Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [JET] relating GMF to JET
icon9.gif  [JET] relating GMF to JET [message #496464] Tue, 10 November 2009 08:43 Go to next message
Samira  is currently offline Samira Friend
Messages: 10
Registered: November 2009
Junior Member
Hi every one,

I'm new to eclipse development and i have a problem ..

task:
i need to call JET transformation from an editor plugin created by GMF

my status:
- I've created the GMF plugin & its working
- I've created a jet project using the same .ecore & .xmi generated by the editor, and its working !


the problem:
i need to relate the plugin with the jet project!
as i've manually entered the .ecore & .xmi as an input.
but the jet is not actually related to the plugin
also i don't know how to the jet project as a plugin!


HELP!!

[Updated on: Tue, 10 November 2009 08:58]

Report message to a moderator

Re: [JET] relating GMF to JET [message #496557 is a reply to message #496464] Tue, 10 November 2009 14:22 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Samira:

Take a look at:

JET2Platform.runTransformOnResource

and

JET2Platform.runTransformOnObject

Use the first, if you want the JET transformation to execute against an workspace resource.

Use the second if you have an EMF Resource already loaded, and want to run the JET transform against that (without it necessarily being saved). In this case, you would pass the EMF Resource argument. Be aware that this second form does not set any of the predefined JET variables:

http://help.eclipse.org/galileo/topic/org.eclipse.jet.doc/re ferences/xpath/predefinedVariables.xhtml

Lastly, neither method provides any UI. Errors are reported by the IStatus returned. If you want progress or status reporting, you'll have to do that in your own code. As an example of showing progress, take a look at the JET new project wizard:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2t/org .eclipse.jet/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ ui/newproject/NewProjectWizard.java?revision=1.11&root=M odeling_Project&view=markup

Paul
Re: [JET] relating GMF to JET [message #496567 is a reply to message #496557] Tue, 10 November 2009 15:09 Go to previous messageGo to next message
Samira  is currently offline Samira Friend
Messages: 10
Registered: November 2009
Junior Member
Dear Paul,

i don't know where to use the "runTransformOnResource"

here's what i've done
I've created the jet project & the GMF project on the same workspace, and i've created a button in the GMF editor to call the JET project using the code in this FAQ
and for loading the JET template i used the JET API to load the JET transformation plug-in; writing this code

try {
    // use templates from 'my.jet' project
    JET2TemplateManager.run(new String[] {"my.jet"}, new JET2TemplateManager.ITemplateOperation() {
        public void run(ITemplateRunner templateRunner) {
            // Run the template 'templates/myStuf.jet'
            templateRunner.generate("templates/myStuff.jet", context, out);
        }
    });
} catch (BundleException e) {
    // handle failure to load plugin 'my.jet'", e);
}

do i still need to use "runTransformOnResource" ?

excuse my questions as i've ben using JET for only 2 days,
and eclipse development since only 2 weeks
Embarrassed Embarrassed Embarrassed
Re: [JET] relating GMF to JET [message #496629 is a reply to message #496567] Tue, 10 November 2009 17:37 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
I'll preface this reply with the following warning: I am not a GMF expert.

From your button handler, you need to get your editor instance (probably a subclass of FileDiagramEditor.

From there you have a choice:
a) figure out the EMF Resource representing the model you want to pass to JET
b) figure out the IFile containing your input model

For a), call editor.getEditingDomain().getResourceSet().getResources(). You will have more than one resource in the list - one for your diagram and one for your model. You'll have to figure out which is which. Once you have, pass the one for your model to runTransformOnObject.

For b), I'd recommend basically the same path. But when you find the right Resource, call Resource.getURI().toPlatformString, and then use ResourcesPlugin.getDefault.getWorkspace().getRoot().findMemb er() on that string. Pass the returned IResource to runTransformOnResource.

Not that with approach b), you should save your editor (by calling doSave()) so that any pending changes are visible to the JET transform.

