// Ignore if the changed collector gem is not displayed.
if (!(collectorToDisplay == null || collectorToDisplay == changedCollector)) {
return;
}
CollectorNode collectorNode = collectorToNodeMap.get(changedCollector);
nodeChanged(collectorNode);
// If we are displaying multiple collectors, ensure that they remain in order.
// Don't reposition the target though.
CollectorGem targetCollectorGem = gemGraph.getTargetCollector();
if (collectorToDisplay == null && changedCollector != targetCollectorGem) {
// Check vs. siblings.
ArgumentTreeNode rootNode = (ArgumentTreeNode)getRoot();
CollectorNode targetCollectorNode = getCollectorNode(targetCollectorGem);
// Get the collector node which should precede this collector's node.
CollectorNode precedingNode = (CollectorNode)collectorNode.getPreviousSibling();
while (precedingNode != null && precedingNode != targetCollectorNode &&
collectorComparatorByName.compare(changedCollector, precedingNode.getCollectorGem()) < 0) {
precedingNode = (CollectorNode)precedingNode.getPreviousSibling();
}
// If it's not equal to the node which currently precedes it, reposition.
if (precedingNode != collectorNode.getPreviousSibling()) {
removeNodeFromParent(collectorNode);
int insertIndex = (precedingNode == null) ? 0 : rootNode.getIndex(precedingNode) + 1;
insertNodeInto(collectorNode, rootNode, insertIndex);
// We can skip the check against the following node, if the nodes are always sorted.
return;
}
// Get the collector node which should follow this collector's node.
CollectorNode followingNode = (CollectorNode)collectorNode.getNextSibling();
while (followingNode != null && collectorComparatorByName.compare(followingNode.getCollectorGem(), changedCollector) < 0) {
followingNode = (CollectorNode)followingNode.getNextSibling();
}
// If it's not equal to the node which currently follows it, reposition.
if (followingNode != collectorNode.getNextSibling()) {
removeNodeFromParent(collectorNode);