Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Webster2014-05-28 15:28:58 +0000
committerDaniel Rolka2014-05-28 19:33:24 +0000
commit87b0c10b81c0ebfa0d44ded0b9cf51c628e9c916 (patch)
tree7919785e2a060167d22da4644b6a4a32e57cf67b
parent45c33454013b9daab6b5c50df6b916346d8c0f66 (diff)
downloadeclipse.platform.ui-87b0c10b81c0ebfa0d44ded0b9cf51c628e9c916.tar.gz
eclipse.platform.ui-87b0c10b81c0ebfa0d44ded0b9cf51c628e9c916.tar.xz
eclipse.platform.ui-87b0c10b81c0ebfa0d44ded0b9cf51c628e9c916.zip
Bug 434991 - [QuickAccess] Ctrl+3 quick access popup, while search field
is hidden, does not use the correct scope Use the active leaf of the workbench window as the context scope to search and validate handler enablement. Change-Id: I26f61b94173af48634e1a25c2219b15ee2366ff8
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/CommandProvider.java47
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java11
2 files changed, 49 insertions, 9 deletions
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 c2c227eeb2e..6ab2d4626ff 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
@@ -18,7 +18,9 @@ import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.e4.core.commands.EHandlerService;
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.ICommandService;
@@ -41,6 +43,8 @@ public class CommandProvider extends QuickAccessProvider {
private Map idToElement;
private IHandlerService handlerService;
+ private ICommandService commandService;
+ private EHandlerService ehandlerService;
public CommandProvider() {
}
@@ -60,16 +64,16 @@ public class CommandProvider extends QuickAccessProvider {
public QuickAccessElement[] getElements() {
if (idToElement == null) {
idToElement = new HashMap();
- ICommandService commandService = (ICommandService) PlatformUI
- .getWorkbench().getService(ICommandService.class);
+ ICommandService commandService = getCommandService();
+ EHandlerService ehandlerService = getEHandlerService();
final Collection commandIds = commandService.getDefinedCommandIds();
final Iterator commandIdItr = commandIds.iterator();
while (commandIdItr.hasNext()) {
final String currentCommandId = (String) commandIdItr.next();
final Command command = commandService
.getCommand(currentCommandId);
- if (command != null && command.isHandled()
- && command.isEnabled()) {
+ ParameterizedCommand pcmd = new ParameterizedCommand(command, null);
+ if (command != null && ehandlerService.canExecute(pcmd)) {
try {
Collection combinations = ParameterizedCommand
.generateCombinations(command);
@@ -101,10 +105,41 @@ public class CommandProvider extends QuickAccessProvider {
return QuickAccessMessages.QuickAccess_Commands;
}
+ EHandlerService getEHandlerService() {
+ if (ehandlerService == null) {
+ if (currentSnapshot instanceof ExpressionContext) {
+ IEclipseContext ctx = ((ExpressionContext) currentSnapshot).eclipseContext;
+ ehandlerService = ctx.get(EHandlerService.class);
+ } else {
+ ehandlerService = (EHandlerService) PlatformUI.getWorkbench().getService(
+ EHandlerService.class);
+ }
+ }
+ return ehandlerService;
+ }
+
+ ICommandService getCommandService() {
+ if (commandService == null) {
+ if (currentSnapshot instanceof ExpressionContext) {
+ IEclipseContext ctx = ((ExpressionContext) currentSnapshot).eclipseContext;
+ commandService = ctx.get(ICommandService.class);
+ } else {
+ commandService = (ICommandService) PlatformUI.getWorkbench().getService(
+ ICommandService.class);
+ }
+ }
+ return commandService;
+ }
+
IHandlerService getHandlerService() {
if (handlerService == null) {
- handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(
- IHandlerService.class);
+ if (currentSnapshot instanceof ExpressionContext) {
+ IEclipseContext ctx = ((ExpressionContext) currentSnapshot).eclipseContext;
+ handlerService = ctx.get(IHandlerService.class);
+ } else {
+ handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(
+ IHandlerService.class);
+ }
}
return handlerService;
}
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 77f7f7232f7..a15888c5c05 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
@@ -18,6 +18,7 @@ import java.util.LinkedList;
import java.util.Map;
import org.eclipse.core.commands.Command;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.e4.core.commands.ExpressionContext;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.jface.bindings.TriggerSequence;
@@ -86,13 +87,16 @@ public class QuickAccessDialog extends PopupDialog {
@Override
public void run() {
+ final CommandProvider commandProvider = new CommandProvider();
+ 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 PerspectiveProvider(),
- new CommandProvider(), new ActionProvider(), new WizardProvider(),
- new PreferenceProvider(), new PropertiesProvider() };
+ new PerspectiveProvider(), commandProvider, new ActionProvider(),
+ new WizardProvider(), new PreferenceProvider(),
+ new PropertiesProvider() };
providerMap = new HashMap();
for (int i = 0; i < providers.length; i++) {
providerMap.put(providers[i].getId(), providers[i]);
@@ -254,6 +258,7 @@ public class QuickAccessDialog extends PopupDialog {
.applyTo(filterText);
contents.hookFilterText(filterText);
+ filterText.addKeyListener(getKeyAdapter());
return filterText;
}

Back to the top