diff options
author | Olivier Prouvost | 2014-03-07 20:59:45 +0000 |
---|---|---|
committer | Olivier Prouvost | 2014-03-08 14:20:49 +0000 |
commit | 63315e883ccfeac6764a6e00e56bf81cf70a1920 (patch) | |
tree | b2fbb41f62e15acfe9a2ce873588c17bb54c8572 | |
parent | 8b9cd00cbf87bfd1860f8bd0509e999261c75623 (diff) | |
download | org.eclipse.e4.tools-63315e883ccfeac6764a6e00e56bf81cf70a1920.tar.gz org.eclipse.e4.tools-63315e883ccfeac6764a6e00e56bf81cf70a1920.tar.xz org.eclipse.e4.tools-63315e883ccfeac6764a6e00e56bf81cf70a1920.zip |
Bug 429854 - Stacktrace at start when org.eclipse.e4.tools.context.spyI20140309-2200I20140308-2200
(0.10.v20140303-1452) is included
Occured when no binding table nor context is present in model. In this
case, the created binding context should be created but not added in
application.
Change-Id: I8074fda2f52229ae611624ea78b42bd5fb591b94
Signed-off-by: Olivier Prouvost <olivier.prouvost@opcoach.com>
-rw-r--r-- | bundles/org.eclipse.e4.tools.context.spy/src/org/eclipse/e4/tools/context/spy/ContextSpyProcessor.java | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/bundles/org.eclipse.e4.tools.context.spy/src/org/eclipse/e4/tools/context/spy/ContextSpyProcessor.java b/bundles/org.eclipse.e4.tools.context.spy/src/org/eclipse/e4/tools/context/spy/ContextSpyProcessor.java index 7bd6b841..8e4798f4 100644 --- a/bundles/org.eclipse.e4.tools.context.spy/src/org/eclipse/e4/tools/context/spy/ContextSpyProcessor.java +++ b/bundles/org.eclipse.e4.tools.context.spy/src/org/eclipse/e4/tools/context/spy/ContextSpyProcessor.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.e4.tools.context.spy; +import java.util.List; + import javax.annotation.PostConstruct; import javax.inject.Inject; @@ -164,26 +166,32 @@ public class ContextSpyProcessor // If this context does not yet exist, create it also. if (spyBindingTable == null) { - MBindingContext dialAndWindowContext = null; - for (MBindingContext bc : application.getBindingContexts()) - if (ORG_ECLIPSE_UI_CONTEXTS_DIALOG_AND_WINDOW.equals(bc.getElementId())) - { - dialAndWindowContext = bc; - break; + + MBindingContext bc = null; + final List<MBindingContext> bindingContexts = application + .getBindingContexts(); + if (bindingContexts.size() == 0) { + bc = modelService.createModelElement(MBindingContext.class); + bc.setElementId("org.eclipse.ui.contexts.window"); + } else { + // Prefer org.eclipse.ui.contexts.dialogAndWindow but randomly + // select another one + // if org.eclipse.ui.contexts.dialogAndWindow cannot be found + for (MBindingContext aBindingContext : bindingContexts) { + bc = aBindingContext; + if ("org.eclipse.ui.contexts.dialogAndWindow" + .equals(aBindingContext.getElementId())) { + break; + } } - - if (dialAndWindowContext == null) - { - // This context has not yet been created... Application model - // must be very poor.... - dialAndWindowContext = modelService.createModelElement(MBindingContext.class); - dialAndWindowContext.setElementId(ORG_ECLIPSE_UI_CONTEXTS_DIALOG_AND_WINDOW); } - + + + // Can now create the binding table and bind it to this context... spyBindingTable = modelService.createModelElement(MBindingTable.class); spyBindingTable.setElementId(E4_SPIES_BINDING_TABLE); - spyBindingTable.setBindingContext(dialAndWindowContext); + spyBindingTable.setBindingContext(bc); application.getBindingTables().add(spyBindingTable); } |