Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Binary assosiation between one class
Binary assosiation between one class [message #485877] Tue, 15 September 2009 11:56 Go to next message
No real name is currently offline No real nameFriend
Messages: 8
Registered: July 2009
Junior Member
Hello,

i need a binary association between one class. Like a association
"Neighbor" between two objects of one class "Element". The EOpposite of
"Neighbor" i would be "Neighbor", too.

As i read in the emf-newsgroup, this is not possible in emf, so it isn't
really possible in gmf either.

As a workaround, i created a simple association "Neighbor", from
"Element" to itself. In the ElementNeighbourCreateCommand.java i changed
the method doExecuteWithResult(...) from

doExecuteWithResult(...){
....
if (getSource() != null && getTarget() != null) {
getSource().getNeighbor().add(getTarget());
}
....
}

to
doExecuteWithResult(...){
....
if (getSource() != null && getTarget() != null) {
getSource().getNeighbor().add(getTarget());
getTarget().getNeighbor().add(getSource());
}
....
}

(I adjusted the ElementNeighbourReorientCommand.java the same way also.)

First question: this is working, but is it also the right gmf-way to do it?

Second question: In the diagram there are shown two neighbour-links
between the Elements, which is correct, because i create two links. But
since these two links are actually one binary link, i would to have only
one link displayed. Is there a (elegant) way, to prevent the second link
from being displayed?


Thanks a lot in advance and best regards,
Klaus
Re: Binary assosiation between one class [message #486000 is a reply to message #485877] Tue, 15 September 2009 20:56 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Klaus,

> First question: this is working, but is it also the right gmf-way to
> do it?
Well, if eOpposte is not working there then it's ok to modify command in
a way you did.

> have only one link displayed. Is there a (elegant) way, to prevent the
> second link from being displayed?
You have to create siource/target end link constraint hiding one of the links
using some criteria.. Like: self.criteria() > oppositeEnd.criteria()

-----------------
Alex Shatalin
Re: Binary assosiation between one class [message #486114 is a reply to message #486000] Wed, 16 September 2009 12:01 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 8
Registered: July 2009
Junior Member
Hello Alex,

first, thanks for your answer!

>> Is there a (elegant) way, to prevent the second link from being displayed?
> You have to create siource/target end link constraint hiding one of the
> links using some criteria.. Like: self.criteria() > oppositeEnd.criteria()

When i create a target end link constraint on the link mapping (i simply
used 'self.getHash() > oppositeEnd.getHash()') in the gmfmap-model, it
leads to being able to create a Neighbor-link from i.e. 'element1' to
'element2', but not being able to create it from 'element2' to 'element1'.
At first, only one link is shown, but after open/close, both links are
shown again.

Did i create the constraint at the wrong place? Does something like a
"Display-constraint" exist in gmf?

Best regards,
Klaus
Re: Binary assosiation between one class [message #486162 is a reply to message #486114] Wed, 16 September 2009 14:58 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Klaus,

> Did i create the constraint at the wrong place? Does something like a
> "Display-constraint" exist in gmf?
Ok. Sorry for incorrect advice - you need to create "constraint" (not one
of "link constraints") for this link mapping.
constraint text should be something like: self.getHash() > neighbor.getHash()

-----------------
Alex Shatalin
Re: Binary assosiation between one class [message #486315 is a reply to message #486162] Thu, 17 September 2009 09:00 Go to previous message
No real name is currently offline No real nameFriend
Messages: 8
Registered: July 2009
Junior Member
Hello,
>> Did i create the constraint at the wrong place? Does something like a
>> "Display-constraint" exist in gmf?
> you need to create "constraint" (not one of "link constraints") for
> this link mapping. constraint text should be something like:
> self.getHash() > neighbor.getHash()

looks like this doesn't work either. When i create a "constraint", i am
asked to set the Domain Meta Element when creating the generator model.
But since the constraint should be for a Referenced Rased Link, i can't
set the Domain Meta Element.

I guess i am going to change my ecore-model and change the
"neighbor"-"neighbor" reference, to "neighborSource"-"neighborTarget" or
something like that.

Thanks for help,
Klaus
Previous Topic:To transform modelo_diagram in an image
Next Topic:How can I create a circle and a square from a rectangle and an ellipse?
Goto Forum:
  


Current Time: Fri Apr 26 09:49:15 GMT 2024

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

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

Back to the top