Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Using business objects with GMF, newbie question
Using business objects with GMF, newbie question [message #184022] Wed, 23 April 2008 10:26 Go to next message
Phil is currently offline PhilFriend
Messages: 3
Registered: July 2009
Junior Member
I am experimenting with the GMF framework (I am now into week 2 of playing with it).

I wish to use it in a way that is slightly different to standard:

I have business objects that already exist and cannot be modified.
These objects are saved in an xml file with a defined xsd (different to the format used by GMF)
I wish to load, display, edit and save these objects.

I am now quite confident using the GMF tools, and have made an diagram editor which works. I can save the model in the correct xml format, but unfortunately I am having problems loading the diagram initially.

My current approach is to override the document provider and replace the line

Diagram diagram = DiagramIOUtil.load( domain, storage, true, getProgressMonitor() );

with my own code.

Diagram diagram = myLoader();

private Diagram myLoader() {
SimpleEmfGraph simpleGraph = ModelFactoryImpl.eINSTANCE.createSimpleEmfGraph();
SimpleEmfNode node1 = ModelFactoryImpl.eINSTANCE.createSimpleEmfNode();
SimpleEmfNode node2 = ModelFactoryImpl.eINSTANCE.createSimpleEmfNode();
SimpleEmfEdge edge = ModelFactoryImpl.eINSTANCE.createSimpleEmfEdge();
edge.setInNode( node1 );
edge.setOutNode( node2 );

simpleGraph.getEdges().add( edge );
simpleGraph.getNodes().add( node1 );
simpleGraph.getNodes().add( node2 );

final Diagram diagram = makeEmptyDiagram();
diagram.setElement( simpleGraph );
return diagram;
}

private Diagram makeEmptyDiagram() {
SimpleEmfGraph model = ModelFactoryImpl.eINSTANCE.createSimpleEmfGraph();
return ViewService.createDiagram( model, SimpleEmfGraphEditPart.MODEL_ID, SimpleEmfGraphDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT );
}

Sadly this approach doesn't work. I get

java.lang.NullPointerException
at org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.getIdStr( ViewUtil.java:642)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.getWo rkspaceViewerPreferenceStore(DiagramEditor.java:1271)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.confi gureGraphicalViewer(DiagramEditor.java:827)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:793)
at org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1548)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:310)
at org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
at org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
at org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:426)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:592)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:29 9)
at org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:179)
at org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:268)
at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:400)
at org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 04)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
at org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
at org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:774)
at org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:673)
at org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:634)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2737)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2651)
at org.eclipse.ui.internal.WorkbenchPage.access$13(WorkbenchPag e.java:2643)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2595)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2590)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2574)
at org.eclipse.ui.actions.OpenWithMenu.openEditor(OpenWithMenu. java:340)
at org.eclipse.ui.actions.OpenWithMenu.access$0(OpenWithMenu.ja va:328)
at org.eclipse.ui.actions.OpenWithMenu$3.handleEvent(OpenWithMe nu.java:226)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3293)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 19)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)

Clearly I haven't set something up: but I don't know what it is.

I would appreciate some advice on the approach I am taking, and if it is the correct one, what am I not setting up?

Thanks for the help


--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-
Re: Using business objects with GMF, newbie question [message #184074 is a reply to message #184022] Wed, 23 April 2008 14:59 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Phil,

I'm suggesting you to first create (generate) a diagram editor plugin working
properly with your domain model. Then once you get it working and applicable
for your use cases you can start thinking about migration of old diagrams.
This is not so simple process but still should be doable.

-----------------
Alex Shatalin
Re: Using business objects with GMF, newbie question [message #184088 is a reply to message #184074] Wed, 23 April 2008 18:21 Go to previous messageGo to next message
Phil is currently offline PhilFriend
Messages: 3
Registered: July 2009
Junior Member
Thank you for your response Alex.

I have in fact built (generated) the editor and it meets my use cases.
Sadly I am unable to populate it with the initial data.

I gave the code I was using in the first post, and I wonder if I am on the
correct track, or if there is a better way of doing this

Phil
Re: Using business objects with GMF, newbie question [message #184121 is a reply to message #184088] Thu, 24 April 2008 09:36 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Phil,

If you are going to save only domain model information then it should be
enough to just initialize new diagrams using old model files (popup menu
in package explorer on model file).

If you have to preserve all visual information then I suggest you to take
a look on generated ???CanonicalEditPolicies - these classes are responsible
for creation visual elements for corresponding domain model elements on diagram
openning.

-----------------
Alex Shatalin
Previous Topic:Problems with the stack
Next Topic:Access to the values of the property sheet
Goto Forum:
  


Current Time: Wed Apr 24 15:21:16 GMT 2024

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

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

Back to the top