|
Re: EMF and JET generating a new package. [message #423395 is a reply to message #423393] |
Mon, 29 September 2008 20:09 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
Marc,
Comments below.
Marc Gendron wrote:
> Hi all,
>
> I am currently experimenting with Jet and EMF. I want to generate another
> package and other files with ecore and genmodel files. There is an example
> of what I am trying to do :
>
You've looked at the Generator Extension example? You can create the
example project (File->New->Example...) your workspace if you have the
EMF SDK installed.
> ///////////////////////////////////
> ca.home.impl
> HomeFactoryImpl.java
> HomeImpl.java
> HomePackageImpl.java
> ca.home.util
> HomeAdapterFactory.java
> HomeSwitch.java
> ca.home.proxy //this is the new package
> HomeProxy.java //This is the new file
> Home.java
> HomeFactory.java
> HomePackage.java
> ///////////////////////////////////
>
> I can create a Proxy.javajet. I don't how exactly I can do this.
>
>
> I tryed to create an Action that is place in the context menu of The
> genmodel Editor. This is the code :
> ///////////////////////////////////
> GenModel genModel = null;
> GenClass gc = null;
>
> if (s instanceof StructuredSelection)
> {
> StructuredSelection selection = (StructuredSelection)s;
> Iterator<?> iterator = selection.iterator();
> while (iterator.hasNext()) {
> Object obj = iterator.next();
> if (obj instanceof GenModel)
> genModel = (GenModel) obj;
> else if (obj instanceof GenClass)
> gc = (GenClass) obj;
> }
> }
> if (genModel == null && gc==null)
> return;
>
> if (gc==null)
> gc = genModel.createGenClass();
>
>
> String uri ="platform:/plugin/mypluggin/templates/model/Proxy.javajet";
> JETEmitter emitter = new JETEmitter( uri,getClass().getClassLoader() );
>
>
> Object[] arg = {gc};
>
> String result = "";
> try {
> result = emitter.generate( new NullProgressMonitor(), arg );
> } catch (JETException e) {
> e.printStackTrace();
> }
> System.out.println(result);
> ///////////////////////////////////
>
> But It doesn't display anything because it Doesn't like the import in the
> first line of Proxy.javajet. For now, the first line of Proxy.javajet is the
> same as Class.javajet.
>
>
> This is the Proxy.javajet :
> //////////////////////////////////
> <%@ jet package="org.eclipse.emf.codegen.ecore.templates.model"
> imports="java.util.* org.eclipse.emf.codegen.ecore.genmodel.*" class="Class"
> version="$Id: Class.javajet,v 1.75 2008/05/20 14:39:35 emerks Exp $" %>
>
> Hello world.
> //////////////////////////////////
>
> Why if I remove the "org.eclipse.emf.codegen.ecore.genmodel.*" it print
> "Hello world."? In my run configuration, I selected the
> "org.eclipse.emf.codegen.ecore" plugin.
>
> What is the best solution to create my Proxy package?
>
>
> Thanks in adavance,
>
> Marc
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.01522 seconds