for (UINeoNode nodeUI : getUINodes()) {
for (UITermination terminationUI : nodeUI.getVisibleTerminations()) {
if (terminationUI.getConnector() != null) {
UIOrigin originUI = terminationUI.getConnector().getOriginUI();
Termination termination = terminationUI.getModel();
Origin origin = originUI.getModel();
Projection projection = projectionMap.get(termination);
if (projection != null && projection.getOrigin() == origin) {
/*
* Projection already exists
*/
projectionsToAdd.remove(projectionMap.get(termination));
} else {
projectionsToRemove.add(terminationUI.getConnector());
}
}
}
}
/*
* Destroy unreferenced projections
*/
for (UIProjection projectionUI : projectionsToRemove) {
UITermination terminationUI = projectionUI.getTermination();
projectionUI.destroy();
if (!isFirstUpdate) {
terminationUI.showPopupMessage("REMOVED Projection to "
+ terminationUI.getNodeParent().getName() + "." + terminationUI.getName());
}
}
/*
* Construct projections
*/
for (Projection projection : projectionsToAdd) {
Origin origin = projection.getOrigin();
Termination term = projection.getTermination();
UINeoNode nodeOrigin = getUINode(origin.getNode());
UINeoNode nodeTerm = getUINode(term.getNode());
if (nodeOrigin != null && nodeTerm != null) {
UIOrigin originUI = nodeOrigin.showOrigin(origin.getName());
UITermination termUI = nodeTerm.showTermination(term.getName());
originUI.connectTo(termUI, false);
if (!isFirstUpdate) {
termUI.showPopupMessage("NEW Projection to " + termUI.getName() + "."
+ getName());
}
} else {
if (nodeOrigin == null) {
Util.Assert(false, "Could not find a Origin attached to a projection: "
+ origin.getNode().getName());
}
if (nodeTerm == null) {
Util.Assert(false, "Could not find a Termination attached to a projection: "
+ term.getNode().getName());
}
}
}