Home » Modeling » TMF (Xtext) » Running a workflow programmatically
| | |
Re: Running a workflow programmatically [message #542380 is a reply to message #542323] |
Thu, 24 June 2010 16:20 |
Victor Noël 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 |
Victor Noël 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 |
Sebastian Zarnekow 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 #542921 is a reply to message #542912] |
Sun, 27 June 2010 14:23 |
Victor Noël 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 #560095 is a reply to message #559977] |
Tue, 21 September 2010 08:19 |
Vishal seth 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 #560186 is a reply to message #560178] |
Tue, 21 September 2010 13:23 |
Vishal seth 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 |
jeremie 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 |
jeremie 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 #625604 is a reply to message #624494] |
Wed, 22 September 2010 09:32 |
jeremie 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 #628677 is a reply to message #628665] |
Thu, 23 September 2010 16:12 |
jeremie 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 #628818 is a reply to message #628786] |
Fri, 24 September 2010 09:44 |
jeremie 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 :
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 |
Sven Efftinge 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
|
|
| | | |
Goto Forum:
Current Time: Thu Sep 26 11:11:59 GMT 2024
Powered by FUDForum. Page generated in 0.06603 seconds
|