Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Webster2012-05-03 17:15:48 +0000
committerPaul Webster2012-05-03 17:15:48 +0000
commitaa3fabc57b242fcd960289450fa938b613eae295 (patch)
tree0a2b17383c1572391176307155914048ccf249c7
parent01e77a96c92d9107b07af5b21d793224e4a23da8 (diff)
downloadeclipse.platform.ui-aa3fabc57b242fcd960289450fa938b613eae295.tar.gz
eclipse.platform.ui-aa3fabc57b242fcd960289450fa938b613eae295.tar.xz
eclipse.platform.ui-aa3fabc57b242fcd960289450fa938b613eae295.zip
Bug 369159 - [Compatibility] ICommandService/IExecutionListener notv20120503-1715
fired Make sure that bindings refer to the same Commands used by the rest of the system.
-rw-r--r--bundles/org.eclipse.e4.core.commands/src/org/eclipse/e4/core/commands/CommandServiceAddon.java10
-rw-r--r--bundles/org.eclipse.e4.ui.services/src/org/eclipse/e4/ui/services/ContextServiceAddon.java7
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java22
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CommandToModelProcessor.java33
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ContextToModelProcessor.java9
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java3
6 files changed, 63 insertions, 21 deletions
diff --git a/bundles/org.eclipse.e4.core.commands/src/org/eclipse/e4/core/commands/CommandServiceAddon.java b/bundles/org.eclipse.e4.core.commands/src/org/eclipse/e4/core/commands/CommandServiceAddon.java
index 5cdb070f2d6..11242cc0786 100644
--- a/bundles/org.eclipse.e4.core.commands/src/org/eclipse/e4/core/commands/CommandServiceAddon.java
+++ b/bundles/org.eclipse.e4.core.commands/src/org/eclipse/e4/core/commands/CommandServiceAddon.java
@@ -27,9 +27,13 @@ public class CommandServiceAddon {
@PostConstruct
public void init(IEclipseContext context) {
// global command service. There can be only one ... per application :-)
- CommandManager manager = new CommandManager();
- setCommandFireEvents(manager, false);
- context.set(CommandManager.class, manager);
+ CommandManager manager = context.get(CommandManager.class);
+ if (manager == null) {
+ manager = new CommandManager();
+ setCommandFireEvents(manager, false);
+ context.set(CommandManager.class, manager);
+ }
+
CommandServiceImpl service = ContextInjectionFactory
.make(CommandServiceImpl.class, context);
context.set(ECommandService.class, service);
diff --git a/bundles/org.eclipse.e4.ui.services/src/org/eclipse/e4/ui/services/ContextServiceAddon.java b/bundles/org.eclipse.e4.ui.services/src/org/eclipse/e4/ui/services/ContextServiceAddon.java
index e3bda80e8a2..693eb88e752 100644
--- a/bundles/org.eclipse.e4.ui.services/src/org/eclipse/e4/ui/services/ContextServiceAddon.java
+++ b/bundles/org.eclipse.e4.ui.services/src/org/eclipse/e4/ui/services/ContextServiceAddon.java
@@ -10,8 +10,11 @@ public class ContextServiceAddon {
@PostConstruct
public void init(IEclipseContext context) {
// global context service.
- ContextManager contextManager = new ContextManager();
- context.set(ContextManager.class.getName(), contextManager);
+ ContextManager manager = context.get(ContextManager.class);
+ if (manager == null) {
+ manager = new ContextManager();
+ context.set(ContextManager.class, manager);
+ }
context.set(EContextService.class.getName(), new ContextContextFunction());
context.set(IServiceConstants.ACTIVE_CONTEXTS, new ActiveContextsFunction());
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java
index 9d267fa44cf..5cbceda214b 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java
@@ -17,6 +17,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.core.commands.CommandManager;
import org.eclipse.core.commands.contexts.ContextManager;
+import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.bindings.EBindingService;
import org.eclipse.e4.ui.model.application.MApplication;
@@ -27,8 +28,6 @@ import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
import org.eclipse.e4.ui.model.application.commands.impl.CommandsFactoryImpl;
import org.eclipse.jface.bindings.Binding;
import org.eclipse.jface.bindings.BindingManager;
-import org.eclipse.ui.internal.commands.CommandPersistence;
-import org.eclipse.ui.internal.contexts.ContextPersistence;
import org.eclipse.ui.internal.keys.BindingPersistence;
import org.eclipse.ui.internal.keys.BindingService;
@@ -39,18 +38,23 @@ public class BindingToModelProcessor {
private Map<String, MBindingTable> tables = new HashMap<String, MBindingTable>();
@Execute
- void process(final MApplication application) {
+ void process(final MApplication application, IEclipseContext context) {
gatherContexts(application.getRootContext());
gatherCommands(application.getCommands());
gatherTables(application.getBindingTables());
- CommandManager commandManager = new CommandManager();
- CommandPersistence commandPersistence = new CommandPersistence(commandManager);
- commandPersistence.reRead();
- ContextManager contextManager = new ContextManager();
- ContextPersistence contextPersistence = new ContextPersistence(contextManager);
- contextPersistence.reRead();
+ CommandManager commandManager = context.get(CommandManager.class);
+ if (commandManager == null) {
+ WorkbenchPlugin
+ .log("Command manager was null in org.eclipse.ui.internal.BindingToModelProcessor"); //$NON-NLS-1$
+ }
+ ContextManager contextManager = context.get(ContextManager.class);
+ if (contextManager == null) {
+ WorkbenchPlugin
+ .log("Context manager was null in org.eclipse.ui.internal.BindingToModelProcessor"); //$NON-NLS-1$
+ }
BindingManager bindingManager = new BindingManager(contextManager, commandManager);
+ context.set(BindingManager.class, bindingManager);
BindingPersistence persistence = new BindingPersistence(bindingManager, commandManager);
persistence.read();
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CommandToModelProcessor.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CommandToModelProcessor.java
index 464bfdb566f..4138a282dcb 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CommandToModelProcessor.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CommandToModelProcessor.java
@@ -11,6 +11,7 @@
package org.eclipse.ui.internal;
+import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.commands.Category;
@@ -19,6 +20,7 @@ import org.eclipse.core.commands.CommandManager;
import org.eclipse.core.commands.IParameter;
import org.eclipse.core.commands.ParameterType;
import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.commands.MCategory;
@@ -38,7 +40,7 @@ public class CommandToModelProcessor {
private Map<String, MCommand> commands = new HashMap<String, MCommand>();
@Execute
- void process(MApplication application) {
+ void process(MApplication application, IEclipseContext context) {
for (MCategory catModel : application.getCategories()) {
categories.put(catModel.getElementId(), catModel);
}
@@ -46,8 +48,13 @@ public class CommandToModelProcessor {
for (MCommand cmdModel : application.getCommands()) {
commands.put(cmdModel.getElementId(), cmdModel);
}
- // throw away manager for reading
- CommandManager commandManager = new CommandManager();
+ CommandManager commandManager = context.get(CommandManager.class);
+ if (commandManager == null) {
+ commandManager = new CommandManager();
+ setCommandFireEvents(commandManager, false);
+ context.set(CommandManager.class, commandManager);
+ }
+
CommandPersistence cp = new CommandPersistence(commandManager);
cp.reRead();
generateCategories(application, commandManager);
@@ -121,4 +128,24 @@ public class CommandToModelProcessor {
}
}
+ private void setCommandFireEvents(CommandManager manager, boolean b) {
+ try {
+ Field f = CommandManager.class.getDeclaredField("shouldCommandFireEvents"); //$NON-NLS-1$
+ f.setAccessible(true);
+ f.set(manager, Boolean.valueOf(b));
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoSuchFieldException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ContextToModelProcessor.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ContextToModelProcessor.java
index 684efcbe864..991159e91a0 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ContextToModelProcessor.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ContextToModelProcessor.java
@@ -17,6 +17,7 @@ import java.util.Map;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.commands.contexts.Context;
import org.eclipse.core.commands.contexts.ContextManager;
+import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.commands.MBindingContext;
@@ -32,9 +33,13 @@ public class ContextToModelProcessor {
@Execute
- void process(MApplication application) {
+ void process(MApplication application, IEclipseContext context) {
gatherContexts(application.getRootContext());
- ContextManager contextManager = new ContextManager();
+ ContextManager contextManager = context.get(ContextManager.class);
+ if (contextManager == null) {
+ contextManager = new ContextManager();
+ context.set(ContextManager.class, contextManager);
+ }
ContextPersistence cp = new ContextPersistence(contextManager);
cp.reRead();
generateContexts(application, contextManager);
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
index 4f249269fc8..11973c56643 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
@@ -2013,8 +2013,7 @@ UIEvents.Context.TOPIC_CONTEXT,
public void runWithException() {
BindingManager.DEBUG = Policy.DEBUG_KEY_BINDINGS;
- bindingManager = new BindingManager(contextManager, commandManager);
- serviceLocator.registerService(BindingManager.class, bindingManager);
+ bindingManager = e4Context.get(BindingManager.class);
bindingService[0] = ContextInjectionFactory.make(
BindingService.class, e4Context);
}

Back to the top