Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Running a workflow programmatically
Running a workflow programmatically [message #542285] Thu, 24 June 2010 12:57 Go to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 60
Registered: April 2010
Member
Hello,

I was wondering what was the best way to run a workflow present in a plugin deployed on the platform, and to give some its parameter.

I would like to be able to run a generator workflow on a folder containing file for my dsl from the right-click menu.

With oAW 4.3 I used WorkflowLogRunner.run with a property map, but it doesn't seem to exist in TMF...

Thanks
Re: Running a workflow programmatically [message #542317 is a reply to message #542285] Thu, 24 June 2010 13:20 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Victor,

please use the org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 24.06.10 14:57, schrieb Victor:
> Hello,
>
> I was wondering what was the best way to run a workflow present in a
> plugin deployed on the platform, and to give some its parameter.
>
> I would like to be able to run a generator workflow on a folder
> containing file for my dsl from the right-click menu.
>
> With oAW 4.3 I used WorkflowLogRunner.run with a property map, but it
> doesn't seem to exist in TMF...
>
> Thanks
Re: Running a workflow programmatically [message #542323 is a reply to message #542317] Thu, 24 June 2010 14:29 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 60
Registered: April 2010
Member
Sebastian Zarnekow wrote on Thu, 24 June 2010 09:20
Hi Victor,

please use the org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.

Regards,
Sebastian


Oh, ok, and is there something specific to do regarding dependency injection? Or should I just instantiate a Mwe2Runner and use it?

Thank you
Re: Running a workflow programmatically [message #542380 is a reply to message #542323] Thu, 24 June 2010 16:20 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 60
Registered: April 2010
Member
Victor wrote on Thu, 24 June 2010 10:29
Sebastian Zarnekow wrote on Thu, 24 June 2010 09:20
Hi Victor,

please use the org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.

Regards,
Sebastian


Oh, ok, and is there something specific to do regarding dependency injection? Or should I just instantiate a Mwe2Runner and use it?

Thank you


Ok, so I created the Mwe2Runner with the following code:
Guice.createInjector(new Mwe2RuntimeModule()).getInstance(Mwe2Runner.class);


Not sure if it is the right way to do it, but it seems to work

The problem is that now it can't find my workflow, I get the following backtrace:
java.lang.IllegalArgumentException: Couldn't find module with name 'workflow.MuADLTGenerator'.
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:63)
	at fr.irit.smac.may.ui.popup.actions.InvokeGeneratorOnDir.launch(InvokeGeneratorOnDir.java:68)
	at fr.irit.smac.may.ui.popup.actions.InvokeGeneratorOnDir.run(InvokeGeneratorOnDir.java:52)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3552)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3171)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)


workflow.MuADLTGenerator is in my .generator project. I tried to add it to the Required-Bundles of the project on which I am running the generation (with a popup menu), it didn't change anything.

But anyway I would like that the user of my plugin has not to add any dependency, nor use PDE dependency management...

Any idea on how to resolve that?

