2009-04-14 17:51:03 +02:00
|
|
|
/*
|
|
|
|
|
* To change this template, choose Tools | Templates
|
|
|
|
|
* and open the template in the editor.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package org.zkoss.ganttz;
|
|
|
|
|
|
|
|
|
|
import java.beans.PropertyChangeEvent;
|
|
|
|
|
import java.beans.PropertyChangeListener;
|
|
|
|
|
|
2009-04-27 15:57:33 +02:00
|
|
|
import org.zkoss.ganttz.util.DependencyBean;
|
|
|
|
|
import org.zkoss.ganttz.util.DependencyType;
|
2009-04-14 17:51:03 +02:00
|
|
|
import org.zkoss.zk.au.out.AuInvoke;
|
|
|
|
|
import org.zkoss.zk.ui.ext.AfterCompose;
|
|
|
|
|
import org.zkoss.zul.impl.XulElement;
|
|
|
|
|
|
|
|
|
|
/**
|
2009-06-07 18:59:58 +02:00
|
|
|
*
|
2009-04-14 17:51:03 +02:00
|
|
|
* @author Francisco Javier Moran Rúa
|
2009-06-07 18:59:58 +02:00
|
|
|
*
|
2009-04-14 17:51:03 +02:00
|
|
|
*/
|
|
|
|
|
public class Dependency extends XulElement implements AfterCompose {
|
|
|
|
|
|
|
|
|
|
private Task source;
|
|
|
|
|
|
|
|
|
|
private Task destination;
|
|
|
|
|
|
|
|
|
|
public Dependency() {
|
|
|
|
|
|
2009-07-05 17:15:30 +02:00
|
|
|
|
2009-04-14 17:51:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Dependency(Task source, Task destination) {
|
|
|
|
|
this();
|
|
|
|
|
if (source == null)
|
|
|
|
|
throw new IllegalArgumentException("source cannot be null");
|
|
|
|
|
if (destination == null)
|
|
|
|
|
throw new IllegalArgumentException("destination cannot be null");
|
|
|
|
|
this.source = source;
|
|
|
|
|
this.destination = destination;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void afterCompose() {
|
|
|
|
|
PropertyChangeListener listener = new PropertyChangeListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
|
|
redrawDependency();
|
|
|
|
|
}
|
|
|
|
|
};
|
2009-07-05 17:15:30 +02:00
|
|
|
this.source.getTaskBean().addFundamentalPropertiesChangeListener(listener);
|
|
|
|
|
this.destination.getTaskBean().addFundamentalPropertiesChangeListener(listener);
|
2009-04-14 17:51:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return the idTaskOrig
|
|
|
|
|
*/
|
|
|
|
|
public String getIdTaskOrig() {
|
|
|
|
|
return source.getUuid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setIdTaskOrig(String idTaskOrig) {
|
|
|
|
|
this.source = findTask(idTaskOrig);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Task findTask(String idTaskOrig) {
|
|
|
|
|
return (Task) getFellow(idTaskOrig);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return the idTaskEnd
|
|
|
|
|
*/
|
|
|
|
|
public String getIdTaskEnd() {
|
|
|
|
|
return destination.getUuid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setIdTaskEnd(String idTaskEnd) {
|
|
|
|
|
this.destination = findTask(idTaskEnd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void zoomChanged() {
|
|
|
|
|
redrawDependency();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void redrawDependency() {
|
|
|
|
|
response("zoomChanged", new AuInvoke(this, "draw"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean contains(Task task) {
|
|
|
|
|
return getSource().equals(task) || getDestination().equals(task);
|
|
|
|
|
}
|
2009-04-27 15:57:33 +02:00
|
|
|
|
|
|
|
|
public Task getSource() {
|
|
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task getDestination() {
|
|
|
|
|
return destination;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DependencyBean getDependencyBean() {
|
|
|
|
|
return new DependencyBean(source.getTaskBean(), destination
|
|
|
|
|
.getTaskBean(), DependencyType.END_START);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-14 17:51:03 +02:00
|
|
|
}
|