Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Advanced Scripting Environment (EASE) » Shouldn't the EcoreModule initialize its selectionModule?
Shouldn't the EcoreModule initialize its selectionModule? [message #1520270] Sun, 21 December 2014 04:43 Go to next message
Nicolas Rouquette is currently offline Nicolas RouquetteFriend
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.
Re: Shouldn't the EcoreModule initialize its selectionModule? [message #1521414 is a reply to message #1520270] Sun, 21 December 2014 20:16 Go to previous messageGo to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 197
Registered: July 2009
Location: Graz, Austria
Senior Member
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 #1521761 is a reply to message #1521414] Mon, 22 December 2014 00:59 Go to previous messageGo to next message
Nicolas Rouquette is currently offline Nicolas RouquetteFriend
Messages: 157
Registered: July 2009
Senior Member
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.
Re: Shouldn't the EcoreModule initialize its selectionModule? [message #1522275 is a reply to message #1521761] Mon, 22 December 2014 07:55 Go to previous messageGo to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 197
Registered: July 2009
Location: Graz, Austria
Senior Member
SelectionModule should be declared as a module in its plugin manifest. Afterwards EcoreModule could define that module as a dependency (again in the manifest). Then there is no need for the EcoreModule to initialize the selection module. It will simply be there once the EcoreModule is loaded.
Re: Shouldn't the EcoreModule initialize its selectionModule? [message #1523060 is a reply to message #1522275] Mon, 22 December 2014 18:05 Go to previous message
Nicolas Rouquette is currently offline Nicolas RouquetteFriend
Messages: 40
Registered: December 2014
Member
Pushed a fix on gerrit for bug 455979
Re: Shouldn't the EcoreModule initialize its selectionModule? [message #1690020 is a reply to message #1521761] Mon, 22 December 2014 07:55 Go to previous message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 197
Registered: July 2009
Location: Graz, Austria
Senior Member
SelectionModule should be declared as a module in its plugin manifest. Afterwards EcoreModule could define that module as a dependency (again in the manifest). Then there is no need for the EcoreModule to initialize the selection module. It will simply be there once the EcoreModule is loaded.
Re: Shouldn't the EcoreModule initialize its selectionModule? [message #1690024 is a reply to message #1522275] Mon, 22 December 2014 18:05 Go to previous message
Nicolas Rouquette is currently offline Nicolas RouquetteFriend
Messages: 157
Registered: July 2009
Senior Member
Pushed a fix on gerrit for bug 455979
Previous Topic:Obsolete Ecore generated package extensions in EASE UI
Next Topic:Problems with EASE's SelectionModule & missing extensions
Goto Forum:
  


Current Time: Mon Oct 15 14:34:26 GMT 2018

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

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

Back to the top