Connections and Drag&Drop [message #213144] |
Mon, 03 April 2006 14:32 |
Eclipse User |
|
|
|
Originally posted by: sami.lakka.watechnologies.no_spam.com
My editor allows users to drag & drop model elements from a tree to GEF
editor. Between model elements there can be connections and my problem is
that I don't want to draw the connections if the other model element isn't
in the diagram. I handle this in getModelSource/Target methods where I first
check if the other part of the connection is already in the diagram and if
it is I call the targetParts refreshTargetConnection method. I have to do
this because otherwise the
connection isn't attached to the target part. Now in getModelTarget I have
to call again to getModelSource to ascertain that the source connections are
ok. This leads to awful code that doesn't seem to work in every occasion so
I was wondering is there a simpler/nicer way to do this?
Pseudocode:
private boolean isUpdating = false;
protected List getModelSourceConnections() {
...
if (isInDiagram(targetModel)) {
if (isUpdating)
sourceConnections.add(association);
else
targetPart.refreshTargetConnections();
}
}
protected List getModelTargetConnections() {
if (!isInDiagram(sourceModel)) {
sourcePart = (JavaElementEditPart)
getViewer().getEditPartRegistry().get(sourceModel);
sourcePart.setUpdating(true);
sourcePart.refreshSourceConnections();
sourcePart.setUpdating(false);
connections.add(association)
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.02838 seconds