Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2015-11-26 09:15:55 +0000
committerTom Schindl2015-11-26 09:15:55 +0000
commit1121fcbe2d4bf7e9fed41f78ab2001c599a2192e (patch)
treee884de26eeaa8df660c4ba08ca1d6d4ec1b845a8
parent6021c7f30468e1152c3f3bbe769050674e592b45 (diff)
downloadorg.eclipse.efxclipse-1121fcbe2d4bf7e9fed41f78ab2001c599a2192e.tar.gz
org.eclipse.efxclipse-1121fcbe2d4bf7e9fed41f78ab2001c599a2192e.tar.xz
org.eclipse.efxclipse-1121fcbe2d4bf7e9fed41f78ab2001c599a2192e.zip
Bug 482988 - Application model variables are not declared as modifiable keys in the context
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/AbstractE4Application.java18
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/Util.java56
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/PartRenderingEngine.java24
3 files changed, 67 insertions, 31 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/AbstractE4Application.java b/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/AbstractE4Application.java
index 0118aa2cd..0dac1e67c 100644
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/AbstractE4Application.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/AbstractE4Application.java
@@ -203,18 +203,18 @@ public abstract class AbstractE4Application implements IApplication {
throw new IllegalStateException("Core services not available. Please make sure that a declarative service implementation (such as the bundle 'org.eclipse.equinox.ds') is available!"); //$NON-NLS-1$
}
-
+
StartupProgressTrackerService startupProgressTrackerService = appContext.get(StartupProgressTrackerService.class);
if( startupProgressTrackerService != null ) {
try {
- ContextInjectionFactory.inject(startupProgressTrackerService, appContext);
+ ContextInjectionFactory.inject(startupProgressTrackerService, appContext);
} catch( Throwable t ) {
LOGGER.error("Could not fully initialize the startup tracker", t); //$NON-NLS-1$
}
-
- startupProgressTrackerService.stateReached(DefaultProgressState.DI_SYSTEM_INITIALIZED);
+
+ startupProgressTrackerService.stateReached(DefaultProgressState.DI_SYSTEM_INITIALIZED);
}
-
+
// Get the factory to create DI instances with
IContributionFactory factory = (IContributionFactory) appContext.get(IContributionFactory.class.getName());
@@ -229,11 +229,11 @@ public abstract class AbstractE4Application implements IApplication {
rv = invokePostContextCreate(appContext);
}
}
-
+
if( startupProgressTrackerService != null ) {
- startupProgressTrackerService.stateReached(DefaultProgressState.POST_CONTEXT_LF_FINISHED);
+ startupProgressTrackerService.stateReached(DefaultProgressState.POST_CONTEXT_LF_FINISHED);
}
-
+
switch (rv) {
case RESTART_CLEAR_STATE:
RestartPreferenceUtil prefUtil = ContextInjectionFactory.make(RestartPreferenceUtil.class, appContext);
@@ -263,7 +263,7 @@ public abstract class AbstractE4Application implements IApplication {
appModel.setContext(appContext);
// Set the app's context after adding itself
- appContext.set(MApplication.class.getName(), appModel);
+ Util.setup(appModel, appContext);
initializeServices(appModel);
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/Util.java b/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/Util.java
new file mode 100644
index 000000000..f1d99969c
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.base/src/org/eclipse/fx/ui/workbench/base/Util.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2015 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ui.workbench.base;
+
+import java.util.Map;
+
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.ui.model.application.ui.MContext;
+
+/**
+ * Utility methods
+ *
+ * @since 2.2.0
+ */
+public class Util {
+ /**
+ * Associate the context and the model, initializing context information
+ * from the model
+ *
+ * @param model
+ * the model
+ * @param context
+ * the context
+ * @since 2.2.0
+ */
+ public static void setup(MContext model, IEclipseContext context) {
+ populateModelInterfaces(model, context, model.getClass().getInterfaces());
+
+ for (String variable : model.getVariables()) {
+ context.declareModifiable(variable);
+ }
+
+ Map<String, String> props = model.getProperties();
+ for (String key : props.keySet()) {
+ context.set(key, props.get(key));
+ }
+
+ model.setContext(context);
+ }
+
+ private static void populateModelInterfaces(MContext contextModel, IEclipseContext context, Class<?>[] interfaces) {
+ for (Class<?> intf : interfaces) {
+ context.set(intf.getName(), contextModel);
+
+ populateModelInterfaces(contextModel, context, intf.getInterfaces());
+ }
+ }
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/PartRenderingEngine.java b/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/PartRenderingEngine.java
index 6730b5a2b..40e19daf5 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/PartRenderingEngine.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/PartRenderingEngine.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.fx.ui.workbench.fx;
-import java.util.Map;
-
import javax.inject.Inject;
import javax.inject.Named;
@@ -43,6 +41,7 @@ import org.eclipse.fx.core.log.Logger;
import org.eclipse.fx.ui.keybindings.e4.EBindingService;
import org.eclipse.fx.ui.services.theme.ThemeManager;
import org.eclipse.fx.ui.workbench.base.AbstractE4Application;
+import org.eclipse.fx.ui.workbench.base.Util;
import org.eclipse.fx.ui.workbench.base.rendering.ElementRenderer;
import org.eclipse.fx.ui.workbench.base.rendering.RendererFactory;
import org.eclipse.fx.ui.workbench.fx.key.KeyBindingDispatcher;
@@ -261,29 +260,10 @@ public class PartRenderingEngine implements IPresentationEngine {
private static IEclipseContext createContext(MContext model, IEclipseContext parentContext) {
IEclipseContext lclContext = parentContext.createChild(getContextName((MApplicationElement) model));
- populateModelInterfaces(model, lclContext, model.getClass().getInterfaces());
- model.setContext(lclContext);
-
- for (String variable : model.getVariables()) {
- lclContext.declareModifiable(variable);
- }
-
- Map<String, String> props = model.getProperties();
- for (String key : props.keySet()) {
- lclContext.set(key, props.get(key));
- }
-
+ Util.setup(model, lclContext);
return lclContext;
}
- private static void populateModelInterfaces(MContext contextModel, IEclipseContext context, Class<?>[] interfaces) {
- for (Class<?> intf : interfaces) {
- context.set(intf.getName(), contextModel);
-
- populateModelInterfaces(contextModel, context, intf.getInterfaces());
- }
- }
-
private static String getContextName(MApplicationElement element) {
StringBuilder builder = new StringBuilder(element.getClass().getSimpleName());
String elementId = element.getElementId();

Back to the top