How to invoke a JET transform [message #657797] |
Fri, 04 March 2011 01:46  |
Eclipse User |
|
|
|
Hi all....I am struggling with a complex 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
|
|
|
Re: How to invoke a JET transform [message #657892 is a reply to message #657797] |
Fri, 04 March 2011 09:19  |
Eclipse User |
|
|
|
JET offers a number of APIs to help you. Since you mention it, runTransformOnResource will load an IResource (file, folder, or even Project) from the workspace, and pass it to your JET transformation - this is essentially what happens when you run a JET transform from the launching UI.
But, for a wizard, I'm guessing that you have not saved your model to disk (and you are not interested in doing so). There are two other variants of runTransform that may help:
runTransformOnString takes your model as a string, parses it, and passes that to your transform. The typical example would be a an XML document. The JET new project wizard does this.
runTransformOnObject takes an already loaded model, and passes it to your JET transformation. What you pass will depend on what kind of model you have. If you have an EMF-based model, pass an EMF Resource (whose contents is your actual model). If you have an XML document, pass the Document object.
You can see how JET itself uses runTransformOnString here:
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.m2t/or g.eclipse.jet/plugins/org.eclipse.jet.ui/src/org/eclipse/jet /ui/newproject/NewProjectWizard.java?view=markup&revisio n=1.11&root=Modeling_Project
(method starts on line 75)
This JET FAQ article may be useful, too:
http://wiki.eclipse.org/JET_FAQ_How_do_I_run_a_JET_transform ation_from_Java%3F
Paul
|
|
|
Powered by
FUDForum. Page generated in 0.02847 seconds