Shouldn't the EcoreModule initialize its selectionModule? [message #1690009] |
Sun, 21 December 2014 04:43 |
Nicolas Rouquette Messages: 157 Registered: July 2009 |
Senior Member |
|
|
When the EcoreModule is instantiated, it also instantiates a SelectionModule but does not initialize it:
public class EcoreModule extends AbstractScriptModule {
protected SelectionModule selectionModule = new SelectionModule();
...
This means that if we try to get the selection, then we get an NPE:
In EcoreModule:
public EObject getSelection() {
Object selection = selectionModule.getCustomSelectionFromSelector(GMFSemanticSeletor.SELECTOR_ID);
if (selection instanceof EObject) {
...
because SelectionModule.getCustomSelectionFromSelector(...) needs to access the environment module.
To avoid this problem, I overloaded initialize() in EcoreModule so as to initialize its selection module:
diff --git a/plugins/org.eclipse.ease.modules.modeling/src/org/eclipse/ease/modules/modeling/EcoreModule.java b/plugins/org.eclipse.ease.modules.modeling/src/org/eclipse/ease/modules/modeling/EcoreModule.java
index 4daedce..dc25979 100644
--- a/plugins/org.eclipse.ease.modules.modeling/src/org/eclipse/ease/modules/modeling/EcoreModule.java
+++ b/plugins/org.eclipse.ease.modules.modeling/src/org/eclipse/ease/modules/modeling/EcoreModule.java
@@ -26,9 +26,11 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.ease.IScriptEngine;
import org.eclipse.ease.Logger;
import org.eclipse.ease.modules.AbstractScriptModule;
import org.eclipse.ease.modules.BootStrapper;
+import org.eclipse.ease.modules.IEnvironment;
import org.eclipse.ease.modules.IModuleWrapper;
import org.eclipse.ease.modules.ScriptParameter;
import org.eclipse.ease.modules.WrapToScript;
@@ -156,6 +158,12 @@ public class EcoreModule extends AbstractScriptModule {
return false;
}
};
+
+ @Override
+ public void initialize(final IScriptEngine engine, final IEnvironment environment) {
+ super.initialize(engine, environment);
+ selectionModule.initialize(engine, environment);
+ }
/**
* Initialized the module with the correct metamodèle. If this method is not called the module will at runtime ask with metamodel shall be used.
Is this correct?
- Nicolas.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.25631 seconds