Hi
I have some questions regarding Graphiti and EMF concepts
My goals are following
I already have a meta-model (Epackage) which i want to use to generate a graphical editor for creating models that conform to this meta-model the same way an xml do to a xsd schema.
Before opening the diagram i register the Epackage to the same resource set as the diagram as following
editingDomain = GraphitiUi.getEmfService()
.createResourceSetAndEditingDomain();
ResourceSet resourceSet = editingDomain.getResourceSet();
final Resource diagramResource = resourceSet.createResource(diagramUri);
CommandStack commandStack = editingDomain.getCommandStack();
commandStack.execute(new RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
diagramResource.setTrackingModification(true);
diagramResource.getContents().add(diagram);
}
});
saveInWorkspaceRunnable(editingDomain,
Collections.<Resource, Map<?, ?>> emptyMap());
editingDomain.dispose();
From the meta-model Epackage i generate create and add features for all EClasses in this Epackage, and when the user add an EClass to the diagram by drag and drop the createfeature "public Object[] create(ICreateContext context)" do the following
EClass eClass = (EClass) myEpackage.getEClassifier(eClassName);
EObject newClass = myEpackage.getEFactoryInstance().create(eClass);
getDiagram().eResource().getContents().add(newClass);
addGraphicalRepresentation(context, newClass);
This is how the .diagram file looks like
<?xml version="1.0" encoding="ASCII"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="...org/XMI" xmlns:xsi="...org/2001/XMLSchema-instance" xmlns:Test="file:/C:/runtime-EclipseApplication/test/test.xsd" xmlns:al="org/graphiti/mm/algorithms" xmlns:pi="org/graphiti/mm/pictograms">
<pi:Diagram visible="true" gridUnit="10" diagramTypeId="uixml" name="test" snapToGrid="true" pictogramLinks="/0/@children.0/@link /0/@children.0/@children.1/@link" version="0.10.0">
<graphicsAlgorithm ... />
<graphicsAlgorithm.../>
<link businessObjects="/1"/>
.
.
.
</pi:Diagram>
<Test:TesteClass/>
</xmi:XMI>
When i save the diagram the object is in the .Diagram file but when i later load it i got a nullPointer exception and the following error in the diagram editor No Diagram found for URI 'platform:/resource/testProject/test.diagram#/0
It works fine if i do this instead
EClass newClass = EClass newClass = EcoreFactory.eINSTANCE.createEClass();
addGraphicalRepresentation(context, newClass);
This is how the .diagram file looks like
<?xml version="1.0" encoding="ASCII"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="...org/XMI" xmlns:xsi="...org/2001/XMLSchema-instance" xmlns:al="....org/graphiti/mm/algorithms" xmlns:ecore="org/emf/2002/Ecore" xmlns:pi="....org/graphiti/mm/pictograms">
<pi:Diagram visible="true" gridUnit="10" diagramTypeId="tutorial" name="test" snapToGrid="true" pictogramLinks="/0/@children.0/@link /0/@children.0/@children.1/@link" version="0.10.0">
<graphicsAlgorithm ...>
.
.
<link businessObjects="/1"/>
.
.
.
</pi:Diagram>
<ecore:EClass name="testEclass"/>
</xmi:XMI>
I have no idea what causes this and would appreciate any input on this. Thanks in advance
[Updated on: Sat, 08 March 2014 10:55]
Report message to a moderator