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 #1520270] 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 #1521414 is a reply to message #1520270] 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 #1521761 is a reply to message #1521414] Sun, 21 December 2014 19:59 Go to previous messageGo to next 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.
Re: Shouldn't the EcoreModule initialize its selectionModule? [message #1522275 is a reply to message #1521761] Mon, 22 December 2014 02:55 Go to previous messageGo to next message
Eclipse UserFriend
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 13:05 Go to previous message
Eclipse UserFriend
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 02:55 Go to previous message
Eclipse UserFriend
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 13:05 Go to previous message
Eclipse UserFriend
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: Sat Jun 21 04:27:17 EDT 2025

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

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

Back to the top