Object object=objectEvent.getObject();
if (object instanceof Dependency) {
Dependency dependency = ((Dependency)object);
if (dependency.getDocument() == document || dependency.getMasterDocument() == document) { // links can come from other projects too, but successor should be in this project
if (objectEvent.isCreate()) {
Node preNode=(Node)model.search(dependency.getPredecessor());
Node sucNode=(Node)model.search(dependency.getSuccessor());
GraphicNode preGNode=(GraphicNode)nodeCache.getElement(preNode);
GraphicNode sucGNode=(GraphicNode)nodeCache.getElement(sucNode);
if (preGNode!=null&&sucGNode!=null){
GraphicDependency edge=(GraphicDependency)edgeCache.getElement(dependency);
if (edge == null) { // for external tasks in subprojects, it's possible they already were created
edge=newGraphicDependency(preGNode,sucGNode,dependency);
update();
}
}
} else if (objectEvent.isDelete()) {
GraphicDependency edge=(GraphicDependency)edgeCache.getElement(dependency);
if (edge!=null){
removeEdge(edge);
update();
}
//edgeCache.fireEdgesRemoved(this,new Object[]{edge});
} else { //update
GraphicDependency edge=(GraphicDependency)edgeCache.getElement(dependency);
if (edge!=null){
modifyEdge(edge,dependency.getDependencyType());
update();
}
//edgeCache.fireEdgesUpdated(this,new Object[]{edge});
}
}
}else{
if (object!=null&&((object instanceof Task && (type&NodeModelCache.TASK_TYPE)==NodeModelCache.TASK_TYPE)||
(object instanceof Resource && (type&NodeModelCache.RESOURCE_TYPE)==NodeModelCache.RESOURCE_TYPE)||
(object instanceof Assignment && (type&NodeModelCache.ASSIGNMENT_TYPE)==NodeModelCache.ASSIGNMENT_TYPE)||
(object instanceof Project && (type&NodeModelCache.PROJECT_TYPE)==NodeModelCache.PROJECT_TYPE))){
if (object!=null&&!objectEvent.isDelete()){ //because node is already deleted
//TODO cannot update parents in case of deletion
Node node=model.search(object);
if (node !=null) {
for(;!node.isRoot();node=model.getParent(node)){
// System.out.println("objectChanged "+objectEvent.getType()+": "+node);
GraphicNode gnode=getGraphicNode(node);
if (gnode != null) // on project list it is null
gnode.setDirty(true);
//nodeCache.fireObjectEvent(objectEvent.getSource(),objectEvent);