Task removedTask = (Task) changedObject;
predecessorTaskList.removeTask(removedTask);
reset(); // Fix of bug 91 31/8/05. This ensures the ancestors of this task that are no longer parents will be replaced as single entries in pred list
} else if (objectEvent.isUpdate()) {
task = (Task)changedObject;
Field field = objectEvent.getField();
if (field != null && !fieldUpdater.inputContains(field))
return;
if (field == constraintTypeField) {
reset();
task.invalidateSchedules();
task.markTaskAsNeedingRecalculation();
}
}
calculate(true,task);
} else if (changedObject instanceof Dependency) { // dependency added or
// removed
Dependency dependency = (Dependency) changedObject;
if (!dependency.refersToDocument(project))
return;
if (!objectEvent.isUpdate()) {
reset(); // refresh predecssor list - the whold thing may change drastically no matter what the link because of parents
}
task = (Task)dependency.getPredecessor();
Task successor = (Task) dependency.getSuccessor(); // the successor needs to be scheduled
// to fix a bug, I am invalidating both early and late schedules
task.invalidateSchedules();
task.markTaskAsNeedingRecalculation();
if (successor.isSubproject()) { // special case for subprojects - need to reset all
SubProj sub = (SubProj)successor;
if (sub.isSubprojectOpen())
sub.getSubproject().markAllTasksAsNeedingRecalculation(true);
}
successor.invalidateSchedules();
successor.markTaskAsNeedingRecalculation();
// The line below fixes a bug with nested parents of the sort pred->grand par sib1->sib2. Of course, it means most of the code above is redundant (except for subproject stuff)
project.markAllTasksAsNeedingRecalculation(true);
calculate(true,null); // Run both passes, since the CP might be modified and it's hard to tell if so
} else if (changedObject == project) { // if whole project changed, such
// as hierarchy event
reset();
calculate(true,null);
} else if (changedObject instanceof WorkingCalendar) { // if whole project changed, such
//TODO for now just invalidating all projects, eventually be smarter
project.markAllTasksAsNeedingRecalculation(false);
calculate(true,null);
} else if (changedObject instanceof Assignment) {
Assignment assignment = (Assignment)changedObject;
task = assignment.getTask();
if (task.getProject().getSchedulingAlgorithm() != this)
return;
// if (((NormalTask)task).isEffortDriven())
calculate(true,task);
} else if (changedObject instanceof BelongsToDocument){ // for other things, such as assignment entry
if (((BelongsToDocument)changedObject).getDocument() instanceof Project) {
Project proj = (Project)((BelongsToDocument)changedObject).getDocument();
if (proj.getSchedulingAlgorithm() != this)
return;
}
Field field = objectEvent.getField();
if (field != null && fieldUpdater.inputContains(field))
calculate(true,null);
}
}