[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Binary assosiation between one class

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