Binary assosiation between one class [message #485877] |
Tue, 15 September 2009 11:56 |
No real name 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 #486114 is a reply to message #486000] |
Wed, 16 September 2009 12:01 |
No real name 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03472 seconds