Binary assosiation between one class [message #485877] |
Tue, 15 September 2009 07:56  |
Eclipse User |
|
|
|
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 08:01   |
Eclipse User |
|
|
|
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 #486315 is a reply to message #486162] |
Thu, 17 September 2009 05:00  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.06324 seconds