Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Creating diagram without XML Resource
Creating diagram without XML Resource [message #164768] Fri, 07 December 2007 15:42
Eclipse UserFriend
Originally posted by: martin.tomaga.gmx.net

Hi all

I am having question about how to load and create diagrams from object model. As a datastore I would like to use DB, not XML files. I would like to load data from DB, then create domain objects and
then from this objets create diagram. I am havimg problem with the last step: creating diagram from domain objects. I am trying to overwrite method setDocumentContent in the class
ProcessDesignerDocumentProvider with code:

protected void setDocumentContent(IDocument document, IEditorInput element) throws CoreException {
ProcessDiagram processDiagram = ObjectFactory.eINSTANCE.createProcessDiagram();

Diagram diagram = ViewService.createDiagram(processDiagram, ProcessDiagramEditPart.MODEL_ID, ProcessDesignerDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT) ;

diagram.setName("myNew.object_diagram");
diagram.setElement(processDiagram);

document.setContent(diagram);

// setting other objects
}

But I always get exception

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)
...

Problem is in the class ViewUtil in the line

String id = ((XMLResource) view.eResource()).getID(view);

where method view.eResource() always returns null. Moreover, if method view.eResource() will return not null value, the next operation is casting to XMLResourse. But my input is not XML file.

I found a few words about how to load diagrams on GMF wiki
http://wiki.eclipse.org/index.php/GMF_Archived_Newsgroup_Q&a mp;A#How_can_I_use_GMF_diagrams_without_using_files.3F
But this answer does not solve my problem :-(

Does anybody know how to solve this problem? Or is there some better solution how to create diagrams from domain objects?

Thanks
Martin
Previous Topic:Labels and Polyline Connection
Next Topic:Diagram Partitioning
Goto Forum:
  


Current Time: Fri Apr 26 09:00:02 GMT 2024

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

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

Back to the top