ItEr17S10CUCreacionProxectoPlanificacionItEr16S12: Refactoring Planner so it doesn't send exceptions when the configuration is still not ready.
This commit is contained in:
parent
697ec9ff54
commit
c15a93229e
3 changed files with 23 additions and 14 deletions
|
|
@ -17,11 +17,13 @@ public class GanttPanel extends XulElement implements AfterCompose {
|
|||
|
||||
private final DependencyRegistry dependencyRegistry;
|
||||
|
||||
public GanttPanel(DependencyRegistry dependencyRegistry) {
|
||||
public GanttPanel(DependencyRegistry dependencyRegistry,
|
||||
TaskEditFormComposer taskEditFormComposer) {
|
||||
this.dependencyRegistry = dependencyRegistry;
|
||||
timeTracker = new TimeTracker(this);
|
||||
appendChild(timeTracker);
|
||||
tasksLists = TaskList.createFor(dependencyRegistry.getTopLevelTasks());
|
||||
tasksLists = TaskList.createFor(taskEditFormComposer,
|
||||
dependencyRegistry.getTopLevelTasks());
|
||||
dependencyList = new DependencyList();
|
||||
appendChild(tasksLists);
|
||||
appendChild(dependencyList);
|
||||
|
|
|
|||
|
|
@ -20,10 +20,9 @@ import org.zkoss.ganttz.util.TaskContainerBean;
|
|||
import org.zkoss.ganttz.util.TaskLeafBean;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.ext.AfterCompose;
|
||||
import org.zkoss.zul.impl.XulElement;
|
||||
|
||||
public class Planner extends XulElement implements AfterCompose {
|
||||
public class Planner extends XulElement {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(Planner.class);
|
||||
|
||||
|
|
@ -32,8 +31,11 @@ public class Planner extends XulElement implements AfterCompose {
|
|||
private DependencyRemovedListener dependencyRemovedListener;
|
||||
private TaskRemovedListener taskRemovedListener;
|
||||
private ListDetails listDetails;
|
||||
|
||||
private GanttPanel ganttPanel;
|
||||
|
||||
private TaskEditFormComposer taskEditFormComposer = new TaskEditFormComposer();
|
||||
|
||||
private OneToOneMapper<?> domainObjectsMapper;
|
||||
|
||||
public Planner() {
|
||||
|
|
@ -96,11 +98,10 @@ public class Planner extends XulElement implements AfterCompose {
|
|||
}
|
||||
|
||||
public TaskEditFormComposer getModalFormComposer() {
|
||||
return getTaskList().getModalFormComposer();
|
||||
return taskEditFormComposer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompose() {
|
||||
public void registerListeners() {
|
||||
if (dependencyRegistry == null)
|
||||
throw new IllegalStateException("dependencyRegistry must be set");
|
||||
ganttPanel.afterCompose();
|
||||
|
|
@ -180,6 +181,8 @@ public class Planner extends XulElement implements AfterCompose {
|
|||
}
|
||||
|
||||
public <T> void setConfiguration(PlannerConfiguration<T> configuration) {
|
||||
if (configuration == null)
|
||||
return;
|
||||
this.dependencyRegistry = new DependencyRegistry();
|
||||
OneToOneMapper<T> mapper = new OneToOneMapper<T>();
|
||||
domainObjectsMapper = mapper;
|
||||
|
|
@ -232,7 +235,9 @@ public class Planner extends XulElement implements AfterCompose {
|
|||
.get(0)));
|
||||
this.listDetails.afterCompose();
|
||||
removePreviousGanntPanel();
|
||||
this.ganttPanel = new GanttPanel(this.dependencyRegistry);
|
||||
this.ganttPanel = new GanttPanel(this.dependencyRegistry,
|
||||
taskEditFormComposer);
|
||||
appendChild(ganttPanel);
|
||||
registerListeners();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,16 +46,18 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
|
||||
private Menupopup contextMenu;
|
||||
|
||||
private TaskEditFormComposer taskEditFormComposer = new TaskEditFormComposer();
|
||||
|
||||
private List<TaskBean> originalTasks;
|
||||
|
||||
public TaskList(List<TaskBean> tasks) {
|
||||
private final TaskEditFormComposer taskEditFormComposer;
|
||||
|
||||
public TaskList(TaskEditFormComposer formComposer, List<TaskBean> tasks) {
|
||||
this.taskEditFormComposer = formComposer;
|
||||
this.originalTasks = tasks;
|
||||
}
|
||||
|
||||
public static TaskList createFor(List<TaskBean> tasks) {
|
||||
TaskList result = new TaskList(tasks);
|
||||
public static TaskList createFor(TaskEditFormComposer formComposer,
|
||||
List<TaskBean> tasks) {
|
||||
TaskList result = new TaskList(formComposer, tasks);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -253,7 +255,7 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
}
|
||||
|
||||
public void redrawDependencies() {
|
||||
getGanttPanel().getDependencyList().redrawDependencies() ;
|
||||
getGanttPanel().getDependencyList().redrawDependencies();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue