ItEr33S08ValidacionEProbasFuncionaisItEr32S09: [Bug #79] TaskComponent now has access to disabilityConfiguration
This commit is contained in:
parent
248b279790
commit
1e87ee10a2
4 changed files with 25 additions and 15 deletions
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.zkoss.ganttz;
|
||||
|
||||
import org.zkoss.ganttz.adapters.IDisabilityConfiguration;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
|
||||
/**
|
||||
|
|
@ -27,8 +28,9 @@ import org.zkoss.ganttz.data.Task;
|
|||
*/
|
||||
public class MilestoneComponent extends TaskComponent {
|
||||
|
||||
public MilestoneComponent(Task task) {
|
||||
super(task);
|
||||
public MilestoneComponent(Task task,
|
||||
IDisabilityConfiguration disabilityConfiguration) {
|
||||
super(task, disabilityConfiguration);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.zkoss.ganttz.adapters.IDisabilityConfiguration;
|
||||
import org.zkoss.ganttz.data.Milestone;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.ganttz.data.TaskContainer;
|
||||
|
|
@ -143,18 +144,20 @@ public class TaskComponent extends Div implements AfterCompose {
|
|||
}
|
||||
};
|
||||
|
||||
private final IDisabilityConfiguration disabilityConfiguration;
|
||||
|
||||
public static TaskComponent asTaskComponent(Task task, TaskList taskList,
|
||||
boolean isTopLevel) {
|
||||
final TaskComponent result;
|
||||
if (task.isContainer()) {
|
||||
result = TaskContainerComponent
|
||||
.asTask((TaskContainer) task, taskList);
|
||||
result = TaskContainerComponent.asTask((TaskContainer) task,
|
||||
taskList);
|
||||
} else if (task instanceof Milestone) {
|
||||
result = new MilestoneComponent(task, taskList
|
||||
.getDisabilityConfiguration());
|
||||
} else {
|
||||
if (task instanceof Milestone) {
|
||||
result = new MilestoneComponent(task);
|
||||
} else {
|
||||
result = new TaskComponent(task);
|
||||
}
|
||||
result = new TaskComponent(task, taskList
|
||||
.getDisabilityConfiguration());
|
||||
}
|
||||
result.isTopLevel = isTopLevel;
|
||||
return result;
|
||||
|
|
@ -164,12 +167,14 @@ public class TaskComponent extends Div implements AfterCompose {
|
|||
return asTaskComponent(task, taskList, true);
|
||||
}
|
||||
|
||||
public TaskComponent(Task task) {
|
||||
public TaskComponent(Task task,
|
||||
IDisabilityConfiguration disabilityConfiguration) {
|
||||
setHeight(HEIGHT_PER_TASK + "px");
|
||||
setContext("idContextMenuTaskAssignment");
|
||||
this.task = task;
|
||||
setColor(STANDARD_TASK_COLOR);
|
||||
setId(UUID.randomUUID().toString());
|
||||
this.disabilityConfiguration = disabilityConfiguration;
|
||||
}
|
||||
|
||||
protected String calculateClass() {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class TaskContainerComponent extends TaskComponent implements
|
|||
private IExpandListener expandListener;
|
||||
|
||||
public TaskContainerComponent(TaskContainer taskContainer, TaskList taskList) {
|
||||
super(taskContainer);
|
||||
super(taskContainer, taskList.getDisabilityConfiguration());
|
||||
if (!taskContainer.isContainer())
|
||||
throw new IllegalArgumentException();
|
||||
this.expandListener = new IExpandListener() {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
|
||||
private final FunctionalityExposedForExtensions<?> context;
|
||||
|
||||
private boolean addingDependenciesEnabled;
|
||||
private final IDisabilityConfiguration disabilityConfiguration;
|
||||
|
||||
public TaskList(
|
||||
FunctionalityExposedForExtensions<?> context,
|
||||
|
|
@ -79,8 +79,7 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
this.editTaskCommand = editTaskCommand;
|
||||
this.originalTasks = tasks;
|
||||
this.commandsOnTasksContextualized = commandsOnTasksContextualized;
|
||||
this.addingDependenciesEnabled = disabilityConfiguration
|
||||
.isAddingDependenciesEnabled();
|
||||
this.disabilityConfiguration = disabilityConfiguration;
|
||||
}
|
||||
|
||||
public static TaskList createFor(
|
||||
|
|
@ -284,7 +283,7 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
if (contextMenu == null) {
|
||||
MenuBuilder<TaskComponent> menuBuilder = MenuBuilder.on(getPage(),
|
||||
getTaskComponents());
|
||||
if (addingDependenciesEnabled) {
|
||||
if (disabilityConfiguration.isAddingDependenciesEnabled()) {
|
||||
menuBuilder.item("Add Dependency",
|
||||
new ItemAction<TaskComponent>() {
|
||||
|
||||
|
|
@ -333,4 +332,8 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
context.addDependency(new Dependency(source.getTask(), destination
|
||||
.getTask(), DependencyType.END_START));
|
||||
}
|
||||
|
||||
public IDisabilityConfiguration getDisabilityConfiguration() {
|
||||
return disabilityConfiguration;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue