Skip to main content



      Home
Home » Eclipse Projects » Advanced Scripting Environment (EASE) » Shouldn't the EcoreModule initialize its selectionModule?
Shouldn't the EcoreModule initialize its selectionModule? [message #1690009] Sat, 20 December 2014 23:43 Go to next message
Eclipse UserFriend
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.
Re: Shouldn't the EcoreModule initialize its selectionModule? [message #1690014 is a reply to message #1690009] Sun, 21 December 2014 15:16 Go to previous messageGo to next message
Eclipse UserFriend
Dependencies should be defined declaratively as part of the module definition. Each module may define its own dependencies. Loading in the correct order will be handled automatically. Furthermore it is guaranteed that all dependencies are correctly loaded when the actual plugin is loaded. To get an instance of such a dependency use getEngile.getModule(module.class).

In theory your patch would be sufficient to initialize the SelectionModule correctly, but the EnvironmentModule would never know about the SelectionModule, which might resolve in other unwanted side effects.
Re: Shouldn't the EcoreModule initialize its selectionModule? [message #1690018 is a reply to message #1690014] Sun, 21 December 2014 19:59 Go to previous message
Eclipse UserFriend
Currently, the EcoreModule does not initialize its EcoreModule.selectionModule object.
This means that if a script calls getSelection() on the EcoreModule, there will be an NPE.
How do you suggest fixing this if not with the patch I proposed?

- Nicolas.
Previous Topic:Obsolete Ecore generated package extensions in EASE UI
Next Topic:Obsolete Ecore generated package extensions in EASE UI
Goto Forum:
  


Current Time: Sun Jul 27 09:36:15 EDT 2025

Powered by FUDForum. Page generated in 0.04562 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top