|Problem loading ecore model as input in JET [message #47434]
||Mon, 30 June 2008 18:11
Originally posted by: uneebtariq.gmail.com|
I am working with mark on this project and have neva Used JET before. I
am having a couple of problems using JET.
1. How to load ecore model as an input? What should be the
2. Plz can someone give me a simple example of loading ecore in JET and
transforming it into code.
waiting for ur response
|Re: Problem loading ecore model as input in JET [message #47465 is a reply to message #47434]
||Wed, 02 July 2008 10:49
| Paul Elder
Registered: July 2009
> 1. How to load ecore model as an input? What should be the
By "ecore model", I am assuming you mean a model defined with EMF/Ecore, and
not a file with a .ecore extension (the meta-model).
In that case, the extension that JET recognizes the model by is found in the
plug-in containing the generated Java model code. Look at plugin.xml for
class="...some fully qualified Java class name"/>
JET should be able to load (and understand) files with the extension defined
in the plugin.xml
If the plug-in defining this is a project in the same workspace as your JET
transformation, JET will not find the registration. (JET relies on EMF for
this information, and EMF gets it from loaded plug-ins only.) The fix for
this (assuming that you are using the default EMF XMI serialization) is to
add an xsi:schemaLocation attribute to your model:
> 2. Plz can someone give me a simple example of loading ecore in JET and
> transforming it into code.
Here is a link to the SWT-wizard page generator used in the EcilpseCon 2008
tutorial on JET:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2t/org .eclipse.jet/examples/org.eclipse.jet.ec2008.pushbuttonbuild /?root=Modeling_Project
To check it out from the Eclipse CVS repository, do the following:
1) switch to the CVS Repository Exploring perspective.
2) Add a connection as follows:
Repository Path: /cvsroot/modeling.
Connection type: pserver
3) In CVS Repositories view, expand to:
HEAD / org.eclipse.m2t / org.eclipse.jet / examples
4) Right click org.eclipse.jet.ec2008.swtgen.codebehind and click Check Out
5) Right click org.eclipse.jet.examples.ec2008 and click Check Out.
6) Switch to the Java perspective.
To run the transformation on some test input, do the following:
1) Create a new plug-in project:
Source folder: src
Ensure 'This plug-in will make contributions to the UI' is checked (second
2) In the Package Explorer, expand org.eclipse.jet.examples.ec2008
3) Right click test.wizardpage.xml, and click Run As > Input for JET
4) In the dialog that appears, select SWT Gen (codeBehind)
(test.wizardpage.xml) and click OK.
The structure of the transformation pretty much follows what I feel are best
1) The template main.jet (the entry point) traverses the input twice. In the
first pass, it calculates values and stores them as 'annotations' on the
input model (they appear as if they are attributes, although they are never
stored). In the second pass, JET templates are executed using tags such as
ws:project, ws:folder, ws:file and java:class
2) main.jet also does some fancy things via c:load. This is probably not
'normal', but the idea is to make the transformation more data-driven (the
transformation is generating code for SWT widgets, and separating the bits
of widget specific code from the rest of the transformation is desirable.
3) the transformation uses JMerge (java:merge) and the Java import manager
(via java:import and java:importsLocation), demonstrating some ways to
manage the production of Java code. (Note that the java:merge and
java:importsLocation tags interact slightly, and the transformation
incorrectly places java:merge first - it is much better to place the
java:merge tag after java:importsLocation - for maximum safety, place it at
the end of the template).
Hope this helps.
Powered by FUDForum
. Page generated in 0.01656 seconds