ItEr06S03ArquitecturaClientesItEr05S03: Fixing bug. When a task is removed the task detail wasn't removed.
This commit is contained in:
parent
8c47fb0216
commit
b1555cb111
3 changed files with 35 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package org.zkoss.ganttz;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
|
@ -12,6 +13,7 @@ import org.zkoss.zk.ui.HtmlMacroComponent;
|
|||
public class ListDetails extends HtmlMacroComponent {
|
||||
|
||||
private static Log LOG = LogFactory.getLog(ListDetails.class);
|
||||
private TaskRemovedListener taskRemovedListener;
|
||||
|
||||
public ListDetails() {
|
||||
LOG.info("constructing list details");
|
||||
|
|
@ -21,6 +23,26 @@ public class ListDetails extends HtmlMacroComponent {
|
|||
return (Planner) getParent();
|
||||
}
|
||||
|
||||
private List<TaskDetail> getTaskDetails() {
|
||||
List<Object> children = getInsertionPoint().getChildren();
|
||||
return Planner.findComponentsOfType(TaskDetail.class, children);
|
||||
}
|
||||
|
||||
public void taskRemoved(Task taskRemoved) {
|
||||
List<TaskDetail> taskDetails = getTaskDetails();
|
||||
for (TaskDetail taskDetail : taskDetails) {
|
||||
if (taskDetail.getTaskId().equals(taskRemoved.getId())) {
|
||||
removeDetail(taskDetail);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("not found taskDetail for " + taskRemoved);
|
||||
}
|
||||
|
||||
private void removeDetail(TaskDetail taskDetail) {
|
||||
getInsertionPoint().getChildren().remove(taskDetail);
|
||||
}
|
||||
|
||||
public void addTask() {
|
||||
TaskDetail taskDetail = new TaskDetail();
|
||||
String newId = UUID.randomUUID().toString();
|
||||
|
|
@ -29,7 +51,7 @@ public class ListDetails extends HtmlMacroComponent {
|
|||
taskDetail.setDynamicProperty("length", "30 days");
|
||||
taskDetail.setDynamicProperty("taskName", Labels
|
||||
.getLabel("task.new_task_name"));
|
||||
Component insertionPoint = getFellow("insertionPoint");
|
||||
Component insertionPoint = getInsertionPoint();
|
||||
taskDetail.setParent(insertionPoint);
|
||||
taskDetail.afterCompose();
|
||||
Task task = new Task();
|
||||
|
|
@ -38,4 +60,8 @@ public class ListDetails extends HtmlMacroComponent {
|
|||
task.setId(newId);
|
||||
}
|
||||
|
||||
private Component getInsertionPoint() {
|
||||
return getFellow("insertionPoint");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class Planner extends XulElement implements AfterCompose {
|
|||
public Planner() {
|
||||
}
|
||||
|
||||
private TaskList getTaskList() {
|
||||
TaskList getTaskList() {
|
||||
List<Object> children = findOneComponentOfType(GanttPanel.class)
|
||||
.getChildren();
|
||||
return Planner.findComponentsOfType(TaskList.class, children).get(0);
|
||||
|
|
@ -77,6 +77,11 @@ public class Planner extends XulElement implements AfterCompose {
|
|||
return findComponentsOfType(DependencyList.class, children).get(0);
|
||||
}
|
||||
|
||||
private ListDetails getDetails() {
|
||||
List<Object> children = getChildren();
|
||||
return Planner.findComponentsOfType(ListDetails.class, children).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompose() {
|
||||
TaskList taskList = getTaskList();
|
||||
|
|
@ -91,6 +96,8 @@ public class Planner extends XulElement implements AfterCompose {
|
|||
@Override
|
||||
public void taskRemoved(Task taskRemoved) {
|
||||
dependencyRegistry.remove(taskRemoved.getTaskBean());
|
||||
getDetails().taskRemoved(taskRemoved);
|
||||
getGanntPanel().invalidate();
|
||||
}
|
||||
};
|
||||
taskList.addTaskRemovedListener(taskRemovedListener);
|
||||
|
|
|
|||
|
|
@ -203,7 +203,6 @@ public class Task extends Div {
|
|||
// Command action to do
|
||||
void doUpdatePosition(String leftX, String topY) {
|
||||
System.out.println("leftX:" + getLeft() + "newLeft:" + leftX);
|
||||
setTop(topY);
|
||||
this.taskBean.setBeginDate(getMapper().toDate(stripPx(leftX)));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue