Synchronizing different diagrams to show parts of the same model [message #491015] |
Mon, 12 October 2009 15:28  |
Eclipse User |
|
|
|
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 #491930 is a reply to message #491486] |
Fri, 16 October 2009 10:56   |
Eclipse User |
|
|
|
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 #500841 is a reply to message #496659] |
Sun, 29 November 2009 08:21  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04042 seconds