ItEr22S12CUVistaRecursosTempoPorProxectoItEr21S07: When the type changes a new dependency is created.

This commit is contained in:
Óscar González Fernández 2009-08-18 12:26:56 +02:00
parent 2ff7e7b5ee
commit 25208ebe52
4 changed files with 15 additions and 16 deletions

View file

@ -21,13 +21,10 @@ public class DependencyComponent extends XulElement implements AfterCompose {
private TaskComponent destination;
private DependencyType type;
private FunctionalityExposedForExtensions<?> context;
public DependencyComponent(FunctionalityExposedForExtensions<?> context,
TaskComponent source, TaskComponent destination) {
this.type = DependencyType.END_START;
this.context = context;
if (source == null)
throw new IllegalArgumentException("source cannot be null");
@ -105,11 +102,7 @@ public class DependencyComponent extends XulElement implements AfterCompose {
}
public DependencyType getDependencyType() {
return this.type;
}
public void setType(DependencyType type) {
this.type = type;
return getDependency().getType();
}
public boolean hasSameSourceAndDestination(Dependency dependency) {

View file

@ -155,8 +155,8 @@ public class DependencyList extends XulElement implements AfterCompose {
@Override
public void onEvent(final DependencyComponent choosen,
Event event) {
choosen.setType(DependencyType.END_START);
choosen.invalidate();
context.changeType(choosen.getDependency(),
DependencyType.END_START);
}
});
@ -165,8 +165,8 @@ public class DependencyList extends XulElement implements AfterCompose {
@Override
public void onEvent(final DependencyComponent choosen,
Event event) {
choosen.setType(DependencyType.START_START);
choosen.invalidate();
context.changeType(choosen.getDependency(),
DependencyType.START_START);
}
});
@ -175,8 +175,8 @@ public class DependencyList extends XulElement implements AfterCompose {
@Override
public void onEvent(final DependencyComponent choosen,
Event event) {
choosen.setType(DependencyType.END_END);
choosen.invalidate();
context.changeType(choosen.getDependency(),
DependencyType.END_END);
}
});

View file

@ -13,6 +13,7 @@ import org.zkoss.ganttz.adapters.IDomainAndBeansMapper;
import org.zkoss.ganttz.adapters.IStructureNavigator;
import org.zkoss.ganttz.adapters.PlannerConfiguration;
import org.zkoss.ganttz.data.Dependency;
import org.zkoss.ganttz.data.DependencyType;
import org.zkoss.ganttz.data.GanttDiagramGraph;
import org.zkoss.ganttz.data.ITaskFundamentalProperties;
import org.zkoss.ganttz.data.Position;
@ -270,4 +271,9 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
getDependencyList().remove(dependency);
}
public void changeType(Dependency dependency, DependencyType type) {
removeDependency(dependency);
addDependency(dependency.createWithType(type));
}
}

View file

@ -110,8 +110,8 @@ public class Dependency {
return visible;
}
public void setType(DependencyType type) {
this.type = type;
public Dependency createWithType(DependencyType type) {
return new Dependency(source, destination, type, visible);
}
}