GMF display diagram example

二次信任 提交于 2019-12-11 11:35:49

问题


How can I display a GMF diagram, with the file format "*.ecorediag" in Eclipse in a View? The diagram should not be editable.

Is there a simple sample view that loads a diagram from say "/home/diagrams/test.ecorediag"


回答1:


The GMF diagrams (including ecorediag) are rendered on the editor with the help of "org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer".

So the bare minimum code to make this work

DiagramGraphicalViewer viewer = new DiagramGraphicalViewer();
viewer.createControl(composite);

RootEditPart root = EditPartService.getInstance().createRootEditPart(
                diagram);
viewer.setRootEditPart(root);
viewer.setEditPartFactory(new EcoreEditPartProvider());

viewer.getControl().setBackground(ColorConstants.listBackground);

viewer.setContents(diagram);


来源:https://stackoverflow.com/questions/12148243/gmf-display-diagram-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!