Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Opening instance of .ecore in GMF diagram
Opening instance of .ecore in GMF diagram [message #668429] Thu, 05 May 2011 12:27 Go to next message
David Mising name is currently offline David Mising name
Messages: 9
Registered: December 2010
Location: Aachen
Junior Member

Hey everyone,

I got into a little trouble trying to programmatically open an instance of my ecore model in a gmf-diagram. The instance I would like to display is in a Resource and I try to open it in a rcp application.

I have already tried this:
MyDiagramEditorUtil.openDiagram(myResource);


but this causes this error:
	java.lang.NullPointerException
	at org.eclipse.core.runtime.Path.<init>(Path.java:153)
	at my.diagram.part.MyDiagramEditorUtil.openDiagram(MyDiagramEditorUtil.java:82)


DiagramEditorUtil seems like a good starting point for my approach, e.g. using the runWizard() method worked fine, but I do not want to use this wizard. Or am I totally wrong at this point?

Hope someone could help. Thanks upfront

Best regards,
David
Re: Opening instance of .ecore in GMF diagram [message #669442 is a reply to message #668429] Tue, 10 May 2011 07:12 Go to previous message
Adrian Civil is currently offline Adrian Civil
Messages: 10
Registered: January 2011
Junior Member
URI newURI = URI.createURI("file:/C:/xyz");
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
   page.openEditor(new URIEditorInput(newURI), XYZ.diagram.part.XYZDiagramEditor.ID);
} catch (PartInitException e) {
   e.printStackTrace();
}

Or get the URI from the resource that you have. Not sure if this is the correct way to do it, but you could give it a try...
Previous Topic:Create automatically an edge between two nodes
Next Topic:set Default Color of figures
Goto Forum:
  


Current Time: Sat Aug 23 11:39:24 EDT 2014

Powered by FUDForum. Page generated in 0.08968 seconds