Paul
Re: [JET] relating GMF to JET [message #498115 is a reply to message #496629] Sat, 14 November 2009 16:15 Go to previous messageGo to next message
Samira  is currently offline Samira Friend
Messages: 10
Registered: November 2009
Junior Member
Dear Paul,

i tried what u said..

here's what i wrote:
	Resource resource = activeEditor.getEditingDomain().getResourceSet().getResources().get(0);
		IResource iResource = ResourcesPlugin.getWorkspace().getRoot().findMember(resource.getURI().toPlatformString(true));
		IStatus status = JET2Platform.runTransformOnObject("m2t.editor.trial1", iResource, null,new NullProgressMonitor());
		System.out.println(status.toString());


here's what i got
Status ERROR: org.eclipse.jet code=0 Errors occurred during execution null children=[Status ERROR: org.eclipse.jet code=0 org.eclipse.core.internal.resources.ResourceException: Resource '/simple.statemachine.trial1.editor' does not exist. org.eclipse.jet.taglib.JET2TagException: org.eclipse.core.internal.resources.ResourceException: Resource '/simple.statemachine.trial1.editor' does not exist. children=[Status ERROR: org.eclipse.jet code=0 Resource '/simple.statemachine.trial1.editor' does not exist. null]]


note that "m2t.editor.trial" is the jet project
& the "simple.statemachine.trial1.editor" is the gmf editor containing the button

what should i do ??? Confused Confused Confused

[Updated on: Sat, 14 November 2009 16:16]

Report message to a moderator

Re: [JET] relating GMF to JET [message #498121 is a reply to message #498115] Sat, 14 November 2009 17:43 Go to previous messageGo to next message
Samira  is currently offline Samira Friend
Messages: 10
Registered: November 2009
Junior Member
while debugging , i guess i found a problem..

inside the method
JET2Platform.processResults(final String id, final ContextLogEntry contextLog)

the line:
    String projectName = bundleManager.getProjectForId(id);
returns a null string!

i don't know why knowing that i'm sure i typed the id right "m2t.editor.trial1" as the name of the jet project

[Updated on: Sat, 14 November 2009 17:43]

Report message to a moderator

Re: [JET] relating GMF to JET [message #498125 is a reply to message #498121] Sat, 14 November 2009 18:25 Go to previous messageGo to next message
Samira  is currently offline Samira Friend
Messages: 10
Registered: November 2009
Junior Member
although..

when i debugged, every thing seemed working well!

i mean it code read the main.jet template & the dumb.jet template also

[Updated on: Sat, 14 November 2009 18:57]

Report message to a moderator

Re: [JET] relating GMF to JET [message #498160 is a reply to message #498125] Sun, 15 November 2009 08:54 Go to previous messageGo to next message
Samira  is currently offline Samira Friend
Messages: 10
Registered: November 2009
Junior Member
now every thing is working well, thank you Very Happy
Re: [JET] relating GMF to JET [message #656764 is a reply to message #498160] Mon, 28 February 2011 13:55 Go to previous message
Priyanshu  is currently offline Priyanshu Friend
Messages: 2
Registered: February 2011
Junior Member
hey samira...I am struggling with the same situation.I have created a project that contains wizards and from those wizards I am fetching user input and I have put the values in a model.Now I want to create some files when I click the finish button in the wizard. For that I have created a JET.I want to invoke the JET inside the performFinish method of the wizard Page.I have used the runResourceOnTransform method but can u plz tell me how to pass the input model, I mean the xml file dynamically. see when I press the finish button the JET has to be invoked, so that the relevant files are generated. I have maintained two text boxes "project name" and "package name" in the wizard page. the problem that I am facing is i am unable to populate the xml file with the project name and package name, which I have to feed to the JET transformation upon clicking the finish button. Plz help me out

[Updated on: Mon, 28 February 2011 14:09]

Report message to a moderator

Previous Topic:[Acceleo] Outsource Computation to Java
Next Topic:[Acceleo] Dynamic model support appears broken
Goto Forum:
  


Current Time: Thu Apr 18 00:25:58 GMT 2024

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

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

Back to the top