diff options
author | Tom Hochstein | 2013-07-15 18:03:45 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2013-07-23 14:26:52 +0000 |
commit | fa694e6ccb5d1fdad75a158aaa19c33fcddef0e5 (patch) | |
tree | 23a01d3c5f9960074dde1ee418d42b902d8103f1 | |
parent | acfd04f9d649d248de1de1be5cf1c243cd0d1254 (diff) | |
download | eclipse.platform.ui-fa694e6ccb5d1fdad75a158aaa19c33fcddef0e5.tar.gz eclipse.platform.ui-fa694e6ccb5d1fdad75a158aaa19c33fcddef0e5.tar.xz eclipse.platform.ui-fa694e6ccb5d1fdad75a158aaa19c33fcddef0e5.zip |
Bug 393703 - NotHandledException selecting inactive command under
'Previous Choices' in Quick access
Change-Id: Ic2268ea4f74342612453655f38d49223e13c32ea
Signed-off-by: Tom Hochstein <tom.hochstein@freescale.com>
4 files changed, 90 insertions, 82 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/PreviousPicksProvider.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/PreviousPicksProvider.java new file mode 100644 index 00000000000..d7c7b11d2f1 --- /dev/null +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/PreviousPicksProvider.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2013 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tom Hochstein (Freescale) - Bug 393703 - NotHandledException selecting inactive command under 'Previous Choices' in Quick access + ******************************************************************************/ + +package org.eclipse.ui.internal.quickaccess; + +import java.util.List; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.internal.IWorkbenchGraphicConstants; +import org.eclipse.ui.internal.WorkbenchImages; + +class PreviousPicksProvider extends QuickAccessProvider { + + private List<QuickAccessElement> previousPicksList; + + PreviousPicksProvider(List<QuickAccessElement> previousPicksList) { + this.previousPicksList = previousPicksList; + } + + public QuickAccessElement getElementForId(String id) { + return null; + } + + public QuickAccessElement[] getElements() { + return previousPicksList.toArray(new QuickAccessElement[previousPicksList.size()]); + } + + public QuickAccessElement[] getElementsSorted() { + return getElements(); + } + + public String getId() { + return "org.eclipse.ui.previousPicks"; //$NON-NLS-1$ + } + + public ImageDescriptor getImageDescriptor() { + return WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_OBJ_NODE); + } + + public String getName() { + return QuickAccessMessages.QuickAccess_Previous; + } + + protected void doReset() { + // operation not applicable for this provider + } + + public boolean isAlwaysPresent() { + return true; + } +} diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java index a2414f9a841..9e6a75440a0 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Tom Hochstein (Freescale) - Bug 393703 - NotHandledException selecting inactive command under 'Previous Choices' in Quick access *******************************************************************************/ package org.eclipse.ui.internal.quickaccess; @@ -349,7 +350,7 @@ public abstract class QuickAccessContents { } } - if (entry != null) { + if (entryEnabled(provider, entry)) { entries[i].add(entry); count++; countTotal++; @@ -387,7 +388,7 @@ public abstract class QuickAccessContents { } while ((showAllMatches || countTotal < maxCount) && !done); if (!perfectMatchAdded) { QuickAccessEntry entry = perfectMatch.match(filter, providers[0]); - if (entry != null) { + if (entryEnabled(providers[0], entry)) { if (entries[0] == null) { entries[0] = new ArrayList<QuickAccessEntry>(); indexPerProvider[0] = 0; @@ -398,6 +399,28 @@ public abstract class QuickAccessContents { return entries; } + /** + * @param provider + * @param entry + * @return <code>true</code> if the entry is enabled + */ + private boolean entryEnabled(QuickAccessProvider provider, QuickAccessEntry entry) { + if (entry == null) { + return false; + } + + // For a previous pick provider, check that the original provider does + // also provide the element + if (provider instanceof PreviousPicksProvider) { + QuickAccessElement element = entry.element; + final QuickAccessProvider originalProvider = element.getProvider(); + QuickAccessElement match = originalProvider.getElementForId(element.getId()); + return match != null; + } + + return true; + } + private void doDispose() { if (textLayout != null && !textLayout.isDisposed()) { textLayout.dispose(); diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java index 451cf3b368e..9e6647cdbaa 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Tom Hochstein (Freescale) - Bug 393703 - NotHandledException selecting inactive command under 'Previous Choices' in Quick access *******************************************************************************/ package org.eclipse.ui.internal.quickaccess; @@ -25,7 +26,6 @@ import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.PopupDialog; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; -import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.util.Util; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; @@ -40,8 +40,6 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.internal.IWorkbenchGraphicConstants; -import org.eclipse.ui.internal.WorkbenchImages; import org.eclipse.ui.internal.WorkbenchPlugin; import org.eclipse.ui.internal.WorkbenchWindow; import org.eclipse.ui.internal.progress.ProgressManagerUtil; @@ -87,7 +85,8 @@ public class QuickAccessDialog extends PopupDialog { public void run() { QuickAccessProvider[] providers = new QuickAccessProvider[] { - new PreviousPicksProvider(), new EditorProvider(), + new PreviousPicksProvider(previousPicksList), + new EditorProvider(), new ViewProvider(model.getContext().get(MApplication.class), model), new PerspectiveProvider(), new CommandProvider(), new ActionProvider(), new WizardProvider(), @@ -394,40 +393,4 @@ public class QuickAccessDialog extends PopupDialog { } } - private class PreviousPicksProvider extends QuickAccessProvider { - - public QuickAccessElement getElementForId(String id) { - return null; - } - - public QuickAccessElement[] getElements() { - return (QuickAccessElement[]) previousPicksList - .toArray(new QuickAccessElement[previousPicksList.size()]); - } - - public QuickAccessElement[] getElementsSorted() { - return getElements(); - } - - public String getId() { - return "org.eclipse.ui.previousPicks"; //$NON-NLS-1$ - } - - public ImageDescriptor getImageDescriptor() { - return WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_OBJ_NODE); - } - - public String getName() { - return QuickAccessMessages.QuickAccess_Previous; - } - - public boolean isAlwaysPresent() { - // TODO Auto-generated method stub - return true; - } - - protected void doReset() { - } - } - } diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java index aa137d9b6be..a345246b3fd 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java @@ -7,9 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Tom Hochstein (Freescale) - Bug 393703 - NotHandledException selecting inactive command under 'Previous Choices' in Quick access ******************************************************************************/ package org.eclipse.ui.internal.quickaccess; - import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; @@ -33,7 +33,6 @@ import org.eclipse.e4.ui.workbench.modeling.EPartService; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; -import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.util.Geometry; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; @@ -61,11 +60,10 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.ISources; import org.eclipse.ui.IWorkbenchCommandConstants; import org.eclipse.ui.handlers.IHandlerService; -import org.eclipse.ui.internal.IWorkbenchGraphicConstants; -import org.eclipse.ui.internal.WorkbenchImages; import org.eclipse.ui.internal.WorkbenchPlugin; import org.eclipse.ui.swt.IFocusService; + public class SearchField { private static final String TEXT_ARRAY = "textArray"; //$NON-NLS-1$ @@ -131,7 +129,8 @@ public class SearchField { hookUpSelectAll(); final CommandProvider commandProvider = new CommandProvider(); - QuickAccessProvider[] providers = new QuickAccessProvider[] { new PreviousPicksProvider(), + QuickAccessProvider[] providers = new QuickAccessProvider[] { + new PreviousPicksProvider(previousPicksList), new EditorProvider(), new ViewProvider(application, window), new PerspectiveProvider(), commandProvider, new ActionProvider(), new WizardProvider(), new PreferenceProvider(), new PropertiesProvider() }; @@ -559,41 +558,6 @@ public class SearchField { } } - private class PreviousPicksProvider extends QuickAccessProvider { - - public QuickAccessElement getElementForId(String id) { - return null; - } - - public QuickAccessElement[] getElements() { - return previousPicksList.toArray(new QuickAccessElement[previousPicksList.size()]); - } - - public QuickAccessElement[] getElementsSorted() { - return getElements(); - } - - public String getId() { - return "org.eclipse.ui.previousPicks"; //$NON-NLS-1$ - } - - public ImageDescriptor getImageDescriptor() { - return WorkbenchImages.getImageDescriptor(IWorkbenchGraphicConstants.IMG_OBJ_NODE); - } - - public String getName() { - return QuickAccessMessages.QuickAccess_Previous; - } - - protected void doReset() { - // operation not applicable for this provider - } - - public boolean isAlwaysPresent() { - return true; - } - } - /** * Returns the quick access shell for testing. Should not be referenced * outside of the tests. |