Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2013-12-16 10:45:44 -0500
committerLars Vogel2013-12-16 10:46:54 -0500
commitb4e739328ab3c46c2994191d20e8fd5449df8a78 (patch)
tree57df59370b005be76fdbb7ca6c9d5b4a136d5001
parentbe7720d498a7da9b559778bda50012c9cd7affdf (diff)
downloadorg.eclipse.e4.tools-I20140103-2200.tar.gz
org.eclipse.e4.tools-I20140103-2200.tar.xz
org.eclipse.e4.tools-I20140103-2200.zip
handlers and commands Change-Id: Ic24b001e0760766d2f7af0736938f633c05e716c Signed-off-by: Lars Vogel <Lars.Vogel@gmail.com>
-rw-r--r--bundles/org.eclipse.e4.tools.emf.liveeditor/src/org/eclipse/e4/tools/emf/liveeditor/ModelProcessor.java34
1 files changed, 21 insertions, 13 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.liveeditor/src/org/eclipse/e4/tools/emf/liveeditor/ModelProcessor.java b/bundles/org.eclipse.e4.tools.emf.liveeditor/src/org/eclipse/e4/tools/emf/liveeditor/ModelProcessor.java
index 6f969f65..8d83bd93 100644
--- a/bundles/org.eclipse.e4.tools.emf.liveeditor/src/org/eclipse/e4/tools/emf/liveeditor/ModelProcessor.java
+++ b/bundles/org.eclipse.e4.tools.emf.liveeditor/src/org/eclipse/e4/tools/emf/liveeditor/ModelProcessor.java
@@ -26,36 +26,44 @@ import org.eclipse.e4.ui.workbench.modeling.EModelService;
public class ModelProcessor {
+ private static final String E4_TOOLING_LIVEMODEL_HANDLER = "e4.tooling.livemodel.handler";
+ private static final String E4_TOOLING_LIVEMODEL = "e4.tooling.livemodel";
+
@Execute
public void process(MApplication application, EModelService modelService) {
- List<MCommand> commands = modelService.findElements(application,
- "e4.tooling.livemodel", MCommand.class, null);
MCommand command = null;
+ for (MCommand cmd : application.getCommands()) {
+ if (E4_TOOLING_LIVEMODEL.equals(cmd.getElementId())) {
+ command = cmd;
+ }
+ }
+ // List<MCommand> commands = modelService.findElements(application,
+ // E4_TOOLING_LIVEMODEL, MCommand.class, null);
- if (commands.size() == 0) {
+ if (command == null) {
command = modelService.createModelElement(MCommand.class);
- command.setElementId("e4.tooling.livemodel");
+ command.setElementId(E4_TOOLING_LIVEMODEL);
command.setCommandName("Show running app model");
command.setDescription("Show the running application model");
application.getCommands().add(command);
- } else {
- command = commands.get(0);
}
- List<MHandler> handlers = modelService.findElements(application,
- "e4.tooling.livemodel.handler", MHandler.class, null);
-
MHandler handler = null;
- if (handlers.size() == 0) {
+ for (MHandler hdl : application.getHandlers()) {
+ if (E4_TOOLING_LIVEMODEL_HANDLER.equals(handler.getElementId())) {
+ handler = hdl;
+ }
+ }
+
+ if (handler == null) {
handler = modelService.createModelElement(MHandler.class);
- handler.setElementId("e4.tooling.livemodel.handler");
+ handler.setElementId(E4_TOOLING_LIVEMODEL_HANDLER);
handler.setContributionURI("bundleclass://org.eclipse.e4.tools.emf.liveeditor/org.eclipse.e4.tools.emf.liveeditor.OpenLiveDialogHandler");
application.getHandlers().add(handler);
- } else {
- handler = handlers.get(0);
}
+
handler.setCommand(command);
MKeyBinding binding = null;

Back to the top