Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Injection not working when Xtezt is launch from EMF model
Injection not working when Xtezt is launch from EMF model [message #1234169] Tue, 21 January 2014 11:43 Go to next message
Nieves Salor is currently offline Nieves SalorFriend
Messages: 19
Registered: September 2013
Junior Member
Hello,
I created a Xtext Project referencing an EMF Model (by creating the additional two plugins for binding everything to EMF) and everything is working fine if I launch it as an Eclipse Application directly from the Xtext plugin.
However, if I try to call the Xtext Plugin from the EMF model by selecting one of the elements in the model, the injection does not work. I need to use this because in the EMF model one of the properties of the element is the path of the file the Xtext has to open so I need the resourceSet.

After reading Jan's blog, I created in the application plugin which has dependencies to both EMF and Xtext plugins, the ExecutableExtensionFactory class referencing the Xtext Activator and its extension point in the plugin.xml. But still nothing.
I also try to create the RuntimeModule in the application plugin without success.
Finally I tried to get a hold of the Activator directly in the xtext ui project, and then it was working the guice but not resources where shown although they exist in the file system.

I think the issue is that I should create the Factory in the EMF project by adding the editor extension point to my Xtext in the EMF editor plugin as well as a editor action exptension point, but that would generate a cycle dependency between the plugins.

I think I am doing something wrong. Can you help me?

As a summary of my projects:
-My application project depends on the EMF and Xtext projects
-My EMF project has a handler that when one type of element is selected in the model, triggers the Xtext plugin for the script path referred in that element by a field containing the path.
-The Xtext plugin displays and parses the file content of the Dsl

Thanks in advance
Re: Injection not working when Xtezt is launch from EMF model [message #1234187 is a reply to message #1234169] Tue, 21 January 2014 12:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13489
Registered: July 2009
Senior Member
Hi,

what do you actually want todo:

- have general injection in a non xtext project => Create / Change Activator and ExecutableExtensionFactory in your application project
- get stuff from a specific xtextproject => do the first one and use IGlobalServiceProvider to obtain stuff.


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Injection not working when Xtezt is launch from EMF model [message #1234190 is a reply to message #1234169] Tue, 21 January 2014 12:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13489
Registered: July 2009
Senior Member
P.S: is it possible to use transitive scoping in youzr grammar e.g. by referencing
an anchor from the other grammar and then collect the items manually?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Injection not working when Xtezt is launch from EMF model [message #1234199 is a reply to message #1234190] Tue, 21 January 2014 12:56 Go to previous messageGo to next message
Nieves Salor is currently offline Nieves SalorFriend
Messages: 19
Registered: September 2013
Junior Member
Hi Christian,
It is more the first option than the second. Getting elements from my Xtext Project and its non-Xtext references is not an issue as I made the two plugins for the non-Xtext (xtext.ssm and xtext.ssm.ui) and they work fine.
My issue is launching my xtext project from a non xtext one and triggering the injection. So I think it is a problem of the standAlone running.
In my application I have created, as you said the ExecutableExtensionFactory referencing the DslActivator of my Xtext Project without success. And then I tried to create a new Activator and call the DslRuntimeModule and DslUiModule also without success.
As my Non-Xtext project already has the xtext.ssm and xtext.ssm.ui projects do I also need to create another ExecutableExtensionFactory in the SSM.editor project?
Re: Injection not working when Xtezt is launch from EMF model [message #1234204 is a reply to message #1234199] Tue, 21 January 2014 13:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13489
Registered: July 2009
Senior Member
Hi,

i still not understand what you mean by "launching my xtext project from a non xtext one"
what do you want to inject where?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Injection not working when Xtezt is launch from EMF model [message #1234205 is a reply to message #1234204] Tue, 21 January 2014 13:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13489
Registered: July 2009
Senior Member
And yes id create an own extensionfacotry for the non xtext project

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Injection not working when Xtezt is launch from EMF model [message #1234229 is a reply to message #1234205] Tue, 21 January 2014 13:53 Go to previous messageGo to next message
Nieves Salor is currently offline Nieves SalorFriend
Messages: 19
Registered: September 2013
Junior Member
Ok I try to explain a little bit better:

I have an EMF model called SSM with its .editor plugin displaying some stuff. An element of this model (i.e. procedure) tells me the script file which I have to parse and display in a property named script.
The parsing and edition of this script is done via my Xtext Project (grammar pluto) which contains cross references to my SSM project. These references are working because I created the xtext.ssm and xtext.ssm.ui projects as you answered me in another thread..thanks for that btw.
Now, I need to do the following process: When I right click in the procedure element of the SSM Editor View (which is contained in my SSM.editor plugin), I want to launch the Xtext parser passing the file that is specified in the property script of the procedure element of the SSM from a handler that I have in the Pluto.ui project.
URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
IProject project = file.getProject();	
ResourceSet rs = resourceSetProvider.get(project);
Resource r = rs.getResource(uri, true);
List<Issue> validate = resourceValidator.validate(r, CheckMode.ALL, null);


however my resourceSetProvider is null when I debug although I use the injection in the handler class and in the pluto.ui the extensionFactory and adapters are automatically generated by Xtext.
So I think I need to create as original point of injection the factory and adapter in my SSM.editor plugin. But as I already created the xtext.ssm and xtext.ssm.ui for the cross references, they already should be invoked when launching my SSM.

Ideas?
Re: Injection not working when Xtezt is launch from EMF model [message #1234235 is a reply to message #1234229] Tue, 21 January 2014 14:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13489
Registered: July 2009
Senior Member
Hmmm this should work even without injecting or with injecting and
your own factory

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Injection not working when Xtezt is launch from EMF model [message #1235021 is a reply to message #1234235] Thu, 23 January 2014 11:15 Go to previous message
Nieves Salor is currently offline Nieves SalorFriend
Messages: 19
Registered: September 2013
Junior Member
I found the problem.
The issue was that in my handler class I had to prefix the class also with the ExtensionFactory. Once I did that it was working Very Happy

Thanks again
Previous Topic:Extending the Xtext index
Next Topic:Upgrade from Xtext 2.3.0 to 2.4.1: org.eclipse.xtext.xbase.validation.XtypeJavaValidator missing
Goto Forum:
  


Current Time: Wed Jul 08 05:51:45 GMT 2020

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

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

Back to the top