Thanks again!
Re: Running a workflow programmatically [message #542907 is a reply to message #542380] Sun, 27 June 2010 11:52 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
Victor wrote on Thu, 24 June 2010 12:20

Ok, so I created the Mwe2Runner with the following code:
Guice.createInjector(new Mwe2RuntimeModule()).getInstance(Mwe2Runner.class);


Not sure if it is the right way to do it, but it seems to work



Hello again,

I also tried using the following, as in the Mwe2Launcher, but I always get the error about workflow.MuADLTGenerator being not found:

Injector injector = new Mwe2StandaloneSetup().createInjectorAndDoEMFRegistration();
Mwe2Runner runner = injector.getInstance(Mwe2Runner.class);
runner.run("workflow.MuADLTGenerator", properties);


If I try to debug it, it seems that Mwe2Runneris using the classpath returned by System.getProperty("java.class.path") to find the resource, and this classpath seems strange, it contains only the following:
org.eclipse.equinox.launcher_1.1.0.v20100507.jar


Not sure this is normal.

I remind you the context: the workflow is executed from a plugin contributing to the extension point org.eclipse.ui.popupMenus with an action.
The workflow itself is in a plugin (a generated generator project from xtext) in the dependencies of the first plugin.
It meant to be used transparently by a user of my dsl.
Re: Running a workflow programmatically [message #542911 is a reply to message #542907] Sun, 27 June 2010 12:04 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Victor,

you should never try to execute the standalone setup in an OSGi
environment. This will corrupt the global registries of your running
Eclipse instance.
It is usually not a good idea to use the very same workflow for the
standalone-mode and the "inside Eclipse"-mode.
Please have a look at the implementation of the Mwe2Runner. It is
configured with other components, e.g. the RuntimeResourceSetInitializer
which in turn uses other exchangeable components. I'm afraid you'll have
to dig into the implementation and hook the way a module is identified.
Another option is to call the generator directly or to use the
Mwe2Execution and IWorkflow#run(IWorkflowContext) directly.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 27.06.10 13:52, schrieb Victor:
> Victor wrote on Thu, 24 June 2010 12:20
>> Ok, so I created the Mwe2Runner with the following code:
>>
>> Guice.createInjector(new
>> Mwe2RuntimeModule()).getInstance(Mwe2Runner.class);
>>
>>
>> Not sure if it is the right way to do it, but it seems to work
>
>
> Hello again,
>
> I also tried using the following, as in the Mwe2Launcher, but I always
> get the error about workflow.MuADLTGenerator being not found:
>
>
> Injector injector = new
> Mwe2StandaloneSetup().createInjectorAndDoEMFRegistration();
> Mwe2Runner runner = injector.getInstance(Mwe2Runner.class);
> runner.run("workflow.MuADLTGenerator", properties);
>
>
> If I try to debug it, it seems that Mwe2Runneris using the classpath
> returned by System.getProperty("java.class.path") to find the resource,
> and this classpath seems strange, it contains only the following:
>
> org.eclipse.equinox.launcher_1.1.0.v20100507.jar
>
>
> Not sure this is normal.
>
> I remind you the context: the workflow is executed from a plugin
> contributing to the extension point org.eclipse.ui.popupMenus with an
> action.
> The workflow itself is in a plugin (a generated generator project from
> xtext) in the dependencies of the first plugin.
> It meant to be used transparently by a user of my dsl.
Re: Running a workflow programmatically [message #542912 is a reply to message #542911] Sun, 27 June 2010 12:13 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 112
Registered: June 2010
Senior Member
Sebastian Zarnekow wrote on Sun, 27 June 2010 08:04
Hi Victor,

you should never try to execute the standalone setup in an OSGi
environment. This will corrupt the global registries of your running
Eclipse instance.



If not, how can I instantiate a new Mwe2Runner?

Sebastian Zarnekow wrote on Sun, 27 June 2010 08:04

It is usually not a good idea to use the very same workflow for the
standalone-mode and the "inside Eclipse"-mode.
Please have a look at the implementation of the Mwe2Runner. It is
configured with other components, e.g. the RuntimeResourceSetInitializer
which in turn uses other exchangeable components. I'm afraid you'll have
to dig into the implementation and hook the way a module is identified.
Another option is to call the generator directly or to use the
Mwe2Execution and IWorkflow#run(IWorkflowContext) directly.



So you do mean that I should not use Mwe2Runner but reimplement something similar based on its content?
Or do I misunderstand what you say?

I will try to look at the things you mention, thank you :)
Re: Running a workflow programmatically [message #542921 is a reply to message #542912] Sun, 27 June 2010 14:23 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 60
Registered: April 2010
Member
Hello again,

I tried to change the behaviour of Mwe2Runner by extending it as following:
public class MyMwe2Runner extends Mwe2Runner {
	@Override
	protected List<String> getPathes() {
		List<String> r = Lists.newArrayList();
		Bundle bundle = Platform.getBundle("fr.irit.smac.muadl.text.generator");
		try {
			URL fileLocation = FileLocator.toFileURL(bundle.getEntry("/"));
			r.add(fileLocation.getPath());
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		return r;
	}
}


I also changed the way I instantiate this runner:
Injector injector = Guice.createInjector(new MuADLTRuntimeModule());
Mwe2Runner runner = injector.getInstance(MyMwe2Runner.class);


(I also tried using the MuADLTExecutableExtensionFactory in the action definition of the plugin.xml but it didn't work, the ExecutableExtensionFactory couldn't find the class of the action to be executed... certainly because these plugin.xml and class for the action is not in the same project as the one were MuADLTExecutableExtensionFactory is...)

This way, the module is found, but I nevertheless get errors when EcoreUtil.resolveAll is called on the found object:
java.lang.IllegalStateException: [XtextLinkingDiagnostic: null:9 Couldn't resolve reference to JvmType 'Workflow'., XtextLinkingDiagnostic: null:11 Couldn't resolve reference to JvmFeature 'component'., XtextLinkingDiagnostic: null:11 Couldn't resolve reference to JvmType 'org.eclipse.xtext.mwe.Reader'., XtextLinkingDiagnostic: null:16 Couldn't resolve reference to JvmFeature 'path'., XtextLinkingDiagnostic: null:19 Couldn't resolve reference to JvmFeature 'register'., XtextLinkingDiagnostic: null:19 Couldn't resolve reference to JvmType 'fr.irit.smac.muadl.text.MuADLTStandaloneSetup'., XtextLinkingDiagnostic: null:21 Couldn't resolve reference to JvmFeature 'load'., XtextLinkingDiagnostic: null:22 Couldn't resolve reference to JvmFeature 'slot'., XtextLinkingDiagnostic: null:23 Couldn't resolve reference to JvmFeature 'type'., XtextLinkingDiagnostic: null:25 Couldn't resolve reference to JvmFeature 'load'., XtextLinkingDiagnostic: null:26 Couldn't resolve reference to JvmFeature 'slot'., XtextLinkingDiagnostic: null:27 Couldn't resolve reference to JvmFeature 'type'., XtextLinkingDiagnostic: null:31 Couldn't resolve reference to JvmFeature 'component'., XtextLinkingDiagnostic: null:31 Couldn't resolve reference to JvmType 'org.eclipse.xpand2.Generator'., XtextLinkingDiagnostic: null:32 Couldn't resolve reference to JvmFeature 'expand'., XtextLinkingDiagnostic: null:33 Couldn't resolve reference to JvmFeature 'outlet'., XtextLinkingDiagnostic: null:34 Couldn't resolve reference to JvmFeature 'path'., XtextLinkingDiagnostic: null:35 Couldn't resolve reference to JvmFeature 'postprocessor'., XtextLinkingDiagnostic: null:35 Couldn't resolve reference to JvmType 'org.eclipse.xpand2.output.JavaBeautifier'., XtextLinkingDiagnostic: null:37 Couldn't resolve reference to JvmFeature 'fileEncoding'., XtextLinkingDiagnostic: null:40 Couldn't resolve reference to JvmFeature 'component'., XtextLinkingDiagnostic: null:40 Couldn't resolve reference to JvmType 'org.eclipse.xpand2.Generator'., XtextLinkingDiagnostic: null:41 Couldn't resolve reference to JvmFeature 'expand'., XtextLinkingDiagnostic: null:42 Couldn't resolve reference to JvmFeature 'outlet'., XtextLinkingDiagnostic: null:43 Couldn't resolve reference to JvmFeature 'path'., XtextLinkingDiagnostic: null:44 Couldn't resolve reference to JvmFeature 'postprocessor'., XtextLinkingDiagnostic: null:44 Couldn't resolve reference to JvmType 'org.eclipse.xpand2.output.JavaBeautifier'., XtextLinkingDiagnostic: null:46 Couldn't resolve reference to JvmFeature 'fileEncoding'.]
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:66)


Any ideas? Am I going the wrong way?

And if I want to try to directly use the run() on the IWorkflow, what is the way to get the Workflow object itself?!

Thanks
Re: Running a workflow programmatically [message #543010 is a reply to message #542921] Mon, 28 June 2010 08:15 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 60
Registered: April 2010
Member
Would it be easier if it's a mwe1 workflow that has to be run?

Since it was w orking well with oaw workflows...
Re: Running a workflow programmatically [message #543046 is a reply to message #543010] Mon, 28 June 2010 09:47 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 60
Registered: April 2010
Member
Victor wrote on Mon, 28 June 2010 04:15
Would it be easier if it's a mwe1 workflow that has to be run?

Since it was working well with oaw workflows...


Hello again,

Using WorkflowRunner and the generator workflow rewritten with mwe1, I can finally execute my generator as I wanted.

One more problem is present:
My DSL depends on the JvmTypes and obviously, when an instance of the dsl is referring to types declared inside a project, running the workflow uses the classpath of the plugin contributing to the popup menu and not the classpath of the project on which it is executed.
This results in errors as this one:
8: Couldn't resolve reference to JvmType 'fr.irit.smac.may.common.interfaces.Queue'.


What could I do to workaround that?

Thank you again,

Victor
Re: Running a workflow programmatically [message #543926 is a reply to message #542921] Thu, 01 July 2010 06:37 Go to previous messageGo to next message
rkrul is currently offline rkrulFriend
Messages: 12
Registered: July 2010
Junior Member
Victor wrote on Sun, 27 June 2010 10:23
...
This way, the module is found, but I nevertheless get errors when EcoreUtil.resolveAll is called on the found object:
java.lang.IllegalStateException: [XtextLinkingDiagnostic: null:9 Couldn't resolve reference to JvmType 'Workflow'., XtextLinkingDiagnostic: null:11 Couldn't resolve reference to ...


Any ideas? Am I going the wrong way?



I am running into the same problem:

I want to run the mwe2 workflow to start code generation for some of my model files from within my editor.
When i start the workflow from inside eclipse using the run configuration it works fine, but i have no idea how to start it programmatically. Trying Victor's solution gives me the same error message.

Does anyone have an example how to start xpand for model files from within code?
Re: Running a workflow programmatically [message #543944 is a reply to message #543926] Thu, 01 July 2010 07:32 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 60
Registered: April 2010
Member
Hi,

When I will have it working it will be available online, I almost done (actually, the running workflow part is ok, I only have classpath problems because of my particular DSL).

I rewrote the generator workflow with mwe1 and run it with WorkflowRunner.

I will post here when I put it online if you want.
Re: Running a workflow programmatically [message #544039 is a reply to message #543944] Thu, 01 July 2010 12:43 Go to previous messageGo to next message
rkrul is currently offline rkrulFriend
Messages: 12
Registered: July 2010
Junior Member
Victor wrote on Thu, 01 July 2010 03:32
Hi,

When I will have it working it will be available online, I almost done (actually, the running workflow part is ok, I only have classpath problems because of my particular DSL).

I rewrote the generator workflow with mwe1 and run it with WorkflowRunner.

I will post here when I put it online if you want.


Thank you, but i was looking for a solution for mwe2, because with mwe1 it doesn't work from inside eclipse since i migrated to xtext 1.0.
Re: Running a workflow programmatically [message #544041 is a reply to message #544039] Thu, 01 July 2010 12:48 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 60
Registered: April 2010
Member
Hm,

You mean executing the workflow with Run As?

You can have both workflows: one for executing in a Standalone way with mwe2, and one for executing programmatically (no Standalone) with mwe1.

Anyway, you can also wait for the next release in a "couple of week" (citing one of xtext dev) that will fix the problem with mwe2.
Re: Running a workflow programmatically [message #544390 is a reply to message #544039] Fri, 02 July 2010 13:53 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
See https://bugs.eclipse.org/bugs/show_bug.cgi?id=318721

rkrul@web.de schrieb:
> Victor wrote on Thu, 01 July 2010 03:32
>> Hi,
>>
>> When I will have it working it will be available online, I almost done
>> (actually, the running workflow part is ok, I only have classpath
>> problems because of my particular DSL).
>>
>> I rewrote the generator workflow with mwe1 and run it with
>> WorkflowRunner.
>>
>> I will post here when I put it online if you want.
>
>
> Thank you, but i was looking for a solution for mwe2, because with mwe1
> it doesn't work from inside eclipse since i migrated to xtext 1.0.


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: Running a workflow programmatically [message #544393 is a reply to message #544390] Fri, 02 July 2010 14:41 Go to previous messageGo to next message
Victor Noël is currently offline Victor NoëlFriend
Messages: 60
Registered: April 2010
Member
Thanks for the information.

I am currently doing it with a IXtextBuilderParticipant and no workflow at all, but I would indeed wanted to do it with a workflow :)

Victor
Re: Running a workflow programmatically [message #559311 is a reply to message #542285] Thu, 16 September 2010 10:52 Go to previous messageGo to next message
Vishal seth is currently offline Vishal sethFriend
Messages: 32
Registered: April 2010
Member
Hi,

Facing a similar issue when trying to run this in standalone environment. Was able to find the module by providing implementation of RuntimeResourceSetInitializer but failed when it does EcoreUtil.resolveAll(module) in Mwe2Runner.
Was not able to follow from the post what would be required to move ahead with this problem.

Tried debugging this issue to resolve but got lost in org.eclipse.xtext.linking.lazy.getEObject() where it tries to find the linkedObjects & unable to find it.

Thanks
Vishal
Re: Running a workflow programmatically [message #559928 is a reply to message #559311] Mon, 20 September 2010 12:38 Go to previous messageGo to next message
Vishal seth is currently offline Vishal sethFriend
Messages: 32
Registered: April 2010
Member
Hi,

After further debugging, issue is resolved. Basically there were classpath issues. It used to look into ClasspathTypeProvider & returns TypeNotFoundException which was then handled by AbstractTypeScope & returns null. Have then added required libs & worked properly.

Thanks
Vishal
Re: Running a workflow programmatically [message #559977 is a reply to message #559928] Mon, 20 September 2010 15:20 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Hello,

I just see this topic and I have the same problem.
I try to launch programmatically a workflow (.mwe2 file), but it doesn't work.
I describe it in this topic :
http:// www.eclipse.org/forums/index.php?t=msg&th=175543&sta rt=0&S=50764b23f3fb6298809d66de4923fbd8

Jérémie

[Updated on: Tue, 21 September 2010 10:26]

Report message to a moderator

Re: Running a workflow programmatically [message #560095 is a reply to message #559977] Tue, 21 September 2010 08:19 Go to previous messageGo to next message
Vishal seth is currently offline Vishal sethFriend
Messages: 32
Registered: April 2010
Member
Hi,

RuntimeResourceSetInitializer tries to get the classpath from "java.class.path" which in case of eclipse container only comprises of equinox launcher. Hence you would need to inject custom implementation of the above mentioned class for method getClassPathEntries(). Once the correct implementation of the same is provided you would be successful in finding the module.

Hope this helps.

Thanks
Vishal

[Updated on: Tue, 21 September 2010 08:19]

Report message to a moderator

Re: Running a workflow programmatically [message #560127 is a reply to message #560095] Tue, 21 September 2010 09:46 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Sorry, it is not clear in my mind.
I just see that I had the xtext 1.0 version, so I update to 1.0.1 version. But I still have the problem,
I am not very familiar with the eclipse API.

after, I tried this :
RuntimeResourceSetInitializer r = new RuntimeResourceSetInitializer();
List<String> classPathEntries = r.getClassPathEntries();
System.out.println(classPathEntries);

the result is :
[/Users/jguidoux/localPrograms/Eclipses/Helios/eclipse/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar]

but is is a .jar so I don't know what to do with that.

jérémie
Re: Running a workflow programmatically [message #560129 is a reply to message #560095] Tue, 21 September 2010 09:47 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Sorry, it is not clear in my mind.
I just see that I had the xtext 1.0 version, so I update to 1.0.1 version. But I still have the problem,
I am not very familiar with the eclipse API.

after, I tried this :
RuntimeResourceSetInitializer r = new RuntimeResourceSetInitializer();
List<String> classPathEntries = r.getClassPathEntries();
System.out.println(classPathEntries);

the result is :
[/Users/jguidoux/localPrograms/Eclipses/Helios/eclipse/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar]

But it is a .jar so I don't know what to do with that.

jérémie
Re: Running a workflow programmatically [message #560135 is a reply to message #560129] Tue, 21 September 2010 10:01 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
sorry for the 2 same messages, it is an error ^^
Re: Running a workflow programmatically [message #560147 is a reply to message #560135] Tue, 21 September 2010 10:59 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
I try to reimplement the RuntimeResourceSetInitializer class :
public class MyRuntimeResourceSetInitializer extends
		RuntimeResourceSetInitializer {

	@Override
	public List<String> getClassPathEntries() {
		List<String> pathes = Lists.newArrayList();
		String classPath = System.getProperty("java.class.path");
		String separator = System.getProperty("path.separator");
		String[] strings = classPath.split(separator);
		for (String path : strings) {
			pathes.add(path);
		}
		return pathes;
	}
}



but I don't knwo what to write instead of
		String classPath = System.getProperty("java.class.path");


If I have well understand, I have after to make the binding for google guice.
I tried something like that :
public class MyMwe2RuntimeModule extends Mwe2RuntimeModule {
	
	@Override
	public void configure(Binder binder){
		super.configure(binder);
		
		bind(RuntimeResourceSetInitializer.class).to(MyRuntimeResourceSetInitializer.class);
	}

}


But there is no bind method. SO I think I am on the wrong way.

And after these problem are resolves I only have to do something like this after ?
Mwe2Runner runner = Guice.createInjector(new MyMwe2RuntimeModule()).getInstance(Mwe2Runner.class);
		Map<String, String> parameters = new HashMap<String, String>();
		parameters.put("modelPath", absoluteModelDir);
		parameters.put("targetDir", absoluteTargetDir);
		parameters.put("fileEncoding", this.encoding);
		runner.run(module, parameters);



Jérémie
Re: Running a workflow programmatically [message #560148 is a reply to message #560135] Tue, 21 September 2010 10:59 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
I try to reimplement the RuntimeResourceSetInitializer class :
public class MyRuntimeResourceSetInitializer extends
		RuntimeResourceSetInitializer {

	@Override
	public List<String> getClassPathEntries() {
		List<String> pathes = Lists.newArrayList();
		String classPath = System.getProperty("java.class.path");
		String separator = System.getProperty("path.separator");
		String[] strings = classPath.split(separator);
		for (String path : strings) {
			pathes.add(path);
		}
		return pathes;
	}
}



but I don't knwo what to write instead of
		String classPath = System.getProperty("java.class.path");


If I have well understand, I have after to make the binding for google guice.
I tried something like that :
public class MyMwe2RuntimeModule extends Mwe2RuntimeModule {
	
	@Override
	public void configure(Binder binder){
		super.configure(binder);
		
		bind(RuntimeResourceSetInitializer.class).to(MyRuntimeResourceSetInitializer.class);
	}

}


But there is no bind method. SO I think I am on the wrong way.

And after these problem are resolves I only have to do something like this after ?
Mwe2Runner runner = Guice.createInjector(new MyMwe2RuntimeModule()).getInstance(Mwe2Runner.class);
		Map<String, String> parameters = new HashMap<String, String>();
		parameters.put("modelPath", absoluteModelDir);
		parameters.put("targetDir", absoluteTargetDir);
		parameters.put("fileEncoding", this.encoding);
		runner.run(module, parameters);



Jérémie
Re: Running a workflow programmatically [message #560152 is a reply to message #560148] Tue, 21 September 2010 11:14 Go to previous messageGo to next message
Vishal seth is currently offline Vishal sethFriend
Messages: 32
Registered: April 2010
Member
Hi,

Have a look at the Mwe2RuntimeModule to see how to bind. As far as implementation for geClaspathentries goes, would advise you to go through source for how it works. You can find bundles & you can provide the path for the same or can directly provide the jar file.


Thanks
Vishal

Re: Running a workflow programmatically [message #560178 is a reply to message #560152] Tue, 21 September 2010 13:00 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Hi vishal;

for the Mwe2RuntimeModule, I don't have the source, but I tried this :
@Override
	public void configure(Binder binder){
		super.configure(binder);
		
		binder.bind(RuntimeResourceSetInitializer.class).to(MyRuntimeResourceSetInitializer.class);
	}

I hope it is good.
for the implementation for geClaspathentries(), I don't know what really what kind of path I have to search.
What have I to find with this method?
this is not clear for me.
I think I have to change the key "java.class.path" with something else, but I don't know what.

Thanks,

Jérémie
Re: Running a workflow programmatically [message #560186 is a reply to message #560178] Tue, 21 September 2010 13:23 Go to previous messageGo to next message
Vishal seth is currently offline Vishal sethFriend
Messages: 32
Registered: April 2010
Member
Hi,

- Binding can work this way but i had not tried. Created a custom class extending from Mwe2RuntimeModule where the binding is done. Remember to use this class while creating injector of Guice. You would definitely need to browse the source once to implement this.Not sure of the best practice though.

public Class<? extends RuntimeResourceSetInitializer> bindRuntimeResourceSetInitializer() {
return StandaloneRuntimeResourceSetInitializer.class;
}

- Regarding the classpath thing, it tries to load all the mwe2 resources from the classpath and then tries the fetch the module which is passed. The current implementation get the collection of classpath entries as string &traverse to find the mwe2 entries. Key is not an issue, the current implementation assumes that all the libraries would be in classpath. But working with tools/conatiners override this hence an issue.

You would definitely need to browse the code to make it work.

Thanks
Vishal

[Updated on: Tue, 21 September 2010 13:26]

Report message to a moderator

Re: Running a workflow programmatically [message #560200 is a reply to message #560186] Tue, 21 September 2010 14:19 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
oki, I think I get it.
I write this :
	@Override
	public List<String> getClassPathEntries() {
		List<String> pathes = Lists.newArrayList();
		Bundle bundle = Platform.getBundle("fr.irisa.cairn.graphAdapter.language.generator");
		System.out.println("bundle =  " + bundle);
		try {
			 URL fileLocation = FileLocator.toFileURL(bundle.getEntry("/"));
			 System.out.println("bundle path  =  " + fileLocation);
			 pathes.add(fileLocation.getPath());
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		
		return pathes;
	}


But after I have the same error than someone victor :
java.lang.IllegalStateException: [XtextLinkingDiagnostic: null:9 Couldn't resolve reference to JvmType 'Workflow'., XtextLinkingDiagnostic: null:12 Couldn't resolve reference to JvmFeature 'bean'., XtextLinkingDiagnostic: null:12 Couldn't resolve reference to JvmType 'StandaloneSetup'., XtextLinkingDiagnostic: null:13 Couldn't resolve reference to JvmFeature 'registerGeneratedEPackage'., XtextLinkingDiagnostic: null:14 Couldn't resolve reference to JvmFeature 'registerGeneratedEPackage'., XtextLinkingDiagnostic: null:17 Couldn't resolve reference to JvmFeature 'component'., XtextLinkingDiagnostic: null:17 Couldn't resolve reference to JvmType 'org.eclipse.xtext.mwe.UriBasedReader'., XtextLinkingDiagnostic: null:23 Couldn't resolve reference to JvmFeature 'uri'., XtextLinkingDiagnostic: null:26 Couldn't resolve reference to JvmFeature 'register'., XtextLinkingDiagnostic: null:26 Couldn't resolve reference to JvmType 'fr.irisa.cairn.graphAdapter.LanguageStandaloneSetup'., XtextLinkingDiagnostic: null:27 Couldn't resolve reference to JvmFeature 'load'., XtextLinkingDiagnostic: null:28 Couldn't resolve reference to JvmFeature 'slot'., XtextLinkingDiagnostic: null:29 Couldn't resolve reference to JvmFeature 'type'., XtextLinkingDiagnostic: null:33 Couldn't resolve reference to JvmFeature 'component'., XtextLinkingDiagnostic: null:33 Couldn't resolve reference to JvmType 'org.eclipse.xpand2.Generator'., XtextLinkingDiagnostic: null:34 Couldn't resolve reference to JvmFeature 'expand'., XtextLinkingDiagnostic: null:35 Couldn't resolve reference to JvmFeature 'outlet'., XtextLinkingDiagnostic: null:36 Couldn't resolve reference to JvmFeature 'path'., XtextLinkingDiagnostic: null:37 Couldn't resolve reference to JvmFeature 'postprocessor'., XtextLinkingDiagnostic: null:37 Couldn't resolve reference to JvmType 'org.eclipse.xpand2.output.JavaBeautifier'., XtextLinkingDiagnostic: null:47 Couldn't resolve reference to JvmFeature 'fileEncoding'.]
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:66)
	at fr.irisa.cairn.graphAdapter.language.generator.GraphAdapterGenerator.run(GraphAdapterGenerator.java:125)
	at fr.irisa.cairn.graphAdapter.language.generator.GraphAdapterGenerator.generate(GraphAdapterGenerator.java:29)
	at fr.irisa.cairn.graphAdapter.ui.GraphAdapterGeneratorHandler.execute(GraphAdapterGeneratorHandler.java:32)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
	at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:820)
	at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:806)
	at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:796)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3776)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1367)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1390)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1187)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3622)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3277)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)


I don't really understand how he resolved this other problem.
Sorry to have difficulty to fid solution.

Jérémie

Re: Running a workflow programmatically [message #560220 is a reply to message #560200] Tue, 21 September 2010 15:16 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
hmm I thought that it is because I have maybe to add manually the "org.eclipse.emf.mwe2.runtime" plugin.
So I write this :
	@Override
	public List<String> getClassPathEntries() {
		List<String> pathes = Lists.newArrayList();
		Bundle Generatorbundle = Platform.getBundle("fr.irisa.cairn.graphAdapter.language.generator");
		Bundle workFlowbundle = Platform.getBundle("org.eclipse.emf.mwe2.runtime");
		System.out.println(" generator bundle =  " + Generatorbundle);
		System.out.println(" workflow bundle =  " + workFlowbundle);
		try {
			 URL generatorPath = FileLocator.toFileURL(Generatorbundle.getEntry("/"));
			 URL workflowPath = FileLocator.toFileURL(workFlowbundle.getEntry("/"));
			 System.out.println("generator bundle path  =  " + generatorPath);
			 System.out.println("workflow bundle path  =  " + workflowPath);
			 pathes.add(generatorPath.getPath());
			 pathes.add(workflowPath.getPath());
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		
		return pathes;
	}


but it change nothing. And for the path of the workflow plugin the result is :
workflow bundle path  =  file:/Users/jguidoux/workspace_adapter/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/org.eclipse.osgi/bundles/688/1/.cp/


we can notice that
/Users/jguidoux/workspace_adapter/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/org.eclipse.osgi/bundles/688/1/.cp/

does not exist. in fact the folder org.eclipse.pde.core does not exist...

Strange...

Am I in the right way?

[Updated on: Tue, 21 September 2010 16:06]

Report message to a moderator

Re: Running a workflow programmatically [message #624494 is a reply to message #560200] Wed, 22 September 2010 05:12 Go to previous messageGo to next message
Vishal seth is currently offline Vishal sethFriend
Messages: 32
Registered: April 2010
Member
Hi,

To fix you would need to add org.eclipse.emf.mwe.core to your classpath along with its dependency graph.

Basically it tries to load the classes using various combination of import in mwe2 & if no class is found in classloader it would add it to the exception list.

Thanks
Vishal
Re: Running a workflow programmatically [message #625604 is a reply to message #624494] Wed, 22 September 2010 09:32 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Hi,

I try to add it in the manifest, but I it is not in the plugins list.
I tried to add it manually,and it manually, the manifest accept to add it manually.
So i add the org.eclipse.emf.mwe.core and org.eclipse.emf.mwe2.runtime plugins.

But I still have the same error.
This mu my manifest :
[CODE][
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: fr.irisa.cairn.graphAdapter.language.generator
Bundle-Vendor: My Company
Bundle-Version: 1.0.0
Bundle-SymbolicName: fr.irisa.cairn.graphAdapter.language.generator; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: fr.irisa.cairn.graphAdapter.language;visibility:=reexport,
org.eclipse.xpand;visibility:=reexport,
org.eclipse.xtend;visibility:=reexport,
org.eclipse.xtext;visibility:=reexport,
org.eclipse.emf.mwe2.launch;resolution:=optional,
org.eclipse.emf.mwe.core;resolution:=optional,
org.eclipse.emf.mwe2.runtime;resolution:=optional,
org.eclipse.emf.mwe.utils;visibility:=reexport,
org.eclipse.xtend.typesystem.emf;visibility:=reexport,
org.eclipse.jdt.core;bundle-version="3.6.0",
org.eclipse.text;bundle-version="3.5.0",
org.eclipse.core.resources;bundle-version="3.6.0",
org.eclipse.core.commands;bundle-version="3.6.0",
org.eclipse.emf.mwe2.language.ui;bundle-version="1.0.1",
org.eclipse.core.runtime;bundle-version="3.6.0",
org.eclipse.emf.mwe.activities;bundle-version="1.0.0",
org.eclipse.emf.mwe.ui;bundle-version="1.0.0",
org.eclipse.emf.mwe.ui.simpleEditor;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: fr.irisa.cairn.graphAdapter.language.generator
/CODE]

Jérémie

[Updated on: Wed, 22 September 2010 09:32]

Report message to a moderator

Re: Running a workflow programmatically [message #625841 is a reply to message #625604] Wed, 22 September 2010 10:33 Go to previous messageGo to next message
Vishal seth is currently offline Vishal sethFriend
Messages: 32
Registered: April 2010
Member
Hi,

Adding to mainifest might not be working as the classloader is different which would be loading the plugins. Debug/Browse source in ClasspathTypeProvider through whcih it loads the class of mwe2.

Thanks
Vishal
Re: Running a workflow programmatically [message #626132 is a reply to message #625841] Wed, 22 September 2010 11:58 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
I am sorry, but is is nor clear for me.

I tried in MyRuntimeResourceSetInitializer class to add all the dependencies plugins of the manifest, but it change nothing.
And I don't have source for the mwe2.launch, mwe2.runtimes and mwe.core projects,
So the debugger don't help me. ;s

What do I have to do with the ClasspathTypeProvider class?

Jérémie
Re: Running a workflow programmatically [message #626285 is a reply to message #626132] Wed, 22 September 2010 13:24 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Is there a way to attach source to the these plugin?
when I go the the MWE2Runner class for exemple, I have this message :
"The JAR of this class file belongs to container 'plug-in Depedencies' which does not allow modifications to source attachments in tis entries"

jeremie
Re: Running a workflow programmatically [message #626574 is a reply to message #626285] Wed, 22 September 2010 16:19 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
I try to find the bug with the debugger.
But, because I have not the sources of alle the classes, it is difficult.
I just see that in the method LazyLinkingResource.getEOgject(),
the line :
List<EObject> linkedObjects = getLinkingService().getLinkedObjects(triple.getFirst(), reference,triple.getThird());

sometimes return an empty list.
getLinkingService use a scope provider. But I don't source code of of the scopes providers methods which are invoked. so, it is don't knat append it these methods.

Can someone show me his code ?
show me what plugins I have to add? and where?

thanks,

Jérémie
Re: Running a workflow programmatically [message #627088 is a reply to message #626574] Wed, 22 September 2010 20:38 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
But I already all all the mwe plugins, in the manifest and in the getClassPathEntries() method :
@Override
	public List<String> getClassPathEntries() {
		List<String> pathes = Lists.newArrayList();
		List<Bundle> bundles = Lists.newArrayList();
		bundles.add(Platform
				.getBundle("fr.irisa.cairn.graphAdapter.language.generator"));
		bundles.add(Platform
				.getBundle("fr.irisa.cairn.graphAdapter.language"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe2.launch"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe2.runtime"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe2.language"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe2.language.ui"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe.core"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe.utils"));
		bundles.add( Platform
				.getBundle("org.eclipse.emf.mwe.activities"));
		bundles.add(Platform.getBundle("org.eclipse.emf.mwe.ui"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe.ui.simpleEditor"));
		bundles.add(Platform.getBundle("org.eclipse.xpand"));
		bundles.add(Platform.getBundle("org.eclipse.xtend"));
		bundles.add(Platform.getBundle("org.eclipse.xtext"));
		bundles.add(Platform.getBundle("org.eclipse.xtend.typesystem.emf"));
		bundles.add( Platform.getBundle("org.eclipse.jdt.core"));
		bundles.add(Platform.getBundle("org.eclipse.text"));
		bundles.add( Platform
				.getBundle("org.eclipse.core.resources"));
		bundles.add( Platform
				.getBundle("org.eclipse.core.commands"));
		bundles.add(Platform.getBundle("org.eclipse.core.runtime"));
		
		System.out.println(" bundles =  " + bundles);
		try {
			pathes = getPathes(bundles);
			System.out.println("bundlePathes =  " + pathes);
			
		} catch (IOException e) {
			throw new RuntimeException(e);
		}

		return pathes;
	}



jeremie
Re: Running a workflow programmatically [message #628665 is a reply to message #627088] Thu, 23 September 2010 15:29 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Can anyone tell me where I can find the ClasspathTypeProvider class?
Is it a class of Xtext, eclipse or mwe ?

thanks,

Jérémie
Re: Running a workflow programmatically [message #628677 is a reply to message #628665] Thu, 23 September 2010 16:12 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
the class in in the org.eclipse.xtext.common.types project

But this class in never used.

in the org.eclipse.emf.mwe2.language.scoping.getGlobalScope(..) method :
@Override
	protected IScope getGlobalScope(EObject context, EReference reference) {
		EClass referenceType = reference.getEReferenceType();
		if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_TYPE, referenceType)) {
			ResourceSet resourceSet = context.eResource().getResourceSet();
			ITypeProvider typeProvider = typeScopeProvider.getTypeProviderFactory().findTypeProvider(resourceSet);
			if (typeProvider == null)
				typeProvider = typeScopeProvider.getTypeProviderFactory().createTypeProvider(resourceSet);
			return typeScopeProvider.createTypeScope(typeProvider);
		} else {
			return super.getGlobalScope(context, reference);
		}
	}


the line
ITypeProvider typeProvider = typeScopeProvider.getTypeProviderFactory().findTypeProvider(resourceSet);
return a NullJdtTypeProvider

typeScopeProvider is an org.eclipse.xtext.common.types.xtext.ui.JdtBasedSimpleTypeSc opeProvider

The method findTypeProvider() look like that :
public ITypeProvider findTypeProvider(ResourceSet resourceSet) {
		if (resourceSet == null)
			throw new IllegalArgumentException("resourceSet may not be null.");
		return (ITypeProvider) resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().get(URIHelperConstants.PROTOCOL);
	}


URIHelperConstants.PROTOCOL = "Java"

Does these informations help someone to resolve this problem?

Thanks,

Jérémie

[Updated on: Thu, 23 September 2010 17:04]

Report message to a moderator

Re: Running a workflow programmatically [message #628691 is a reply to message #628677] Thu, 23 September 2010 17:09 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
I know why it is a NullJdtTypeProvider.

when the scope provider is created JdtTypeProviderFactory.createTypeProvider(..) method :
public IJdtTypeProvider createTypeProvider(ResourceSet resourceSet) {
		if (resourceSet == null)
			throw new IllegalArgumentException("resourceSet may not be null.");
		IJavaProject javaProject = javaProjectProvider.getJavaProject(resourceSet);
		IJdtTypeProvider result = createJdtTypeProvider(javaProject, resourceSet);
		return result;
	}


the line :
IJavaProject javaProject = javaProjectProvider.getJavaProject(resourceSet);

return null because in the method XtextResourceSetBasedProjectProvider.getJavaProject() :
ublic IJavaProject getJavaProject(ResourceSet resourceSet) {
		if (resourceSet instanceof XtextResourceSet) {
			XtextResourceSet xtextResourceSet = (XtextResourceSet) resourceSet;
			Object context = xtextResourceSet.getClasspathURIContext();
			if (context instanceof IJavaProject)
				return (IJavaProject) context;
		}
		return null;
	}

the classpathURIContext variable is null.

now, why this variable is null?


Re: Running a workflow programmatically [message #628786 is a reply to message #628691] Fri, 24 September 2010 07:22 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
There are to different implmentations of AbstractTypeProvider.
The JdtTypeProvider is only used within the IDE (or when working with a
workspace and JDT). That one needs a classpathURIContext set to the
ResourceSet, which can be done programmatically or by using

org.eclipse.xtext.ui.resource.XtextResourceSetProvider

It's not clear to me, wether you run your code in that mode. If you
don't, the implementation used should be ClasspathTypeProvider, which
doesn't rely on JDT but on a Java ClassLoader.

Sven


Am 9/23/10 7:09 PM, schrieb jeremie:
> I know why it is a NullJdtTypeProvider.
>
> when the scope provider is created
> JdtTypeProviderFactory.createTypeProvider(..) method :
>
> public IJdtTypeProvider createTypeProvider(ResourceSet resourceSet) {
> if (resourceSet == null)
> throw new IllegalArgumentException("resourceSet may not be
> null.");
> IJavaProject javaProject =
> javaProjectProvider.getJavaProject(resourceSet);
> IJdtTypeProvider result = createJdtTypeProvider(javaProject,
> resourceSet);
> return result;
> }
>
>
> the line :
> IJavaProject javaProject = javaProjectProvider.getJavaProject(resourceSet);
> return null because in the method
> XtextResourceSetBasedProjectProvider.getJavaProject() :
>
> ublic IJavaProject getJavaProject(ResourceSet resourceSet) {
> if (resourceSet instanceof XtextResourceSet) {
> XtextResourceSet xtextResourceSet = (XtextResourceSet)
> resourceSet;
> Object context = xtextResourceSet.getClasspathURIContext();
> if (context instanceof IJavaProject)
> return (IJavaProject) context;
> }
> return null;
> }
>
> the classpathURIContext variable is null.
>
> now, why this variable is null?
>
>
>


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: Running a workflow programmatically [message #628818 is a reply to message #628786] Fri, 24 September 2010 09:44 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Thanks svan for your answer.

I don't know why it is the JdtTypeProvider which is used instead of ClasspathTypeProvider.

The only thing I write are :
	Mwe2Runner runner = Guice.createInjector(new MyMwe2RuntimeModule()).getInstance(Mwe2Runner.class);

//		Mwe2Runner runner = injector.getInstance(Mwe2Runner.class);
		Map<String, String> parameters = new HashMap<String, String>();
		parameters.put("modelPath", absoluteModelDir);
		parameters.put("targetDir", absoluteTargetDir);
		parameters.put("fileEncoding", this.encoding);
		runner.run(module, parameters);


in MyMwe2RuntimeModule() I just said to to guice to use MyRuntimeResourceSetInitializer instead of RuntimeResourceSetInitializer.

MyRuntimeResourceSetInitializer look like that.
ublic class MyRuntimeResourceSetInitializer extends
		RuntimeResourceSetInitializer {

	@Override
	public List<String> getClassPathEntries() {
		List<String> pathes = super.getClassPathEntries();
		List<Bundle> bundles = Lists.newArrayList();
		
		bundles.add(Platform.getBundle("com.ibm.icu"));
		bundles.add( Platform.getBundle("com.google.inject"));
		bundles.add( Platform.getBundle("com.google.collect"));
		
		bundles.add(Platform
				.getBundle("fr.irisa.cairn.graphAdapter.language.generator"));
		bundles.add(Platform
				.getBundle("fr.irisa.cairn.graphAdapter.language"));
		
		bundles.add(Platform.getBundle("org.apache.ant"));
		bundles.add(Platform.getBundle("org.apache.commons.cli"));
		bundles.add( Platform.getBundle("org.antlr.runtime"));
		bundles.add( Platform
				.getBundle("org.eclipse.core.commands"));
		bundles.add(Platform.getBundle("org.eclipse.core.jobs"));
		bundles.add( Platform
				.getBundle("org.eclipse.core.resources"));
		bundles.add(Platform.getBundle("org.eclipse.core.runtime"));
		
		bundles.add(Platform.getBundle("org.eclipse.equinox.app"));
		bundles.add(Platform.getBundle("org.eclipse.equinox.preferences"));
		bundles.add(Platform.getBundle("org.eclipse.equinox.registry"));
		bundles.add(Platform.getBundle("org.eclipse.equinox.common"));
		
		bundles.add(Platform.getBundle("org.eclipse.emf.common"));
		bundles.add(Platform.getBundle("org.eclipse.emf.ecore"));
		bundles.add(Platform.getBundle("org.eclipse.emf.ecore.xmi"));
		
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe.core"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe.utils"));
		bundles.add( Platform
				.getBundle("org.eclipse.emf.mwe.activities"));
		bundles.add(Platform.getBundle("org.eclipse.emf.mwe.ui"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe.ui.simpleEditor"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe2.launch"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe2.runtime"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe2.language"));
		bundles.add(Platform
				.getBundle("org.eclipse.emf.mwe2.language.ui"));
		
		bundles.add( Platform.getBundle("org.eclipse.jdt.core"));
		bundles.add( Platform.getBundle("org.eclipse.jdt.compiler.apt"));
		bundles.add( Platform.getBundle("org.eclipse.jdt.compiler.tool"));
		bundles.add(Platform.getBundle("org.eclipse.osgi"));
		bundles.add(Platform.getBundle("org.eclipse.text"));
		
		bundles.add(Platform.getBundle("org.eclipse.xpand"));
		bundles.add(Platform.getBundle("org.eclipse.xtend"));
		bundles.add(Platform.getBundle("org.eclipse.xtend.typesystem.emf"));
		bundles.add(Platform.getBundle("org.eclipse.xtext"));
		bundles.add(Platform.getBundle("org.eclipse.xtext.util"));
		bundles.add(Platform.getBundle("org.eclipse.xtext.xbase"));
		bundles.add(Platform.getBundle("org.eclipse.xtext.common.types"));
		
//		bundles.add(Platform.getBundle("runtime_registry_compatibility"));
		
		System.out.println(" bundles =  " + bundles);
		try {
			pathes = getPathes(bundles);
			System.out.println("bundlePathes =  " + pathes);
			
		} catch (IOException e) {
			throw new RuntimeException(e);
		}

		return pathes;
	}

	private List<String> getPathes(List<Bundle> bundles) throws IOException {
		List<String> pathes = Lists.newArrayList();
		for (Bundle bundle : bundles) {
			pathes.add(FileLocator.toFileURL(bundle.getEntry("/")).getPath());
		}
		return pathes;
	}


As you can see, to be sure that I don't forgot a plugin, I write all the plugins that my generator project use.

I will try to describe you what appends in my program :

I can see that in MWERunnner.run method, when this mathid called
EcoreUtil.resolveAll(module);

when this method try to reslove the cross reference whith the method FeatureIteratorImpl<T>.hasNext(). this method try to find the next obhect whith the line :
 Object value = eObject.eGet(feature, resolve());

when the abject is a jvm type, he had to reslove the proxy with the method :
EcoreUtil.resolve(...);

to resolve this late the scope provider is called :
final IScope scope = getScope(context, ref);


At this point :
the scope provider is a Mwe2ScopeProvider
and his delegateScope is a NamespaceAwareScopeProvider.
the delegateScopeProvider ihas a typeScopeProvider attribute which is a JdtBasedSimpleTypeScopeProvider.

I think the it should not be a JdtBasedSimpleTypeScopeProvider but maybe something like ClasspathTypeScopeProvider. because it is the delegateScope which is used.


Maybe the problem is before, in the MweRunner.findModule() method.
I hope all these informations can help you to understand my programm.


regards,

Jeremie
Re: Running a workflow programmatically [message #628844 is a reply to message #628818] Fri, 24 September 2010 12:09 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
You are running into this issue :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=318721

Sven


Am 9/24/10 11:44 AM, schrieb jeremie:
> Thanks svan for your answer.
>
> I don't know why it is the JdtTypeProvider which is used instead of
> ClasspathTypeProvider.
>
> The only thing I write are :
> Mwe2Runner runner = Guice.createInjector(new
> MyMwe2RuntimeModule()).getInstance(Mwe2Runner.class);
>
> // Mwe2Runner runner = injector.getInstance(Mwe2Runner.class);
> Map<String, String> parameters = new HashMap<String, String>();
> parameters.put("modelPath", absoluteModelDir);
> parameters.put("targetDir", absoluteTargetDir);
> parameters.put("fileEncoding", this.encoding);
> runner.run(module, parameters);
>
>
> in MyMwe2RuntimeModule() I just said to to guice to use
> MyRuntimeResourceSetInitializer instead of RuntimeResourceSetInitializer.
>
> MyRuntimeResourceSetInitializer look like that.
>
> ublic class MyRuntimeResourceSetInitializer extends
> RuntimeResourceSetInitializer {
>
> @Override
> public List<String> getClassPathEntries() {
> List<String> pathes = super.getClassPathEntries();
> List<Bundle> bundles = Lists.newArrayList();
>
> bundles.add(Platform.getBundle("com.ibm.icu"));
> bundles.add( Platform.getBundle("com.google.inject"));
> bundles.add( Platform.getBundle("com.google.collect"));
>
> bundles.add(Platform
>
> .getBundle("fr.irisa.cairn.graphAdapter.language.generator"));
> bundles.add(Platform
> .getBundle("fr.irisa.cairn.graphAdapter.language"));
>
> bundles.add(Platform.getBundle("org.apache.ant"));
> bundles.add(Platform.getBundle("org.apache.commons.cli"));
> bundles.add( Platform.getBundle("org.antlr.runtime"));
> bundles.add( Platform
> .getBundle("org.eclipse.core.commands"));
> bundles.add(Platform.getBundle("org.eclipse.core.jobs"));
> bundles.add( Platform
> .getBundle("org.eclipse.core.resources"));
> bundles.add(Platform.getBundle("org.eclipse.core.runtime"));
>
> bundles.add(Platform.getBundle("org.eclipse.equinox.app"));
> bundles.add(Platform.getBundle("org.eclipse.equinox.preferences "));
> bundles.add(Platform.getBundle("org.eclipse.equinox.registry "));
> bundles.add(Platform.getBundle("org.eclipse.equinox.common"));
>
> bundles.add(Platform.getBundle("org.eclipse.emf.common"));
> bundles.add(Platform.getBundle("org.eclipse.emf.ecore"));
> bundles.add(Platform.getBundle("org.eclipse.emf.ecore.xmi"));
>
> bundles.add(Platform
> .getBundle("org.eclipse.emf.mwe.core"));
> bundles.add(Platform
> .getBundle("org.eclipse.emf.mwe.utils"));
> bundles.add( Platform
> .getBundle("org.eclipse.emf.mwe.activities"));
> bundles.add(Platform.getBundle("org.eclipse.emf.mwe.ui"));
> bundles.add(Platform
> .getBundle("org.eclipse.emf.mwe.ui.simpleEditor"));
> bundles.add(Platform
> .getBundle("org.eclipse.emf.mwe2.launch"));
> bundles.add(Platform
> .getBundle("org.eclipse.emf.mwe2.runtime"));
> bundles.add(Platform
> .getBundle("org.eclipse.emf.mwe2.language"));
> bundles.add(Platform
> .getBundle("org.eclipse.emf.mwe2.language.ui"));
>
> bundles.add( Platform.getBundle("org.eclipse.jdt.core"));
> bundles.add( Platform.getBundle("org.eclipse.jdt.compiler.apt"));
> bundles.add( Platform.getBundle("org.eclipse.jdt.compiler.tool"));
> bundles.add(Platform.getBundle("org.eclipse.osgi"));
> bundles.add(Platform.getBundle("org.eclipse.text"));
>
> bundles.add(Platform.getBundle("org.eclipse.xpand"));
> bundles.add(Platform.getBundle("org.eclipse.xtend"));
>
> bundles.add(Platform.getBundle("org.eclipse.xtend.typesystem.emf "));
> bundles.add(Platform.getBundle("org.eclipse.xtext"));
> bundles.add(Platform.getBundle("org.eclipse.xtext.util"));
> bundles.add(Platform.getBundle("org.eclipse.xtext.xbase"));
> bundles.add(Platform.getBundle("org.eclipse.xtext.common.types "));
>
> //
> bundles.add(Platform.getBundle("runtime_registry_compatibility "));
>
> System.out.println(" bundles = " + bundles);
> try {
> pathes = getPathes(bundles);
> System.out.println("bundlePathes = " + pathes);
>
> } catch (IOException e) {
> throw new RuntimeException(e);
> }
>
> return pathes;
> }
>
> private List<String> getPathes(List<Bundle> bundles) throws
> IOException {
> List<String> pathes = Lists.newArrayList();
> for (Bundle bundle : bundles) {
>
> pathes.add(FileLocator.toFileURL(bundle.getEntry("/")).getPath());
> }
> return pathes;
> }
>
>
> As you can see, to be sure that I don't forgot a plugin, I write all the
> plugins that my generator project use.
>
> I will try to describe you what appends in my program :
>
> I can see that in MWERunnner.run method, when this mathid called
> EcoreUtil.resolveAll(module);
>
> when this method try to reslove the cross reference whith the method
> FeatureIteratorImpl<T>.hasNext(). this method try to find the next
> obhect whith the line :
> Object value = eObject.eGet(feature, resolve());
> when the abject is a jvm type, he had to reslove the proxy with the
> method :
> EcoreUtil.resolve(...);
> to resolve this late the scope provider is called :
>
> final IScope scope = getScope(context, ref);
>
>
> At this point :
> the scope provider is a Mwe2ScopeProvider
> and his delegateScope is a NamespaceAwareScopeProvider.
> the delegateScopeProvider ihas a typeScopeProvider attribute which is a
> JdtBasedSimpleTypeScopeProvider.
>
> I think the it should not be a JdtBasedSimpleTypeScopeProvider but maybe
> something like ClasspathTypeScopeProvider. because it is the
> delegateScope which is used.
>
>
> Maybe the problem is before, in the MweRunner.findModule() method.
> I hope all these informations can help you to understand my programm.
>
> regards,
>
> Jeremie


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: Running a workflow programmatically [message #628851 is a reply to message #628844] Fri, 24 September 2010 12:47 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
thanks sven.

Yeah it looks to be my problem.

So I create a class MyXtextResourceSet extends XtextResourceSet.

in class MyMwe2RuntimeModule extends Mwe2RuntimeModule I add this :
@Override
		public Class<? extends XtextResourceSet> bindXtextResourceSet() {
			// TODO Auto-generated method stub
			return MyXtextResourceSet.class;
		}



but in MyXtextResourceSet, I don't really know how to shadow the ResourceFactory.Registry and IResourceServiceProvider.Registry ans with what.

regards,

Jérémie
Re: Running a workflow programmatically [message #628876 is a reply to message #628851] Fri, 24 September 2010 14:47 Go to previous messageGo to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
I have noticed one thing in the NamespaceAwareScopeProvider class :
@Inject
	private AbstractTypeScopeProvider typeScopeProvider;

	@Override
	protected IScope getGlobalScope(EObject context, EReference reference) {
		EClass referenceType = reference.getEReferenceType();
		if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_TYPE, referenceType)) {
			ResourceSet resourceSet = context.eResource().getResourceSet();
			ITypeProvider typeProvider = typeScopeProvider.getTypeProviderFactory().findTypeProvider(resourceSet);
			if (typeProvider == null)
				typeProvider = typeScopeProvider.getTypeProviderFactory().createTypeProvider(resourceSet);
			return typeScopeProvider.createTypeScope(typeProvider);
		} else {
			return super.getGlobalScope(context, reference);
		}
	}


here google juice inject a JdtBasedSimpleTypeScopeProvider to the variable typeScopeProvider.
So Maybe I just have to change the binding in a module. But I don"t know in what modul et replace with what.

Jérémie
Re: Running a workflow programmatically [message #629174 is a reply to message #628876] Mon, 27 September 2010 12:27 Go to previous message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Hello, I maybe found one thing.

in the class org.eclipse.emf.mwe2.language.ui.AbstractMwe2UiModule there are these methods :
// contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment
	public Class<? extends org.eclipse.xtext.common.types.access.ITypeProvider.Factory> bindITypeProvider$Factory() {
		return org.eclipse.xtext.common.types.access.jdt.JdtTypeProviderFactory.class;
	}

	// contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment
	public Class<? extends org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider> bindAbstractTypeScopeProvider() {
		return org.eclipse.xtext.common.types.xtext.ui.JdtBasedSimpleTypeScopeProvider.class;
	}

	// contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment
	public Class<? extends org.eclipse.xtext.common.types.xtext.ui.ITypesProposalProvider> bindITypesProposalProvider() {
		return org.eclipse.xtext.common.types.xtext.ui.JdtTypesProposalProvider.class;
	}


I thought that maybe I add to @Override these methods/
So in my ui plugin I create a class MyMwe2UiModule extends Mwe2UiModule which look like that :
public class MyMwe2UiModule extends Mwe2UiModule {

	public MyMwe2UiModule(AbstractUIPlugin plugin) {
		super(plugin);
		// TODO Auto-generated constructor stub
	}
	
	// contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment
	@Override
	public Class<? extends org.eclipse.xtext.common.types.access.ITypeProvider.Factory> bindITypeProvider$Factory() {
		return ClasspathTypeProviderFactory.class;
	}
	
	// contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment
	@Override
	public Class<? extends org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider> bindAbstractTypeScopeProvider() {
		return ClasspathBasedTypeScopeProvider.class;
//		return org.eclipse.xtext.common.types.xtext.ui.JdtBasedSimpleTypeScopeProvider.class;
	}

}


But I don't know where to use this module...

Thanks,

Jérémie
Previous Topic:[Announce] new eTrice project proposal: an implementation of the ROOM modeling language
Next Topic:[Announce] Demonstrations at ESE's Modeling Symposium
Goto Forum:
  


Current Time: Tue Sep 24 18:04:14 GMT 2024

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

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

Back to the top