my goal is to generated from some Xtext-Datei a diagram and add all the Object which them connection. That was working fine. I based of org.eclipse.graphiti.examples.common. Each Xtext-Datei is associated to one diagram file. When i make some modification (create/delete/add object) on thediagram, i become these modification on my xtext-datei but another way (xtext-datei to diagram for example if i delete some Object) is not working.
Remark: if i change the name of object on the xtext-datei, follow these modification on my diagram. the only problem is delete some object from my xtext-datei
You are most likely using the default Graphiti mechanism for handling updates?
If you do, the problem cause is that when a xtext file is changed the (changed) sub tree structure is replaced!
Your deleted objects in graphiti are now very likely objects where obj.eResource() == null (andor obj.eContainer() == null)
So in order for the linking to work properly between xtext and graphiti, you need to use URIs or QualifiedNames of the object instead of live memory references.
(I think the Notifier you want is the XtextBuildParticipant to update your diagram)
i think i know my problem. Each diagram i was create get a resource. That means Xtext and Graphiti working in 2 different resources. May be i can try to synchronize the both resources, and if the resource of xtext it was modified, i schould find with object it is and bring the modification in my diagram. My problem now is first how can i have the resource of Xtext? second how schould i compare the both resources?
Yes this is indeed tricky, depending on when you want to update your diagrams.
A) whenever your xtext file is saved
B) whenever your xtext file is changed in the xtext editor
if A) you can use the XtextBuildParticipant extension point to get the xtext resource, then search for your diagram editor (or diagram file) and update them
Note: I think every build (pretty certainly) creates a new xtext resource
if B) you can create a IPartListener2.partActivated() for your Diagram Editor and whenever your diagram comes to front (and changes are in an open xtext editor) do an update
Note: the xtext resource must be accessed from within a transaction of the xtexteditor, (any other access will likely create "interesting" crashes)
How to update?
I use a implementation that stores URIs and QualifiedNames in the diagram, when a update occurs it uses those to match diagram Elements and xtext Elements.