[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: generate code from .gmfgen

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.TransformToGenModelOperation.loadMappingModel(TransformToGenModelOperation.java:164)


at bt.com.ccm.generation.plugin.actions.GenerateDiagram.<init>(GenerateDiagram.java:85)

at bt.com.ccm.generation.plugin.actions.GenerateAction.run(GenerateAction.java:91)

at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)


at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583)

at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500)

at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(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.java:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
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(Workbench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)


at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.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(EclipseStarter.java:382)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.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.TransformToGenModelOperation.loadMappingModel(TransformToGenModelOperation.java: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.getFullPath().toString(), true));


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


//IProgressMonitor monitor = // (IProgressMonitor)getProject().getReferences().get(AntCorePlugin.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