diff options
author | Lars Vogel | 2013-12-16 15:45:44 +0000 |
---|---|---|
committer | Lars Vogel | 2013-12-16 15:46:54 +0000 |
commit | b4e739328ab3c46c2994191d20e8fd5449df8a78 (patch) | |
tree | 57df59370b005be76fdbb7ca6c9d5b4a136d5001 | |
parent | be7720d498a7da9b559778bda50012c9cd7affdf (diff) | |
download | org.eclipse.e4.tools-b4e739328ab3c46c2994191d20e8fd5449df8a78.tar.gz org.eclipse.e4.tools-b4e739328ab3c46c2994191d20e8fd5449df8a78.tar.xz org.eclipse.e4.tools-b4e739328ab3c46c2994191d20e8fd5449df8a78.zip |
Bug 424140 - LiveModelEditor should not rely on findElements forI20140111-2200I20140110-2200I20140109-2200I20140108-2200I20140108-1400I20140107-2200I20140106-2200I20140105-2200I20140104-2200I20140103-2200I20140102-2200I20140101-2200I20140101-1400I20131231-2200I20131230-2200I20131229-2200I20131228-2200I20131227-2200I20131226-2200I20131225-2200I20131225-1400I20131224-2200I20131223-2200I20131222-2200I20131221-2200I20131220-2200I20131219-2200I20131218-2200I20131218-1400I20131217-2200I20131216-2200
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.java | 34 |
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; |