diff options
author | Patrik Suzzi | 2016-08-17 16:30:37 +0000 |
---|---|---|
committer | Patrik Suzzi | 2016-08-17 16:30:37 +0000 |
commit | 235f36e62c9746c28c2393e85e7ef5b9065cc8b0 (patch) | |
tree | c664202ba5b37978f4875f7c6a7702550e1ef3a6 | |
parent | 3faef04fd7b8482b0598ddbb5b005dc1da0ab3a2 (diff) | |
download | eclipse.platform.ui-235f36e62c9746c28c2393e85e7ef5b9065cc8b0.tar.gz eclipse.platform.ui-235f36e62c9746c28c2393e85e7ef5b9065cc8b0.tar.xz eclipse.platform.ui-235f36e62c9746c28c2393e85e7ef5b9065cc8b0.zip |
Bug 476045 - Commands visible in Quick Access don't show commandImage
Improvement to previous fix, in order to use PlatformUI.getWorkbench()
org.eclipse.ui.internal.quickaccess.CommandProvider is now responsible
to get an instance of ICommandImageService.
I changed CommandProvider public constructor, but is not a problem as
not API
Change-Id: Id6bb2072a3161977f2120ec12ceac70c62b08b33
Signed-off-by: Patrik Suzzi <psuzzi@gmail.com>
4 files changed, 28 insertions, 8 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/CommandElement.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/CommandElement.java index ece2180866f..35d3d34d6f5 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/CommandElement.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/CommandElement.java @@ -86,7 +86,7 @@ public class CommandElement extends QuickAccessElement { @Override public ImageDescriptor getImageDescriptor() { - ICommandImageService imgService = PlatformUI.getWorkbench().getService(ICommandImageService.class); + ICommandImageService imgService = ((CommandProvider) getProvider()).getCommandImageService(); return (imgService == null) ? null : imgService.getImageDescriptor(getId()); } diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/CommandProvider.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/CommandProvider.java index 731a2117239..b614f3fd087 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/CommandProvider.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/CommandProvider.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Lars Vogel <Lars.Vogel@gmail.com> - Bug 440810 + * Patrik Suzzi <psuzzi@gmail.com> - Bug 476045 *******************************************************************************/ package org.eclipse.ui.internal.quickaccess; @@ -24,6 +25,7 @@ import org.eclipse.e4.core.commands.ExpressionContext; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.commands.ICommandImageService; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.internal.IWorkbenchGraphicConstants; @@ -46,8 +48,15 @@ public class CommandProvider extends QuickAccessProvider { private IHandlerService handlerService; private ICommandService commandService; private EHandlerService ehandlerService; - - public CommandProvider() { + private ICommandImageService commandImageService; + private IEclipseContext context = null; + + /** + * Construct a CommandProvider passing an instance of + * {@code IEclipseContext}. + */ + public CommandProvider(IEclipseContext context) { + this.context = context; } @Override @@ -145,6 +154,16 @@ public class CommandProvider extends QuickAccessProvider { return handlerService; } + /** + * @return Returns the commandImageService. + */ + public ICommandImageService getCommandImageService() { + if (commandImageService == null) { + commandImageService = context.get(ICommandImageService.class); + } + return commandImageService; + } + IEvaluationContext getContextSnapshot() { return currentSnapshot; } 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 1b29d1c2b61..8f13de0ccb6 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 @@ -9,7 +9,7 @@ * IBM Corporation - initial API and implementation * Tom Hochstein (Freescale) - Bug 393703 - NotHandledException selecting inactive command under 'Previous Choices' in Quick access * René Brandstetter - Bug 433778 - * Patrik Suzzi <psuzzi@gmail.com> - Bug 491410 + * Patrik Suzzi <psuzzi@gmail.com> - Bug 491410, 476045 *******************************************************************************/ package org.eclipse.ui.internal.quickaccess; @@ -91,13 +91,14 @@ public class QuickAccessDialog extends PopupDialog { @Override public void run() { - final CommandProvider commandProvider = new CommandProvider(); + MApplication application = model.getContext().get(MApplication.class); + final CommandProvider commandProvider = new CommandProvider(application.getContext()); commandProvider.setSnapshot(new ExpressionContext(model.getContext() .getActiveLeaf())); QuickAccessProvider[] providers = new QuickAccessProvider[] { new PreviousPicksProvider(previousPicksList), new EditorProvider(), - new ViewProvider(model.getContext().get(MApplication.class), model), + new ViewProvider(application, model), new PerspectiveProvider(), commandProvider, new ActionProvider(), new WizardProvider(), new PreferenceProvider(), new PropertiesProvider() }; 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 27f0295b3a4..c27af30e07b 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 @@ -12,7 +12,7 @@ * Brian de Alwis - Fix size computation to account for trim * Markus Kuppe <bugs.eclipse.org@lemmster.de> - Bug 449485: [QuickAccess] "Widget is disposed" exception in errorlog during shutdown due to quickaccess.SearchField.storeDialog * Elena Laskavaia <elaskavaia.cdt@gmail.com> - Bug 433746: [QuickAccess] SWTException on closing quick access shell - * Patrik Suzzi <psuzzi@gmail.com> - Bug 488926, 491278, 491291, 491312, 491293 + * Patrik Suzzi <psuzzi@gmail.com> - Bug 488926, 491278, 491291, 491312, 491293, 476045 ******************************************************************************/ package org.eclipse.ui.internal.quickaccess; import java.util.ArrayList; @@ -160,7 +160,7 @@ public class SearchField { hookUpSelectAll(); - final CommandProvider commandProvider = new CommandProvider(); + final CommandProvider commandProvider = new CommandProvider(application.getContext()); QuickAccessProvider[] providers = new QuickAccessProvider[] { new PreviousPicksProvider(previousPicksList), new EditorProvider(), new ViewProvider(application, window), |