Home » Modeling » MDT (Model Development Tools) » transform EMF Object withJET2 (transform EMF Object withJET2 )
transform EMF Object withJET2 [message #533684] |
Sat, 15 May 2010 09:57  |
Eclipse User |
|
|
|
Hello every body.
I need your help.
I Have an EMF object that i want to transform with JET2 to get some xml files ( i take the emf object and print some attribute in my xml files+predefined text).
So my problem is the following.
1/ I created the JET project + templates. i enabled this project to receive an EMF object rather then xml document.
2/ I have my EMF object But i don't know witch project can allow me to call this method
JET2Platform.runTransformOnObject
and how can i load my object in this projecT.
i read that JET2 project must be exported to jar and then be inclued in a plugin-in project. i did IT right now and i have juste one class Activator.
The class JET2Platform is not recognized into this project.
Thank you
|
|
| |
Re: transform EMF Object withJET2 [message #533933 is a reply to message #533913] |
Mon, 17 May 2010 10:07   |
Eclipse User |
|
|
|
Mohammed:
Some questions:
1) Are you able to run the JET transformation against your EMF model
using the Run > Run Configurations dialog?
2) Once you can do #1, you can then consider using API to do the same
thing. Start by deciding HOW you want the user to invoke the
transformation.
a) Assuming your user will trigger the transformation manually, the user
will typically start by clicking a menu item, toolbar button, etc.... In
that case, you need to create a UI plug-in that defines the UI item, and
the handler (Java code) for that item. The handler will then call
JET2Platform.runTransformOnXXX()... The new plug-in wizard provides
templates for UI contributions, which makes it much easier to get started.
b) Once you have created the UI plug-in, you will need to test it by
creating a run time workbench (select Run > Run Configurations, then
create a new Eclipse Application, and click Run).
c) Once you have tested, you are ready to package your UI plug-in plus
the JET project/plug-in for distribution to others. You need to create a
Feature project for that.
Almost all of the above steps in #2 have more to do with extending
Eclipse by creating plug-ins. The eclipse.platform.* groups may be a
better source of information.
As for actually using JET2Platform.runTransformOnXXX(), here are a
couple of more questions:
3) How is the EMF object created? Are you also creating some sort of
editor?
a) If so, then the object is stored as a file in the Eclipse workspace.
That is, it is a workspace resource. You can find and manipulate
resources by adding a dependency on the org.eclipse.core.resources
plug-in, and the start exploring the APIs found in
ResourcesPlugin.getWorkspace().getRoot(). Once you find the IFile
containing your saved model, you can pass it to
JET2Platform.runTransformOnResource.
b) If you have an editor for your EMF objects, and you want to invoke
the transform against the content of the editor, they you have to find
the EMF Resource object (eObject.eResource() should work), and pass that
to JET via JET2Platform.runTransformOnObject().
Paul
On 2010-05-17 9:19 AM, Kenn Hussey wrote:
> Mohammed,
>
> This is a question for the M2T [JET] newsgroup, copied.
>
> Kenn
>
> Mohammed Jelti wrote:
>> Hello every body.
>> I need your help.
>>
>> I Have an EMF object that i want to transform with JET2 to get some
>> xml files ( i take the emf object and print some attribute in my xml
>> files+predefined text).
>>
>> So my problem is the following.
>> 1/ I created the JET project + templates. i enabled this project to
>> receive an EMF object rather then xml document.
>> 2/ I have my EMF object But i don't know witch project can allow me to
>> call this method
>>
>> JET2Platform.runTransformOnObject
>>
>> and how can i load my object in this projecT.
>>
>> i read that JET2 project must be exported to jar and then be inclued
>> in a plugin-in project. i did IT right now and i have juste one class
>> Activator.
>> The class JET2Platform is not recognized into this project.
>>
>>
>> Thank you
>>
>>
|
|
|
Re: transform EMF Object withJET2 [message #544933 is a reply to message #533933] |
Tue, 06 July 2010 03:04  |
Eclipse User |
|
|
|
Dear Paul,
thank you for your help.
honestly, i'm doing my intership for my master and i received this project todo.
The company gave me the whole files that i will need to do the transformation. i mean the main file who extends EObject and all dependencies. They just want a plugin project for the transoformation. That all that i have to do.
My plugin project that i'm trying to start is not working right now because the exception is not explicit, i can't do anything.
that is the code that i'm trying to execute as a Java application :
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "tranformationClient";
private static ProfileSpecObject profile;
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
profile = new MyProfile();
final JET2Context ctx = new JET2Context(profile);
final IStatus status = JET2Platform.runTransform("xxx.eprGenerator.esb", ctx, new MyMonitor());
}
MyProfile is a class that extends the real Object given by the company.
the exception appears when running
JET2Platform.runTransformOnObject.
Can you tell me if this 3 lines are good enough to run the transformation.?
Exception in thread "main" java.lang.ExceptionInInitializerError
at tranformationclient.Activator.<init>(Activator.java:56)
at tranformationclient.Test.main(Test.java:6)
Caused by: java.lang.NullPointerException
at org.eclipse.jet.JET2Platform.<clinit>(JET2Platform.java:77)
... 2 more
Before doing this, i created a JET2 project (xxx.eprGenerator.esb) that i had put (as a jar file) in the dependances of this plugin.
|
|
|
Re: transform EMF Object withJET2 [message #604967 is a reply to message #533684] |
Mon, 17 May 2010 09:19  |
Eclipse User |
|
|
|
Mohammed,
This is a question for the M2T [JET] newsgroup, copied.
Kenn
Mohammed Jelti wrote:
> Hello every body.
> I need your help.
>
> I Have an EMF object that i want to transform with JET2 to get some xml
> files ( i take the emf object and print some attribute in my xml
> files+predefined text).
>
> So my problem is the following.
> 1/ I created the JET project + templates. i enabled this project to
> receive an EMF object rather then xml document.
> 2/ I have my EMF object But i don't know witch project can allow me to
> call this method
>
> JET2Platform.runTransformOnObject
>
> and how can i load my object in this projecT.
>
> i read that JET2 project must be exported to jar and then be inclued in
> a plugin-in project. i did IT right now and i have juste one class
> Activator.
> The class JET2Platform is not recognized into this project.
>
>
> Thank you
>
>
|
|
|
Re: transform EMF Object withJET2 [message #604971 is a reply to message #533913] |
Mon, 17 May 2010 10:07  |
Eclipse User |
|
|
|
Mohammed:
Some questions:
1) Are you able to run the JET transformation against your EMF model
using the Run > Run Configurations dialog?
2) Once you can do #1, you can then consider using API to do the same
thing. Start by deciding HOW you want the user to invoke the
transformation.
a) Assuming your user will trigger the transformation manually, the user
will typically start by clicking a menu item, toolbar button, etc.... In
that case, you need to create a UI plug-in that defines the UI item, and
the handler (Java code) for that item. The handler will then call
JET2Platform.runTransformOnXXX()... The new plug-in wizard provides
templates for UI contributions, which makes it much easier to get started.
b) Once you have created the UI plug-in, you will need to test it by
creating a run time workbench (select Run > Run Configurations, then
create a new Eclipse Application, and click Run).
c) Once you have tested, you are ready to package your UI plug-in plus
the JET project/plug-in for distribution to others. You need to create a
Feature project for that.
Almost all of the above steps in #2 have more to do with extending
Eclipse by creating plug-ins. The eclipse.platform.* groups may be a
better source of information.
As for actually using JET2Platform.runTransformOnXXX(), here are a
couple of more questions:
3) How is the EMF object created? Are you also creating some sort of
editor?
a) If so, then the object is stored as a file in the Eclipse workspace.
That is, it is a workspace resource. You can find and manipulate
resources by adding a dependency on the org.eclipse.core.resources
plug-in, and the start exploring the APIs found in
ResourcesPlugin.getWorkspace().getRoot(). Once you find the IFile
containing your saved model, you can pass it to
JET2Platform.runTransformOnResource.
b) If you have an editor for your EMF objects, and you want to invoke
the transform against the content of the editor, they you have to find
the EMF Resource object (eObject.eResource() should work), and pass that
to JET via JET2Platform.runTransformOnObject().
Paul
On 2010-05-17 9:19 AM, Kenn Hussey wrote:
> Mohammed,
>
> This is a question for the M2T [JET] newsgroup, copied.
>
> Kenn
>
> Mohammed Jelti wrote:
>> Hello every body.
>> I need your help.
>>
>> I Have an EMF object that i want to transform with JET2 to get some
>> xml files ( i take the emf object and print some attribute in my xml
>> files+predefined text).
>>
>> So my problem is the following.
>> 1/ I created the JET project + templates. i enabled this project to
>> receive an EMF object rather then xml document.
>> 2/ I have my EMF object But i don't know witch project can allow me to
>> call this method
>>
>> JET2Platform.runTransformOnObject
>>
>> and how can i load my object in this projecT.
>>
>> i read that JET2 project must be exported to jar and then be inclued
>> in a plugin-in project. i did IT right now and i have juste one class
>> Activator.
>> The class JET2Platform is not recognized into this project.
>>
>>
>> Thank you
>>
>>
|
|
|
Re: transform EMF Object withJET2 [message #604999 is a reply to message #533933] |
Tue, 06 July 2010 03:04  |
Eclipse User |
|
|
|
Dear Paul,
thank you for your help.
honestly, i'm doing my intership for my master and i received this project todo.
The company gave me the whole files that i will need to do the transformation. i mean the main file who extends EObject and all dependencies. They just want a plugin project for the transoformation. That all that i have to do.
My plugin project that i'm trying to start is not working right now because the exception is not explicit, i can't do anything.
that is the code that i'm trying to execute as a Java application :
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "tranformationClient";
private static ProfileSpecObject profile;
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
profile = new MyProfile();
final JET2Context ctx = new JET2Context(profile);
final IStatus status = JET2Platform.runTransform("xxx.eprGenerator.esb", ctx, new MyMonitor());
}
MyProfile is a class that extends the real Object given by the company.
the exception appears when running
JET2Platform.runTransformOnObject.
Can you tell me if this 3 lines are good enough to run the transformation.?
Exception in thread "main" java.lang.ExceptionInInitializerError
at tranformationclient.Activator.<init>(Activator.java:56)
at tranformationclient.Test.main(Test.java:6)
Caused by: java.lang.NullPointerException
at org.eclipse.jet.JET2Platform.<clinit>(JET2Platform.java:77)
... 2 more
Before doing this, i created a JET2 project (xxx.eprGenerator.esb) that i had put (as a jar file) in the dependances of this plugin.
|
|
|
Goto Forum:
Current Time: Wed Mar 19 03:18:39 EDT 2025
Powered by FUDForum. Page generated in 0.05151 seconds
|