Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2007-02-06 23:09:17 +0000
committerChris Goldthorpe2007-02-06 23:09:17 +0000
commitd7b5ffe132e0dfbbff1fa503fb651447d9d73f6f (patch)
treedbdc46495afc97b687a019757d4c073f0d1c8959 /org.eclipse.ui.cheatsheets
parent5982e397bcbd9affa219486ac85c5226a1c83557 (diff)
downloadeclipse.platform.ua-d7b5ffe132e0dfbbff1fa503fb651447d9d73f6f.tar.gz
eclipse.platform.ua-d7b5ffe132e0dfbbff1fa503fb651447d9d73f6f.tar.xz
eclipse.platform.ua-d7b5ffe132e0dfbbff1fa503fb651447d9d73f6f.zip
[Bug 173158] [CheatSheet] Command not executing in cheat sheet
Diffstat (limited to 'org.eclipse.ui.cheatsheets')
-rw-r--r--org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CommandRunner.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CommandRunner.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CommandRunner.java
index 15a99e9fc..e6a593fa7 100644
--- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CommandRunner.java
+++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CommandRunner.java
@@ -15,12 +15,14 @@ import org.eclipse.core.commands.ParameterType;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.common.CommandException;
import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.internal.cheatsheets.data.CheatSheetCommand;
import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager;
@@ -42,6 +44,18 @@ public class CommandRunner {
return null;
}
+ private IHandlerService getHandlerService() {
+ IWorkbench wb = PlatformUI.getWorkbench();
+ if (wb != null) {
+ Object serviceObject = wb.getAdapter(IHandlerService.class);
+ if (serviceObject != null) {
+ IHandlerService service = (IHandlerService)serviceObject;
+ return service;
+ }
+ }
+ return null;
+ }
+
/**
* Attempt to execute a command
* @param command a CheatSheetCommand created by the parser
@@ -50,8 +64,9 @@ public class CommandRunner {
* an error status
*/
public IStatus executeCommand(CheatSheetCommand command, CheatSheetManager csm) {
- ICommandService service = getCommandService();
- if (service == null) {
+ ICommandService commandService = getCommandService();
+ IHandlerService handlerService = getHandlerService();
+ if (commandService == null || handlerService == null) {
return new Status
(IStatus.ERROR,
ICheatSheetResource.CHEAT_SHEET_PLUGIN_ID, 0,
@@ -63,8 +78,9 @@ public class CommandRunner {
String rawSerialization = command.getSerialization();
try {
String substitutedSerialization = csm.performVariableSubstitution(rawSerialization);
- selectedCommand = service.deserialize(substitutedSerialization);
- result = selectedCommand.executeWithChecks(null, null);
+ selectedCommand = commandService.deserialize(substitutedSerialization);
+ IEvaluationContext state = handlerService.getCurrentState();
+ result = selectedCommand.executeWithChecks(null, state);
String returnsAttribute = command.getReturns();
if ((returnsAttribute != null) && (result != null)) {

Back to the top