Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to run a MWE2 from a RCP
How to run a MWE2 from a RCP [message #766782] Fri, 16 December 2011 07:28 Go to next message
Soenke Brightside is currently offline Soenke Brightside
Messages: 39
Registered: January 2011
Member
Hi,

i try to run the MWE2 but it doesn't work. I guess the mwe2runner cant find the module?

Error:
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)


Runner:
Mwe2Runner mweRunner = new Mwe2Runner();
mweRunner.run("foo.bar.GraphMLGenerator", properties);


MWE2 Module Name:
module foo.bar.GraphMLGenerator


All files are in the same package.

Sönke

[Updated on: Fri, 16 December 2011 07:30]

Report message to a moderator

Re: How to run a MWE2 from a RCP [message #766836 is a reply to message #766782] Fri, 16 December 2011 09:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4426
Registered: July 2009
Senior Member
Hi,

it might be that you are affected by https://bugs.eclipse.org/bugs/show_bug.cgi?id=318721
(MWE2 doesnt like OSGi) so you may switch back to mwe(1)

~Christian
Re: How to run a MWE2 from a RCP [message #766861 is a reply to message #766836] Fri, 16 December 2011 10:07 Go to previous messageGo to next message
Soenke Brightside is currently offline Soenke Brightside
Messages: 39
Registered: January 2011
Member
Is there no workaround for that? I realy don't know how to transform my mwe2 to a mwe workflow.
Re: How to run a MWE2 from a RCP [message #766869 is a reply to message #766861] Fri, 16 December 2011 10:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4426
Registered: July 2009
Senior Member
Hi,

no i do not know a workaround. if you do not use any fancy mwe features translation is nearly 1:1

~Christian
Re: How to run a MWE2 from a RCP [message #766875 is a reply to message #766869] Fri, 16 December 2011 10:31 Go to previous messageGo to next message
Soenke Brightside is currently offline Soenke Brightside
Messages: 39
Registered: January 2011
Member
My mwe2 is very simle. Just like the given example. I don't now how to translate the Reader and the Generator.

Sönke

var targetDir = "src-gen"
var filePath = "model"
var fileName = "Car.premise"

Workflow {

	bean = StandaloneSetup {
		registerGeneratedEPackage = "premise.PremisePackage"
	}

	component = DirectoryCleaner {
		directory = targetDir
	}

	component = GraphMLGeneratorSupport {}

	component = org.eclipse.xtext.mwe.Reader {
		path = filePath
		validate = NullValidator {}
		
		register = GraphMLGeneratorSetup {}
		loadResource = {
			slot = filePath
			uri = ".*${fileName}"		
		}
	}
	
	component = org.eclipse.xtext.generator.GeneratorComponent {
		register = GraphMLGeneratorSetup {}
		slot = "model"
		outlet = {
			path = targetDir
		}
	}
}

[Updated on: Fri, 16 December 2011 10:34]

Report message to a moderator

Re: How to run a MWE2 from a RCP [message #766884 is a reply to message #766875] Fri, 16 December 2011 10:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4426
Registered: July 2009
Senior Member
hi,

this should be straight forward

<workflow>

<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup">
<registerGeneratedEPackage value= "premise.PremisePackage" />
</bean>

<component class="...">
</component>

....


</workflow>


see mwe doku for more information
Re: How to run a MWE2 from a RCP [message #766885 is a reply to message #766884] Fri, 16 December 2011 10:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4426
Registered: July 2009
Senior Member
btw have a look a http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/
this might be what you actually want to do

~Christian
Re: How to run a MWE2 from a RCP [message #768046 is a reply to message #766885] Mon, 19 December 2011 08:37 Go to previous messageGo to next message
Soenke Brightside is currently offline Soenke Brightside
Messages: 39
Registered: January 2011
Member
Thank you Christian,
this looks like the solution.

But sadly:
"final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();"
throws me a NullPointerException.

Sönke
Re: How to run a MWE2 from a RCP [message #768047 is a reply to message #768046] Mon, 19 December 2011 08:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4426
Registered: July 2009
Senior Member
Hi,

are you sure you use guice to instantiate you handler / action .....

 <handler
class="org.xtext.example.mydsl.ui.MyDslExecutableExtensionFactory:org.xtext.example.mydsl.ui.handler.GenerationHandler"
 commandId="org.xtext.example.mydsl.ui.handler.GenerationCommand">


the important thing not to miss is org.xtext.example.mydsl.ui.MyDslExecutableExtensionFactory:

and did not mit the @inject?

~Christian

[Updated on: Mon, 19 December 2011 08:42]

Report message to a moderator

Re: How to run a MWE2 from a RCP [message #768065 is a reply to message #768047] Mon, 19 December 2011 09:08 Go to previous messageGo to next message
Soenke Brightside is currently offline Soenke Brightside
Messages: 39
Registered: January 2011
Member
Christian Dietrich wrote on Mon, 19 December 2011 08:41
Hi,

are you sure you use guice to instantiate you handler / action .....

That seems to be the problem ;o) I'm quite new to xtext/xtend und guice. I will search for some docs. Thanks.

Sönke
Re: How to run a MWE2 from a RCP [message #768603 is a reply to message #768065] Tue, 20 December 2011 07:56 Go to previous messageGo to next message
Soenke Brightside is currently offline Soenke Brightside
Messages: 39
Registered: January 2011
Member
Okay, know i tryed to play a bit with guice.

At the moment i become this error:
1) No implementation for org.eclipse.core.resources.IWorkspaceRoot was bound.
  while locating org.eclipse.core.resources.IWorkspaceRoot
    for field at org.eclipse.xtext.builder.EclipseResourceFileSystemAccess.root(EclipseResourceFileSystemAccess.java:42)
  while locating com.google.inject.Provider<org.eclipse.xtext.builder.EclipseResourceFileSystemAccess>
    for field at de.dlr.ft.exchange.graphml.xtend.ui.handler.GenerationHandler.fileAccessProvider(GenerationHandler.java:27)
  while locating de.dlr.ft.exchange.graphml.xtend.ui.handler.GenerationHandler


So i tryed to bind the WorkspaceRoot.class in the module:
    public Class<? extends IWorkspaceRoot> bindIWorkspaceRoot() {
        return ResourcesPlugin.getWorkspace().getRoot().getClass();
    }


But it doens work:
1) Could not find a suitable constructor in org.eclipse.core.internal.resources.WorkspaceRoot. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
  at org.eclipse.core.internal.resources.WorkspaceRoot.class(WorkspaceRoot.java:30)
  at org.eclipse.xtext.service.MethodBasedModule.configure(MethodBasedModule.java:55)

Any hints?

Sönke
Re: How to run a MWE2 from a RCP [message #768604 is a reply to message #768603] Tue, 20 December 2011 07:59 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 4426
Registered: July 2009
Senior Member
Hi,

i do not understand why you do need to do this stuff.
if you pack everthing to your ui project it should work wout of the box.
never the less. copy and paste is your friend.

public org.eclipse.core.resources.IWorkspaceRoot bindIWorkspaceRootToInstance() {
return org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot();
}

~Christian

[Updated on: Tue, 20 December 2011 07:59]

Report message to a moderator

Previous Topic:Validation not happening on file open
Next Topic:Defining a Boolean Literal in 2.x
Goto Forum:
  


Current Time: Sat May 25 23:17:45 EDT 2013

Powered by FUDForum. Page generated in 0.01978 seconds