Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Serialization betwenn Xtext und Graphiti
Serialization betwenn Xtext und Graphiti [message #1599853] Tue, 03 February 2015 23:09 Go to next message
Pierre Kaptue is currently offline Pierre KaptueFriend
Messages: 6
Registered: May 2014
Junior Member
Hello Guys,
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

Please somebody can i help me?

Best regard
Re: Serialization betwenn Xtext und Graphiti [message #1604013 is a reply to message #1599853] Fri, 06 February 2015 15:16 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Pierre,

not sure if I got that correctly, but I think you need to somehow register a
listener on Xtext level to get notified about such changes and then trigger
the according updates in the diagram.

I'm not an Xtext expert, so I cannot tell you how to do that. Maybe you
could ask that question in the Xtext forum.

Michael
Re: Serialization betwenn Xtext und Graphiti [message #1620781 is a reply to message #1599853] Tue, 17 February 2015 12:26 Go to previous messageGo to next message
Simon Sperl is currently offline Simon SperlFriend
Messages: 21
Registered: May 2014
Junior Member
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)
Re: Serialization betwenn Xtext und Graphiti [message #1620926 is a reply to message #1620781] Tue, 17 February 2015 14:39 Go to previous messageGo to next message
Pierre Kaptue is currently offline Pierre KaptueFriend
Messages: 6
Registered: May 2014
Junior Member
Hello Simon,
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?

Thank you

Pierre
Re: Serialization betwenn Xtext und Graphiti [message #1622507 is a reply to message #1620926] Wed, 18 February 2015 14:51 Go to previous message
Simon Sperl is currently offline Simon SperlFriend
Messages: 21
Registered: May 2014
Junior Member
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.

Previous Topic:Custom Feature location Context Menu
Next Topic:Inconsistency in SVG export
Goto Forum:
  


Current Time: Thu Apr 18 18:57:36 GMT 2024

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

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

Back to the top