Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Synchronizing different diagrams to show parts of the same model
Synchronizing different diagrams to show parts of the same model [message #491015] Mon, 12 October 2009 19:28 Go to next message
TL is currently offline TLFriend
Messages: 22
Registered: July 2009
Junior Member
Hi everyone,

Our group is facing the challenge to develop editor for our modeling
language which consists of 3 diagram types that enable the manipulation
of a model form three different viewpoints. The challenge we are facing
is that how to implement editors for these different viewpoints and
synchronize them so the model can be displayed and edited consistently.

I would kindly ask you for your opinion on how to elegantly achieve
this. In the following paragraphs I will describe the situation in
detail and then add specific questions. In my opinion the answers to
these question questions can also be interesting for other developers.

I learned about the possibility to share the EditingDomain, which is
described in http://wiki.eclipse.org/GMF_Tips and in some other posts.
But this actually only allows to share the semantical information
(domain model instances) across diagrams. Since our modeling language
has 2 diagram types that display the same concrete model elements (also
the layout of these models), we would need to somehow share i.e.,
synchronize also the notational information between two diagram types.
To illustrate this requirement please look at the model example at:
http://www.shrani.si/f/2x/HE/2fGA1g80/procgraph-model.png . We would
have to take the elements of the 2nd viewpoint/diagram type (which are
states and transitions between those states) and display them in the 3rd
viewpoint/diagram type. This means that after a state is
added/moved/deleted this has to be automatically done in the 3rd view.
Any suggestions how this would be possible to achieve? Both diagrams are
implemented as separate generated plug-ins with the same domain model
and separate other models (graphical, mapping and generator model).

I am thinking that the possible solution would be (not necessarily the
easiest one) to listen to the changes at the elements of the notational
model in one diagram and then programmatically propagate them to the
other diagram (through reading the properties of elements from the first
diagram and then setting the properties of the elements from the second
diagram). Could anyone comment on this solution? And how to accomplish
this (where and how can I listen for change notifications? in which
method of which class do the query and update properties code?)?
Any help would be much appreciated.

Btw: is this a problem where you would suggest the usage of proxies
instead of regular elements (states and transitions)?

Tomaz L.
Re: Synchronizing different diagrams to show parts of the same model [message #491486 is a reply to message #491015] Wed, 14 October 2009 18:44 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello T,

> I learned about the possibility to share the EditingDomain, which is
> described in http://wiki.eclipse.org/GMF_Tips and in some other posts.
> But this actually only allows to share the semantical information
> (domain model instances) across diagrams. Since our modeling language
Right. And you'll have all the diagrams loaded into the same ResourceSet,
so you'll be able to simply listen for EMF notifications and update current
diagram state in accordance.
BTW, if you think some diagram element properties should be shared with another
diagrams then you can think of moving these properties into the domain model
and modify generated code in order to use domain model properties to store
visual attributes of diagram elements..

> easiest one) to listen to the changes at the elements of the
> notational
> model in one diagram and then programmatically propagate them to the
> other diagram (through reading the properties of elements from the
> first
> diagram and then setting the properties of the elements from the
> second
> diagram). Could anyone comment on this solution? And how to accomplish
Yes, this is the first way to implement it and I suggest you starting with
it. The second step as i mentioned above will be to use domain model element
properties for storing/loading such diagram element properties. In this case
you'll simply modify generated EditParts to load/save/listen domain model
element properties.

-----------------
Alex Shatalin
Re: Synchronizing different diagrams to show parts of the same model [message #491930 is a reply to message #491486] Fri, 16 October 2009 14:56 Go to previous messageGo to next message
TL is currently offline TLFriend
Messages: 22
Registered: July 2009
Junior Member
Hi,

Alex thank you for the hint in the right direction. In my
???DiagramUpdater I found the method, which is called at the creation of
the diagram and at other events that occur and cause the needed for
updating the diagram (btw. Is there a list when the ???DiagramUpdater
methods are called?)

What I am currently tiring to do is to create an element (both semantic
and notational element and also an EditPart for it so it will show on
the diagram). I tried several ways, which I found in the newsgroups, but
could not get this task done. Could someone please help me?

Here are the paths that I tried:
1. The usual one where you create a CreateViewAndElementRequest or
CreateViewRequest and then try to execute it with a command. The problem
is that I don't know how to get the command, since I cannot get an
EditPart. As you probably know the ???DiagramUpdater methods only get a
View object as parameter (this is actually the instance of a Diagram
class), so there is no EditPart object on which to call the
..getCommand(myRequest) method. Any idea what to do? Can I somehow get
the DiagramEditPart or should I take another way?

2. The other method suggested by some post is to create only the
semantic elements. Supposedly the notational element and the appropriate
EditPart should be created by the CanonicalEditPolicy. Here is the code:
---------------
ProcgraphFactory factory = ProcgraphFactory.eINSTANCE;
State myState = factory.createState();
myState.setName("test 1");

VirtualDependence container = (VirtualDependence) view.getElement();
container.getStates().add(myState);
---------------

This does not work and I get the error "Cannot modify resource set
without a write transaction", which is perfectly logical. Should I try
to do this on the EMF level also with a request and command? I think
this path is not preferable since I have to adjust the diagram location
of programmatically the created element and I don't know how I would to
this when I only create a semantic element.

Hopefully the questions aren’t too trivial. Unfortunately I am still a
beginner in the GMF runtime framework. Thank you for any potential
suggestions.

Tomaz L.



Alex Shatalin:
> Hello T,
>
>> I learned about the possibility to share the EditingDomain, which is
>> described in http://wiki.eclipse.org/GMF_Tips and in some other posts.
>> But this actually only allows to share the semantical information
>> (domain model instances) across diagrams. Since our modeling language
> Right. And you'll have all the diagrams loaded into the same
> ResourceSet, so you'll be able to simply listen for EMF notifications
> and update current diagram state in accordance.
> BTW, if you think some diagram element properties should be shared with
> another diagrams then you can think of moving these properties into the
> domain model and modify generated code in order to use domain model
> properties to store visual attributes of diagram elements..
>
>> easiest one) to listen to the changes at the elements of the
>> notational
>> model in one diagram and then programmatically propagate them to the
>> other diagram (through reading the properties of elements from the
>> first
>> diagram and then setting the properties of the elements from the
>> second
>> diagram). Could anyone comment on this solution? And how to accomplish
> Yes, this is the first way to implement it and I suggest you starting
> with it. The second step as i mentioned above will be to use domain
> model element properties for storing/loading such diagram element
> properties. In this case you'll simply modify generated EditParts to
> load/save/listen domain model element properties.
>
> -----------------
> Alex Shatalin
>
>
Re: Synchronizing different diagrams to show parts of the same model [message #495052 is a reply to message #491930] Tue, 03 November 2009 16:15 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello T,

> updating the diagram (btw. Is there a list when the ???DiagramUpdater
> methods are called?)
Currently ???DiagramUpdater is called from the ???CanonicalEditPolicies (on
corresponding notification from the domain model).

> This does not work and I get the error "Cannot modify resource set
> without a write transaction", which is perfectly logical. Should I try
You have to create subclass of AbstractTransactionalCommand, implement doExecuteWithResult()
method (just copy-paste existing code there) and run this command using OperationHistoryFactory.getOperationHistory().execute()
method.

> to do this on the EMF level also with a request and command? I think
> this path is not preferable since I have to adjust the diagram
> location of programmatically the created element and I don't know how
> I would to this when I only create a semantic element.
Right. It's better to modify a place calling ???DiagramUpated and creating
diagram elements for corresponding domain model elements returned from the
updater methods.. See ???CanonicalEditPolicy.

-----------------
Alex Shatalin
Re: Synchronizing different diagrams to show parts of the same model [message #496659 is a reply to message #495052] Tue, 10 November 2009 20:17 Go to previous messageGo to next message
TL is currently offline TLFriend
Messages: 22
Registered: July 2009
Junior Member
Hi Alex,

I did what you suggested. I created only semantic elements (the way you
suggested) and let the CanonicalEditPolicy take care of the
corresponding EditParts and Views.

I put the create semantical elements code into the
get???SemanticChildren(View view) method of the ???DiagramUpdater class.

I also had to be careful not to get into an endless loop since adding
semantic elements calls the get???SemanticChildren method again (so I
did initialization just when there were no elements in the diagram I am
trying to populate).

Although I finally succeeded with the addition of editparts to my new
diagram I am experiencing some problems. The new diagram should
initially be a copy of the contents of 2 exiting diagrams (it should
merge them into one diagram).

An example of an original diagram that should be copied into the new
diagram is depicted in the “source_diagram.JPG” file.
After I initialize my new diagram with adding semantic elements to my
new diagram I first see the diagram that is depicted on the
“initial-diagram.JPG” image. This is defiantly not correct since it
looks like the elements have been copied twice to the model of the new
diagram. But when I try to move one of nodes the diagram changes
suddenly to the one depicted on
“diagram_after-trying-to-move-a-node.JPG”. And this is how I would
expect it to be in the beginning (this is the correct diagram).

I don’t know why the initial diagram is not shown correctly. Alex, do
you maybe have any idea, what could be wrong? Could this be a bug? (I’m
using GMF 2.1.0)

Also I am wondering where and how to adjust the location of the added
EditParts, since I have no access to any EdiParts in the
get???SemanticChildren method where I am creating the semantic elements.


>> to do this on the EMF level also with a request and command? I think
>> this path is not preferable since I have to adjust the diagram
>> location of programmatically the created element and I don't know how
>> I would to this when I only create a semantic element.
> Right. It's better to modify a place calling ???DiagramUpated and
> creating diagram elements for corresponding domain model elements
> returned from the updater methods.. See ???CanonicalEditPolicy.

Alex, it seems you misspelled the method name, I could not find any
similar method. Also I don’t know where to get access the notational
elements, that represent the views.

---------
Tomaz
Re: Synchronizing different diagrams to show parts of the same model [message #500841 is a reply to message #496659] Sun, 29 November 2009 13:21 Go to previous message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello T,

> An example of an original diagram that should be copied into the new
> diagram is depicted in the “source_diagram.JPG” file.
Looks like there was no attachements..

> “initial-diagram.JPG” image. This is defiantly not correct since it
> looks like the elements have been copied twice to the model of the new
> diagram. But when I try to move one of nodes the diagram changes
> suddenly to the one depicted on
> “diagram_after-trying-to-move-a-node.JPG”. And this is how I would
So, looks like DiagramUpdater is working properly - it is removing duplicating
visual elements pointing to the same domain model elements.
Then you need to debug diagram creaton process to check why diagram elements
for the same domain model element was created twice - first time by DiagramUpdater
+ CanonicalEditPolicy and second time dy some code (probably initializing
the diagram..) You have to either suppress diagram updating (check diagran
mode creation from the toolbar as an example - in this case diagram update
will be postponed till the end of command then all the diagram elements will
be finally created) or not create diagram element by diagram initialization
code - just let DiagramUpdater do it.

-----------------
Alex Shatalin
Previous Topic:Caching Edit Parts possible?
Next Topic:Generating Elements Automatically
Goto Forum:
  


Current Time: Thu Mar 28 11:01:44 GMT 2024

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

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

Back to the top