if (showMixedCheckmarkState) {
// Record the check states of our ancestors before we change
// anything so we know which events to fire after we're done
ancestorCheckStates = new ArrayList<NodeCheckState>(path.getLength() - 1);
Path ancestorPath = new Path(path, path.getLength() - 1);
for (int i = ancestorPath.getLength() - 1; i >= 0; i--) {
ancestorCheckStates.insert(getNodeCheckState(ancestorPath), 0);
ancestorPath.remove(i, 1);
}
}
if (checked) {
// Monitor the path's parent
monitorBranch(new Path(path, path.getLength() - 1));
// Update the checked paths
checkedPaths.add(new ImmutablePath(path));
} else {
// Update the checked paths
checkedPaths.remove(index, 1);
}
// Notify listeners
treeViewNodeStateListeners.nodeCheckStateChanged(this, path, previousCheckState);
if (showMixedCheckmarkState) {
// Notify listeners of any changes to our ancestors' check states
Path ancestorPath = new Path(path, path.getLength() - 1);
for (int i = ancestorPath.getLength() - 1; i >= 0; i--) {
NodeCheckState ancestorPreviousCheckState = ancestorCheckStates.get(i);
NodeCheckState ancestorCheckState = getNodeCheckState(ancestorPath);
if (ancestorCheckState != ancestorPreviousCheckState) {
treeViewNodeStateListeners.nodeCheckStateChanged
(this, ancestorPath, ancestorPreviousCheckState);
}
ancestorPath.remove(i, 1);
}
}
}
}