Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Graphiti EMF concept
Graphiti EMF concept [message #1266477] Fri, 07 March 2014 14:08 Go to next message
Nickie woo is currently offline Nickie wooFriend
Messages: 21
Registered: February 2014
Junior Member
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 Sad

[Updated on: Sat, 08 March 2014 10:55]

Report message to a moderator

Re: Graphiti EMF concept [message #1267236 is a reply to message #1266477] Sat, 08 March 2014 18:01 Go to previous message
Nickie woo is currently offline Nickie wooFriend
Messages: 21
Registered: February 2014
Junior Member
Found the problem, it turns out this line does not have a valid value
xmlns:Test="file:/C:/runtime-EclipseApplication/test/test.xsd"
Previous Topic:graphiti Plug-in Diagram editor
Next Topic:Gradient (IGradientType) besides horizontal and vertical
Goto Forum:
  


Current Time: Fri Apr 26 07:25:01 GMT 2024

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

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

Back to the top