Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Problem loading ecore model as input in JET
Problem loading ecore model as input in JET [message #47434] Mon, 30 June 2008 22:11 Go to next message
Eclipse UserFriend
Originally posted by: uneebtariq.gmail.com

Hey Hi
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
extension(myecore.?)
2. Plz can someone give me a simple example of loading ecore in JET and
transforming it into code.

waiting for ur response

Thanks
Uneeb Janjua
Re: Problem loading ecore model as input in JET [message #47465 is a reply to message #47434] Wed, 02 July 2008 14:49 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Uneeb Janjua:

> 1. How to load ecore model as an input? What should be the
> extension(myecore.?)

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
something like:

<extension point="org.eclipse.emf.ecore.extension_parser">
<parser
type="theExtension"
class="...some fully qualified Java class name"/>
</extension>

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:

<somePrefix:YourRootType
xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:somePrefix="Your-meta-model-NS-URI"
xsi:schemaLocation="Your-meta-model-NS-URI
platform:/resource/ws-relative-path-to-your-.ecore-file"
...>


> 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:
Host: dev.eclipse.org
Repository Path: /cvsroot/modeling.
User: anonymous
No Password
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:
Name: test.wizardPage
Source folder: src
Ensure 'This plug-in will make contributions to the UI' is checked (second
page).
2) In the Package Explorer, expand org.eclipse.jet.examples.ec2008
3) Right click test.wizardpage.xml, and click Run As > Input for JET
Transformation
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
practices:
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.

Paul
Previous Topic:Generating OCL from Model
Next Topic:Xpand Ganymede Roadmap
Goto Forum:
  


Current Time: Tue Apr 23 10:44:39 GMT 2024

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

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

Back to the top