ItEr06S03ArquitecturaClientesItEr05S03: Fixing bug. When a new dependency was added, it didn't update the arrow in some edge cases.
This commit is contained in:
parent
b1555cb111
commit
07912640e7
3 changed files with 35 additions and 10 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
package org.zkoss.ganttz;
|
package org.zkoss.ganttz;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
@ -148,8 +149,27 @@ public class DependencyList extends XulElement implements AfterCompose {
|
||||||
return getGanttPanel().getTimeTracker();
|
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()) {
|
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();
|
dependency.redrawDependency();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,9 +72,13 @@ public class Planner extends XulElement implements AfterCompose {
|
||||||
return findOneComponentOfType(GanttPanel.class);
|
return findOneComponentOfType(GanttPanel.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DependencyList getDependencyList() {
|
public DependencyList getDependencyList() {
|
||||||
List<Object> children = getGanntPanel().getChildren();
|
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() {
|
private ListDetails getDetails() {
|
||||||
|
|
|
||||||
|
|
@ -283,19 +283,20 @@ public class Task extends Div {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProperties() {
|
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("0");
|
||||||
setLeft(getMapper().toPixels(this.taskBean.getBeginDate()) + "px");
|
setLeft(getMapper().toPixels(this.taskBean.getBeginDate()) + "px");
|
||||||
setWidth("0");
|
setWidth("0");
|
||||||
setWidth(getMapper().toPixels(this.taskBean.getLengthMilliseconds())
|
setWidth(getMapper().toPixels(this.taskBean.getLengthMilliseconds())
|
||||||
+ "px");
|
+ "px");
|
||||||
smartUpdate("name", this.taskBean.getName());
|
smartUpdate("name", this.taskBean.getName());
|
||||||
|
DependencyList dependencyList = getDependencyList();
|
||||||
|
if (dependencyList != null) {
|
||||||
|
dependencyList.redrawDependenciesConnectedTo(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DependencyList getDependencyList() {
|
||||||
|
return getPlanner().getDependencyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue