Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » generate code from .gmfgen
generate code from .gmfgen [message #232027] Tue, 02 June 2009 09:53 Go to next message
Eclipse UserFriend
Hi,

As Achilleas a few months ago :

"I have an .ecore model from which I am able to automatically
(programmatically) create the .genmodel and generate the java code for the
model,edit,editor projects. This is performed by running an ant script
that makes use of the EcoreGeneratorTask to generate the .genmodel and the
java code. Not by using the Eclipse EMF capabilities, e.g. right click on
genmodel and choose "Generate Model Code". Using this automatic task I can
generate the code and run an instance of the EMF tree-based editor to
define my models.

Now I want to do the same for the diagram GMF-based editor. I have the
gmfmap model and I don't want to right-click on it and choose "Create
generator model" and the right click on .gmfgen to choose "Generate
diagram code"; via the eclipse GMF capabilities. What I want is to
automate this task programmatically or via an ant script as in the first
case.

And yes I have read most of the tutorials. I hope my clarification is
precise so that anyone can provide me with some guidelines how to start
doing that?"

For me I only want to generate code from the .gmfgen (doesn't want to
generate it).

At the end of the thread :
http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg16579.html

So is it possible now? What is the outcome of that? Any suggestions?

(The thread is archived so I don't find how to respond to it... is there
possible to uprise a thread?)
Re: generate code from .gmfgen [message #235251 is a reply to message #232027] Fri, 03 July 2009 09:56 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Returning to this issue after a lot of months of other related work I am
trying to use the TransformToGenModelOperation and
TransformToGenModelWizard as advised by Alex.

I am getting the following exception:

org.eclipse.core.runtime.CoreException: Errors while loading Mapping model
at
org.eclipse.gmf.internal.bridge.transform.TransformToGenMode lOperation.loadMappingModel(TransformToGenModelOperation.jav a:164)
at
bt.com.ccm.generation.plugin.actions.GenerateDiagram.<init>(GenerateDiagram.java:85)
at
bt.com.ccm.generation.plugin.actions.GenerateAction.run(Gene rateAction.java:91)
at
org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:251)
at
org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPl uginAction.java:229)
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:583)
at
org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:500)
at
org.eclipse.jface.action.ActionContributionItem$6.handleEven t(ActionContributionItem.java:452)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:382)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Caused by: java.lang.NullPointerException
at
org.eclipse.gmf.internal.bridge.transform.TransformToGenMode lOperation.loadMappingModel(TransformToGenModelOperation.jav a:149)
... 32 more

Which occurs at the following code - specifically at the statement String
msg = Messages.Tra.......

if (!(root instanceof Mapping)) {
String msg =
MessageFormat.format(Messages.TransformToGenModelOperation_e _wrong_root_element,
root.getClass().getName());
status = Plugin.createError(msg, null);
throw new CoreException(status);
}

I don't seem to understand what is the problem and why the loading of the
gmfmap file fails. I have validated the gmfmap file I am using and it is
just fine. The code I have implemented is the following:

@SuppressWarnings("restriction")
public GenerateDiagram(){


resourceSet = new ResourceSetImpl();

Resource genmodel = new ResourceImpl();
genmodel =
resourceSet.createResource(URI.createPlatformResourceURI("/bt.com.ccm.generation.plugin/model/product.genmodel ",
true));
System.out.println("print genmodel: "+genmodel.toString());

Resource gmfgraph = new ResourceImpl();
gmfgraph =
resourceSet.createResource(URI.createPlatformResourceURI("/bt.com.ccm.generation.plugin/model/product.gmfgraph ",
true));
System.out.println("print gmfgraph: "+gmfgraph.toString());

Resource gmftool = new ResourceImpl();
gmftool =
resourceSet.createResource(URI.createPlatformResourceURI("/bt.com.ccm.generation.plugin/model/product.gmftool ",
true));
System.out.println("print gmftool: "+gmftool.toString());

Resource gmfmap = new ResourceImpl();
gmfmap =
resourceSet.createResource(URI.createPlatformResourceURI("/bt.com.ccm.generation.plugin/model/product.gmfmap ",
true));
System.out.println("print gmfmap: "+gmfmap.toString());

resourceSet.getResources().add(genmodel);
resourceSet.getResources().add(gmfgraph);
resourceSet.getResources().add(gmftool);
resourceSet.getResources().add(gmfmap);

TransformToGenModelOperation tgmfgen = new
TransformToGenModelOperation(resourceSet);


try {
NullProgressMonitor np = new NullProgressMonitor();

tgmfgen.loadMappingModel(gmfmap.getURI(),np);
tgmfgen.loadGenModel(genmodel.getURI(), np);

GenModel genmmodel = tgmfgen.findGenmodel();

IFile target = (IFile)new File("product.gmfgen");
tgmfgen.setGenURI(URI.createPlatformResourceURI(target.getFu llPath().toString(),
true));


} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

//IProgressMonitor monitor =
//
(IProgressMonitor)getProject().getReferences().get(AntCorePl ugin.ECLIPSE_PROGRESS_MONITOR);

NullProgressMonitor np = new NullProgressMonitor();
System.out.println("created IProgressMOnitor: ");
tgmfgen.setGenURI(URI.createPlatformResourceURI("/bt.com.ccm.generation.plugin/model/product.gmfgen ",
true));
tgmfgen.executeTransformation(np);
}

Any ideas?

Thanks,

Achilleas
Re: generate code from .gmfgen [message #235350 is a reply to message #235251] Mon, 06 July 2009 05:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aurelien.pupier.esial.net

Hi,

great to hear news about this subject.
Perhaps you can inspire from the opened bug : https://bugs.eclipse.org/bugs/show_bug.cgi?id=282331

(and vote for it)

Achilleas a écrit :
> Hi,
>
> Returning to this issue after a lot of months of other related work I am
> trying to use the TransformToGenModelOperation and
> TransformToGenModelWizard as advised by Alex.
>
> I am getting the following exception:
>
> org.eclipse.core.runtime.CoreException: Errors while loading Mapping model
> at
> org.eclipse.gmf.internal.bridge.transform.TransformToGenMode lOperation.loadMappingModel(TransformToGenModelOperation.jav a:164)
>
> at
> bt.com.ccm.generation.plugin.actions.GenerateDiagram.<init>(GenerateDiagram.java:85)
>
> at
> bt.com.ccm.generation.plugin.actions.GenerateAction.run(Gene rateAction.java:91)
>
> at
> org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:251)
> at
> org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPl uginAction.java:229)
>
> at
> org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:583)
>
> at
> org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:500)
>
> at
> org.eclipse.jface.action.ActionContributionItem$6.handleEven t(ActionContributionItem.java:452)
>
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:382)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
> Caused by: java.lang.NullPointerException
> at
> org.eclipse.gmf.internal.bridge.transform.TransformToGenMode lOperation.loadMappingModel(TransformToGenModelOperation.jav a:149)
>
> ... 32 more
>
> Which occurs at the following code - specifically at the statement
> String msg = Messages.Tra.......
>
> if (!(root instanceof Mapping)) {
> String msg =
> MessageFormat.format(Messages.TransformToGenModelOperation_e _wrong_root_element,
> root.getClass().getName());
> status = Plugin.createError(msg, null);
> throw new CoreException(status);
> }
>
> I don't seem to understand what is the problem and why the loading of
> the gmfmap file fails. I have validated the gmfmap file I am using and
> it is just fine. The code I have implemented is the following:
>
> @SuppressWarnings("restriction")
> public GenerateDiagram(){
>
>
> resourceSet = new ResourceSetImpl();
>
> Resource genmodel = new ResourceImpl();
> genmodel =
> resourceSet.createResource(URI.createPlatformResourceURI("/bt.com.ccm.generation.plugin/model/product.genmodel ",
> true)); System.out.println("print genmodel: "+genmodel.toString());
>
> Resource gmfgraph = new ResourceImpl();
> gmfgraph =
> resourceSet.createResource(URI.createPlatformResourceURI("/bt.com.ccm.generation.plugin/model/product.gmfgraph ",
> true)); System.out.println("print gmfgraph: "+gmfgraph.toString());
>
> Resource gmftool = new ResourceImpl();
> gmftool =
> resourceSet.createResource(URI.createPlatformResourceURI("/bt.com.ccm.generation.plugin/model/product.gmftool ",
> true)); System.out.println("print gmftool: "+gmftool.toString());
>
> Resource gmfmap = new ResourceImpl();
> gmfmap =
> resourceSet.createResource(URI.createPlatformResourceURI("/bt.com.ccm.generation.plugin/model/product.gmfmap ",
> true)); System.out.println("print gmfmap: "+gmfmap.toString());
>
> resourceSet.getResources().add(genmodel);
> resourceSet.getResources().add(gmfgraph);
> resourceSet.getResources().add(gmftool);
> resourceSet.getResources().add(gmfmap);
>
> TransformToGenModelOperation tgmfgen = new
> TransformToGenModelOperation(resourceSet);
>
>
> try {
> NullProgressMonitor np = new NullProgressMonitor();
>
> tgmfgen.loadMappingModel(gmfmap.getURI(),np);
> tgmfgen.loadGenModel(genmodel.getURI(), np);
>
> GenModel genmmodel = tgmfgen.findGenmodel();
>
> IFile target = (IFile)new File("product.gmfgen");
>
> tgmfgen.setGenURI(URI.createPlatformResourceURI(target.getFu llPath().toString(),
> true));
>
>
> } catch (CoreException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> //IProgressMonitor monitor = //
> (IProgressMonitor)getProject().getReferences().get(AntCorePl ugin.ECLIPSE_PROGRESS_MONITOR);
>
>
> NullProgressMonitor np = new NullProgressMonitor();
> System.out.println("created IProgressMOnitor: ");
>
> tgmfgen.setGenURI(URI.createPlatformResourceURI("/bt.com.ccm.generation.plugin/model/product.gmfgen ",
> true));
> tgmfgen.executeTransformation(np);
> }
>
> Any ideas?
>
> Thanks,
>
> Achilleas
>
Re: generate code from .gmfgen [message #235755 is a reply to message #235350] Thu, 09 July 2009 07:03 Go to previous messageGo to next message
Eclipse UserFriend
Hi again,

Does anyone has any idea why I get this exception when I am loading the
mapping model?

org.eclipse.core.runtime.CoreException: Errors while loading Mapping model
at
org.eclipse.gmf.internal.bridge.transform.TransformToGenMode lOperation.loadMappingModel(TransformToGenModelOperation.jav a:164)
at
bt.com.ccm.generation.plugin.actions.GenerateDiagram.<init>(GenerateDiagram.java:90)
at
bt.com.ccm.generation.plugin.actions.GenerateAction.run(Gene rateAction.java:87)
at
org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:251)
at
org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPl uginAction.java:229)
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:583)
at
org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:500)
at
org.eclipse.jface.action.ActionContributionItem$6.handleEven t(ActionContributionItem.java:452)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:382)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Caused by: java.lang.NullPointerException
at
org.eclipse.gmf.internal.bridge.transform.TransformToGenMode lOperation.loadMappingModel(TransformToGenModelOperation.jav a:149)
... 32 more

The exception is generated from the following code line in the
TransformToGenModelOperation class:

String msg =
MessageFormat.format(Messages.TransformToGenModelOperation_e _wrong_root_element,
root.getClass().getName());

Thanks,

Achilleas
Re: generate code from .gmfgen [message #235795 is a reply to message #235755] Thu, 09 July 2009 09:08 Go to previous messageGo to next message
Eclipse UserFriend
Anyone knows how to use the TransformToGenModelOperation class for
creating the gmfgen model?

I don't seem to be able to find out what is the process? Any ideas since I
am kind of lost here?

Thanks,


Achilleas
Re: generate code from .gmfgen [message #235848 is a reply to message #235795] Thu, 09 July 2009 12:04 Go to previous messageGo to next message
Eclipse UserFriend
I have managed to create the gmfgen from the gmfmap eventually after some
struggle. Is there anyone who has a tip of how to start to generate the
diagram code from the gmfgen?

Thanks,

Achilleas
Re: generate code from .gmfgen [message #236202 is a reply to message #235848] Wed, 15 July 2009 06:50 Go to previous message
Eclipse UserFriend
Hi Achilleas,
You said that had managed to create the .gmfgen from the .gmfmap.
Please, could you post how did you do it? Because I have the same problem.
Tanhks!

Achilleas wrote:
>
> I have managed to create the gmfgen from the gmfmap eventually after
> some struggle. Is there anyone who has a tip of how to start to generate
> the diagram code from the gmfgen?
>
> Thanks,
>
> Achilleas
>
Previous Topic:Confirm delete shape
Next Topic:Drag&Drop into Diagram issue
Goto Forum:
  


Current Time: Wed Jul 23 22:34:18 EDT 2025

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

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

Back to the top