public void nodesChanged(HierarchyEvent e) {
// System.out.println("Node changed ...");
// if ("NO_PROJECT_UPDATE".equals(e.getFlag())) return;
Node node, previousParentNode, newParentNode;
Task task, previousParentTask, newParentTask;
int count=e.getNodes().length;
if (count==0) return;
for (int i=0;i<count;i++){
node=(Node)e.getNodes()[i];
if (!(node.getImpl() instanceof Task)) continue;
task=(Task) node.getImpl();
//TODO verify that this is ok when pasting for bug 426
// task.setProject((Project) getSchedulingAlgorithm().getMasterDocument());
// task.setOwningProject(this);
//moved to validateObject
previousParentTask=task.getWbsParentTask();
previousParentNode=taskOutlines.getDefaultOutline().search(previousParentTask);
// refresh the previous parent's children
if (previousParentTask!=null) {
previousParentTask.markAllDependentTasksAsNeedingRecalculation(true); // flag this and dependent tasks as dirty
previousParentTask.setWbsChildrenNodes(taskOutlines.getDefaultOutline().getHierarchy().getChildren(previousParentNode));
}
// refresh the new parent's children
NodeHierarchy hierarchy=taskOutlines.getDefaultOutline().getHierarchy();
newParentNode = hierarchy.getParent(node);
newParentTask = null;
if (newParentNode!=hierarchy.getRoot()) {
newParentTask=(Task)newParentNode.getImpl();
newParentTask.setWbsChildrenNodes(taskOutlines.getDefaultOutline().getHierarchy().getChildren(newParentNode));
newParentTask.restrictToValidConstraintType();
// newParentTask.setParentDuration(); //hk
newParentTask.markAllDependentTasksAsNeedingRecalculation(true); // flag this and dependent tasks as dirty
}
//refresh this node to point to new parent
task.setWbsParent(newParentTask);
final Task _newParentTask = newParentTask;
final Object eventSource = e.getSource();
// recursively remove all dependencies between new parent and any children, grandchildren, etc.
taskOutlines.getDefaultOutline().getHierarchy().visitAll(newParentNode, new Closure() {
public void execute(Object arg) {
Node node=(Node)arg;
if (!(node.getImpl() instanceof Task)) return;
Task task = (Task) node.getImpl();
DependencyService.getInstance().removeAnyDependencies(task, _newParentTask,eventSource);
}
});
}
if (!e.isVoid()) { // if the event was not the promotion of a void node