ItEr06S03ArquitecturaClientesItEr05S03: Fixing bug. When a new dependency was added, it didn't update the arrow in some edge cases.

This commit is contained in:
Óscar González Fernández 2009-04-29 18:35:19 +02:00 committed by Javier Moran Rua
parent b1555cb111
commit 07912640e7
3 changed files with 35 additions and 10 deletions

View file

@ -5,6 +5,7 @@
package org.zkoss.ganttz;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
@ -148,8 +149,27 @@ public class DependencyList extends XulElement implements AfterCompose {
return getGanttPanel().getTimeTracker();
}
public void redrawDependencies() {
public void redrawDependenciesConnectedTo(Task task) {
redrawDependencies(getDependenciesConnectedTo(task));
}
private List<Dependency> getDependenciesConnectedTo(Task task) {
ArrayList<Dependency> result = new ArrayList<Dependency>();
for (Dependency dependency : getDependencies()) {
if (dependency.getSource().equals(task)
|| dependency.getDestination().equals(task)) {
result.add(dependency);
}
}
return result;
}
public void redrawDependencies() {
redrawDependencies(getDependencies());
}
public void redrawDependencies(List<Dependency> dependencies) {
for (Dependency dependency : dependencies) {
dependency.redrawDependency();
}
}

View file

@ -72,9 +72,13 @@ public class Planner extends XulElement implements AfterCompose {
return findOneComponentOfType(GanttPanel.class);
}
private DependencyList getDependencyList() {
public DependencyList getDependencyList() {
List<Object> children = getGanntPanel().getChildren();
return findComponentsOfType(DependencyList.class, children).get(0);
List<DependencyList> found = findComponentsOfType(DependencyList.class,
children);
if (found.isEmpty())
return null;
return found.get(0);
}
private ListDetails getDetails() {

View file

@ -283,19 +283,20 @@ public class Task extends Div {
}
private void updateProperties() {
/*
* It is set to another value, so the smart update is forced. If the new
* value is equal to the previous, the smart update wouldn't be sent and
* it would keep the same position in the client. This position could be
* the result of dragging the task, so it would seem that the dependency
* is not enforced.
*/
setLeft("0");
setLeft(getMapper().toPixels(this.taskBean.getBeginDate()) + "px");
setWidth("0");
setWidth(getMapper().toPixels(this.taskBean.getLengthMilliseconds())
+ "px");
smartUpdate("name", this.taskBean.getName());
DependencyList dependencyList = getDependencyList();
if (dependencyList != null) {
dependencyList.redrawDependenciesConnectedTo(this);
}
}
private DependencyList getDependencyList() {
return getPlanner().getDependencyList();
}
public void remove() {