Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » EOpposite in diagram editor
EOpposite in diagram editor [message #1021500] Wed, 20 March 2013 04:29 Go to next message
Simon Zutterman is currently offline Simon Zutterman
Messages: 28
Registered: October 2012
Junior Member
Hi,

I have a metamodel that has two classes: 'Goals' and 'Objects'.
Between these two classes are two references that are set as EOpposites so i can draw a link from goal to object and from object to goal.
When i create such a link in a runtime editor, all seems fine and correctly maps the bidirectional relation (see attachment 1), but when i add another object, the layout of the bidirectional changes unwillingly. (see attachment 2).

Any idea on how to solve this problem so i don't see the two relations when i add another object?

index.php/fa/13936/0/
index.php/fa/13937/0/
Re: EOpposite in diagram editor [message #1022378 is a reply to message #1021500] Thu, 21 March 2013 15:17 Go to previous messageGo to next message
Thomas Beyer is currently offline Thomas Beyer
Messages: 55
Registered: February 2013
Member
Hi Simon,

I would guess that the CanonicalEditPolicy of your DiagramEditPart gets called on creation of the third object and creates the additional graphical relation while refreshing.
Do you define two graphical relations in your mapping model?

As you are describing, that you create 2 relations (which have to be unique in your ecore-model) between Business-Goal and Object, it seems logically, that you have two graphical representations for them.

So you might want to check this and maybe reconsider, if you really need two relations on the domain level, as one semantic relation logically already provides the opposite of the relation in both directions.

Regards
Thomas
Re: EOpposite in diagram editor [message #1023901 is a reply to message #1022378] Mon, 25 March 2013 08:31 Go to previous messageGo to next message
Simon Zutterman is currently offline Simon Zutterman
Messages: 28
Registered: October 2012
Junior Member
Hi Thomas,

What i want to achieve is a link that goes both ways
1) so i can connect Goal-Object but also Object-Goal
2) the recursive relation is automatically mapped, so if I connect Goal A-Object A,
the opposite relation is also mapped, so i can't create an additional link
Object A - Goal A.

With this EOpposite relation as you can see below how i mapped that in ecore, that aspect works. I create a single graphical def, and have two link mappings so i can make the link starting from either type of node.

index.php/fa/14005/0/

If i only have one relation on the domain level e.g. from goal-object, i won't be able to draw links from object-goal in the editor right?

So it does everything i want now but displays the recursive relation in an unwanted way when i add a new node (as seen in first post). Because I'm an Eclipse beginner, i also don't know how to find the problem in the DiagramEditPart or other code..

Any help would be immensely appreciated
  • Attachment: Knipsel.PNG
    (Size: 8.45KB, Downloaded 237 times)
Re: EOpposite in diagram editor [message #1027079 is a reply to message #1026537] Tue, 26 March 2013 10:31 Go to previous messageGo to next message
Simon Zutterman is currently offline Simon Zutterman
Messages: 28
Registered: October 2012
Junior Member
Hi Thomas,

if i only create one link mapping , it is correct that the bidirectional relation is mapped but i can only draw the link in one direction e.g. goal-object but not the other way around (object-goal).

when i delete the refresh code (see below) in the canonicaleditpolicy the entire problem is solved, as it does not refresh and displays the second relation upon creating a new node.

Collection/*[org.eclipse.core.runtime.IAdaptable]*/createdConnectionViews = refreshConnections();
if (createdViews.size() > 1) {
// perform a layout of the container
DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host()
.getEditingDomain(), createdViews, host());
executeCommand(new ICommandProxy(layoutCmd));
}
createdViews.addAll(createdConnectionViews);
makeViewsImmutable(createdViews);
}


Does removing this piece of refresh code have big consequences for my diagram editor?
Re: EOpposite in diagram editor [message #1027116 is a reply to message #1027079] Tue, 26 March 2013 11:18 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric Moonen
Messages: 269
Registered: August 2009
Senior Member
Hi Thomas,

I'm jumping in the discussion since it is a problem that I also experienced. I solved it the way you proposed (solution A), so only having mapping.
But as Simon described, it has the drawback that the user has to connect the elements always in the same order (even if the link is bidirectional). This is very confusing for the user, since the only thing he wants to do is connecting two "elements" together. How does that matter in which order they have to be connected (for him I mean) ?

But I think the problem is more generic than the EOpposite: you could also have it without using EOpposite references in your domain model. Suppose that you have a connector EClass which has a reference to an InputPort ECLass and a reference to an OutputPort EClass (it is connecting an output port of a component to an input port of another component). In this case you also have to create your connector always starting from the output port to the input port (and there's no reason, except technical one, that the user shouldn't be able to drag his connector in this other direction, since he simply wants to connect two things together).

Re: EOpposite in diagram editor [message #1036463 is a reply to message #1027116] Mon, 08 April 2013 08:25 Go to previous messageGo to next message
Thomas Beyer is currently offline Thomas Beyer
Messages: 55
Registered: February 2013
Member
Hi,

i think the discussion is more or less a graph theory one.
GMF's notational model semantically (and syntactically) only understands directed graphs, which explicitely require a source and a target.
In my eyes, this only makes sense. Take a look at an UML-Class diagram. It really does matter, from what class you are drawing a composition-relation.

Just an idea:
In order to better support the user, you could raise the abstraction of your elements (Goal and Object) to a common super-class/interface IConcern.
Give the IConcern the relations concern1 and concern2 reference to itself.
In your mapping model, add ocl-contraints to the linkmappings, that prevent the source from being the target at the same time.
This would take care of enabling the user to draw the relation from either Goal or Object to the counter part.
Once a user creates a relation, you would have to complete concern1 or concern2 programmatically (the eopposite-approach) and take care of the canonical behavior for the Relation, you do not want to be displayed.
Tweaky, but could be worth a try.

If you feel, GMF is lacking this kind of feature, you are always free to file feature requests and push discussions or even provide improvements.

Regards
Thomas

Re: EOpposite in diagram editor [message #1036491 is a reply to message #1036463] Mon, 08 April 2013 08:53 Go to previous message
Simon Zutterman is currently offline Simon Zutterman
Messages: 28
Registered: October 2012
Junior Member
Hi Thomas, thanks for the feedback

the topic is actually more related to http://www.eclipse.org/forums/index.php/t/470258/
where I want eclipse to realize it really is one recursive relation, and where it doesn't matter which node is source/target. Don't you agree Eclipse should support such a feature?

I currently limited my editor using OCL so it's not possible anymore to make 2 recursive relations between two nodes. To solve the graphical problem of the two links i deleted the connections refresh semantics in the canonical policy. currently all is working fine, i just hope this won't cause any problems.
Previous Topic:click behaviour to edit a label
Next Topic:How to refresh decorators?
Goto Forum:
  


Current Time: Wed Jul 23 12:22:28 EDT 2014

Powered by FUDForum. Page generated in 0.01690 seconds