ItEr33S14CUCreacionUnidadesPlanificacion: DependencyComponent now has a reference to Dependency
This commit is contained in:
parent
21bc198211
commit
46a901746a
3 changed files with 16 additions and 23 deletions
|
|
@ -23,9 +23,9 @@ package org.zkoss.ganttz;
|
|||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.zkoss.ganttz.data.Dependency;
|
||||
import org.zkoss.ganttz.data.DependencyType;
|
||||
import org.zkoss.ganttz.data.GanttDiagramGraph;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.zk.au.out.AuInvoke;
|
||||
import org.zkoss.zk.ui.ext.AfterCompose;
|
||||
|
|
@ -44,20 +44,19 @@ public class DependencyComponent extends XulElement implements AfterCompose {
|
|||
|
||||
private DependencyType type;
|
||||
|
||||
private Dependency dependency;
|
||||
|
||||
public DependencyComponent(TaskComponent source, TaskComponent destination,
|
||||
DependencyType type) {
|
||||
this.type = type;
|
||||
if (source == null) {
|
||||
throw new IllegalArgumentException("source cannot be null");
|
||||
}
|
||||
if (destination == null) {
|
||||
throw new IllegalArgumentException("destination cannot be null");
|
||||
}
|
||||
if (type == null) {
|
||||
throw new IllegalArgumentException("type must be not null");
|
||||
}
|
||||
Dependency dependency) {
|
||||
Validate.notNull(dependency);
|
||||
Validate.notNull(source);
|
||||
Validate.notNull(destination);
|
||||
Validate.isTrue(source.getTask() == dependency.getSource());
|
||||
Validate.isTrue(destination.getTask() == dependency.getDestination());
|
||||
this.type = dependency.getType();
|
||||
this.source = source;
|
||||
this.destination = destination;
|
||||
this.dependency = dependency;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -122,9 +121,8 @@ public class DependencyComponent extends XulElement implements AfterCompose {
|
|||
return destination;
|
||||
}
|
||||
|
||||
public Dependency getDependency(GanttDiagramGraph diagramGraph) {
|
||||
return diagramGraph.getDependencyFrom(source.getTask(),
|
||||
destination.getTask());
|
||||
public Dependency getDependency() {
|
||||
return dependency;
|
||||
}
|
||||
|
||||
public DependencyType getDependencyType() {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class DependencyList extends XulElement implements AfterCompose {
|
|||
|
||||
@Override
|
||||
public void onEvent(final DependencyComponent choosen, Event event) {
|
||||
context.changeType(dependencyFor(choosen), type);
|
||||
context.changeType(choosen.getDependency(), type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -197,7 +197,7 @@ public class DependencyList extends XulElement implements AfterCompose {
|
|||
final DependencyComponent choosen,
|
||||
Event event) {
|
||||
context
|
||||
.removeDependency(dependencyFor(choosen));
|
||||
.removeDependency(choosen.getDependency());
|
||||
}
|
||||
});
|
||||
contextMenuBuilder.item("Set End-Start", new ChangeTypeAction(
|
||||
|
|
@ -265,9 +265,4 @@ public class DependencyList extends XulElement implements AfterCompose {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Dependency dependencyFor(
|
||||
final DependencyComponent dependencyComponent) {
|
||||
return dependencyComponent.getDependency(context.getDiagramGraph());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
for (Dependency dependency : dependencies) {
|
||||
result.add(new DependencyComponent(taskComponentByTask
|
||||
.get(dependency.getSource()), taskComponentByTask
|
||||
.get(dependency.getDestination()), dependency.getType()));
|
||||
.get(dependency.getDestination()), dependency));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue