ItEr17S10CUCreacionProxectoPlanificacionItEr16S12: Previous functionality of adding task is now set up using commands support.
This commit is contained in:
parent
fc12eccb9e
commit
36e51de76c
10 changed files with 186 additions and 142 deletions
|
|
@ -7,18 +7,18 @@ import org.zkoss.zk.ui.event.EventListener;
|
|||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zul.Button;
|
||||
|
||||
class CommandContextualized {
|
||||
class CommandContextualized<T> {
|
||||
|
||||
public static CommandContextualized create(ICommand command,
|
||||
IContext context) {
|
||||
return new CommandContextualized(command, context);
|
||||
public static <T> CommandContextualized<T> create(ICommand<T> command,
|
||||
IContext<T> context) {
|
||||
return new CommandContextualized<T>(command, context);
|
||||
}
|
||||
|
||||
private final ICommand command;
|
||||
private final ICommand<T> command;
|
||||
|
||||
private final IContext context;
|
||||
private final IContext<T> context;
|
||||
|
||||
private CommandContextualized(ICommand command, IContext context) {
|
||||
private CommandContextualized(ICommand<T> command, IContext<T> context) {
|
||||
this.command = command;
|
||||
this.context = context;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,115 @@
|
|||
package org.zkoss.ganttz;
|
||||
|
||||
import org.zkoss.ganttz.extensions.IContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FunctionalityExposedForExtensions implements IContext {
|
||||
import org.zkoss.ganttz.adapters.DomainDependency;
|
||||
import org.zkoss.ganttz.adapters.IAdapterToTaskFundamentalProperties;
|
||||
import org.zkoss.ganttz.adapters.IDomainAndBeansMapper;
|
||||
import org.zkoss.ganttz.adapters.IStructureNavigator;
|
||||
import org.zkoss.ganttz.extensions.IContext;
|
||||
import org.zkoss.ganttz.util.DependencyBean;
|
||||
import org.zkoss.ganttz.util.GanttDiagramGraph;
|
||||
import org.zkoss.ganttz.util.ITaskFundamentalProperties;
|
||||
import org.zkoss.ganttz.util.TaskBean;
|
||||
import org.zkoss.ganttz.util.TaskContainerBean;
|
||||
import org.zkoss.ganttz.util.TaskLeafBean;
|
||||
|
||||
public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
||||
|
||||
private static class OneToOneMapper<T> implements IDomainAndBeansMapper<T> {
|
||||
private Map<T, TaskBean> fromDomainToTaskBean = new HashMap<T, TaskBean>();
|
||||
|
||||
private Map<TaskBean, T> fromTaskBeanToDomain = new HashMap<TaskBean, T>();
|
||||
|
||||
@Override
|
||||
public TaskBean findAssociatedBean(T domainObject)
|
||||
throws IllegalArgumentException {
|
||||
if (domainObject == null)
|
||||
throw new IllegalArgumentException("domainObject is null");
|
||||
if (!fromDomainToTaskBean.containsKey(domainObject))
|
||||
throw new IllegalArgumentException("not found " + domainObject);
|
||||
return fromDomainToTaskBean.get(domainObject);
|
||||
}
|
||||
|
||||
void register(TaskBean taskBean, T domainObject) {
|
||||
fromDomainToTaskBean.put(domainObject, taskBean);
|
||||
fromTaskBeanToDomain.put(taskBean, domainObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T findAssociatedDomainObject(TaskBean taskBean)
|
||||
throws IllegalArgumentException {
|
||||
if (taskBean == null)
|
||||
throw new IllegalArgumentException("taskBean is null");
|
||||
if (!fromTaskBeanToDomain.containsKey(taskBean))
|
||||
throw new IllegalArgumentException();
|
||||
return fromTaskBeanToDomain.get(taskBean);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final Planner planner;
|
||||
private final IAdapterToTaskFundamentalProperties<T> adapter;
|
||||
private final IStructureNavigator<T> navigator;
|
||||
private final OneToOneMapper<T> mapper = new OneToOneMapper<T>();
|
||||
private final GanttDiagramGraph diagramGraph;
|
||||
|
||||
public FunctionalityExposedForExtensions(Planner planner) {
|
||||
public FunctionalityExposedForExtensions(Planner planner,
|
||||
IAdapterToTaskFundamentalProperties<T> adapter,
|
||||
IStructureNavigator<T> navigator, GanttDiagramGraph diagramGraph) {
|
||||
this.planner = planner;
|
||||
this.adapter = adapter;
|
||||
this.navigator = navigator;
|
||||
this.diagramGraph = diagramGraph;
|
||||
}
|
||||
|
||||
private TaskBean extractTaskBean(
|
||||
List<DomainDependency<T>> accumulatedDependencies, T data) {
|
||||
ITaskFundamentalProperties adapted = adapter.adapt(data);
|
||||
accumulatedDependencies
|
||||
.addAll(adapter.getDependenciesOriginating(data));
|
||||
final TaskBean result;
|
||||
if (navigator.isLeaf(data)) {
|
||||
result = new TaskLeafBean(adapted);
|
||||
} else {
|
||||
TaskContainerBean container = new TaskContainerBean(adapted);
|
||||
for (T child : navigator.getChildren(data)) {
|
||||
container.add(extractTaskBean(accumulatedDependencies, child));
|
||||
}
|
||||
result = container;
|
||||
}
|
||||
mapper.register(result, data);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void add(Collection<? extends T> domainObjects) {
|
||||
List<DomainDependency<T>> totalDependencies = new ArrayList<DomainDependency<T>>();
|
||||
for (T object : domainObjects) {
|
||||
TaskBean taskBean = extractTaskBean(totalDependencies, object);
|
||||
diagramGraph.addTopLevel(taskBean);
|
||||
this.planner.addTask(taskBean);
|
||||
}
|
||||
for (DependencyBean dependencyBean : DomainDependency
|
||||
.toDependencyBeans(mapper, totalDependencies)) {
|
||||
this.diagramGraph.add(dependencyBean);
|
||||
}
|
||||
this.diagramGraph.applyAllRestrictions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(T domainObject) {
|
||||
LinkedList<T> list = new LinkedList<T>();
|
||||
list.add(domainObject);
|
||||
add(list);
|
||||
}
|
||||
|
||||
IDomainAndBeansMapper<T> getMapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,14 @@ public class LeftPane extends HtmlMacroComponent {
|
|||
|
||||
private final List<TaskBean> topLevelTasks;
|
||||
|
||||
private List<CommandContextualized> commands;
|
||||
private List<? extends CommandContextualized<?>> commands;
|
||||
|
||||
private LeftTasksTree leftTasksTree;
|
||||
|
||||
public LeftPane(List<CommandContextualized> commands,
|
||||
public LeftPane(
|
||||
List<? extends CommandContextualized<?>> contextualizedCommands,
|
||||
List<TaskBean> topLevelTasks) {
|
||||
this.commands = commands;
|
||||
this.commands = contextualizedCommands;
|
||||
this.topLevelTasks = topLevelTasks;
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +38,7 @@ public class LeftPane extends HtmlMacroComponent {
|
|||
|
||||
private void addCommands() {
|
||||
Component commandsContainer = getCommandsContainer();
|
||||
for (CommandContextualized command : commands) {
|
||||
for (CommandContextualized<?> command : commands) {
|
||||
Button button = command.toButton();
|
||||
commandsContainer.appendChild(button);
|
||||
}
|
||||
|
|
@ -58,4 +59,8 @@ public class LeftPane extends HtmlMacroComponent {
|
|||
leftTasksTree.taskRemoved(taskBean);
|
||||
}
|
||||
|
||||
public void addTask(TaskBean newTask) {
|
||||
leftTasksTree.addTask(newTask);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import org.zkoss.ganttz.LeftTasksTreeRow.ILeftTasksTreeNavigator;
|
|||
import org.zkoss.ganttz.util.MutableTreeModel;
|
||||
import org.zkoss.ganttz.util.TaskBean;
|
||||
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.HtmlMacroComponent;
|
||||
|
|
@ -247,24 +246,6 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
tasksTreeModel.remove(taskRemoved);
|
||||
}
|
||||
|
||||
public void addTask() {
|
||||
TaskBean newTask = new TaskLeafBean();
|
||||
newTask.setName("Nova Tarefa");
|
||||
newTask.setBeginDate(new Date());
|
||||
newTask.setEndDate(threeMonthsLater(newTask.getBeginDate()));
|
||||
addTask(newTask);
|
||||
getPlanner().addTask(newTask);
|
||||
}
|
||||
|
||||
public void addTaskContainer() {
|
||||
TaskContainerBean newTask = new TaskContainerBean();
|
||||
newTask.setName("Novo Contedor de Tarefas");
|
||||
newTask.setBeginDate(new Date());
|
||||
newTask.setEndDate(threeMonthsLater(newTask.getBeginDate()));
|
||||
addTask(newTask);
|
||||
getPlanner().addTask(newTask);
|
||||
}
|
||||
|
||||
private static Date threeMonthsLater(Date now) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(now);
|
||||
|
|
@ -283,7 +264,7 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
tasksTree.setTreeitemRenderer(new TaskBeanRenderer());
|
||||
}
|
||||
|
||||
private void addTask(TaskBean taskBean) {
|
||||
void addTask(TaskBean taskBean) {
|
||||
detailsForBeans.requestFocusFor(taskBean);
|
||||
tasksTreeModel.add(tasksTreeModel.getRoot(), taskBean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ public class LeftTasksTreeRow extends GenericForwardComposer {
|
|||
belowDetail.receiveFocus(position);
|
||||
} else {
|
||||
LeftTasksTree listDetails = getListDetails();
|
||||
listDetails.addTask();
|
||||
// TODO add comamnd for focus going down
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,25 +2,19 @@ package org.zkoss.ganttz;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.zkoss.ganttz.adapters.DomainDependency;
|
||||
import org.zkoss.ganttz.adapters.IAdapterToTaskFundamentalProperties;
|
||||
import org.zkoss.ganttz.adapters.IDomainAndBeansMapper;
|
||||
import org.zkoss.ganttz.adapters.IStructureNavigator;
|
||||
import org.zkoss.ganttz.adapters.PlannerConfiguration;
|
||||
import org.zkoss.ganttz.extensions.ICommand;
|
||||
import org.zkoss.ganttz.extensions.IContext;
|
||||
import org.zkoss.ganttz.util.DependencyBean;
|
||||
import org.zkoss.ganttz.util.GanttDiagramGraph;
|
||||
import org.zkoss.ganttz.util.ITaskFundamentalProperties;
|
||||
import org.zkoss.ganttz.util.TaskBean;
|
||||
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.zul.impl.XulElement;
|
||||
|
|
@ -39,17 +33,17 @@ public class Planner extends XulElement {
|
|||
|
||||
private TaskEditFormComposer taskEditFormComposer = new TaskEditFormComposer();
|
||||
|
||||
private OneToOneMapper<?> domainObjectsMapper;
|
||||
|
||||
private DependencyAdderAdapter<?> dependencyAdder;
|
||||
|
||||
private List<CommandContextualized> contextualizedCommands;
|
||||
private List<? extends CommandContextualized<?>> contextualizedCommands;
|
||||
|
||||
public Planner() {
|
||||
}
|
||||
|
||||
TaskList getTaskList() {
|
||||
List<Object> children = findOneComponentOfType(GanttPanel.class)
|
||||
if (ganttPanel == null)
|
||||
return null;
|
||||
List<Object> children = ganttPanel
|
||||
.getChildren();
|
||||
return Planner.findComponentsOfType(TaskList.class, children).get(0);
|
||||
}
|
||||
|
|
@ -113,8 +107,6 @@ public class Planner extends XulElement {
|
|||
}
|
||||
|
||||
public void registerListeners() {
|
||||
if (diagramGraph == null)
|
||||
throw new IllegalStateException("dependencyRegistry must be set");
|
||||
ganttPanel.afterCompose();
|
||||
TaskList taskList = getTaskList();
|
||||
dependencyAddedListener = new DependencyAddedListener() {
|
||||
|
|
@ -122,7 +114,7 @@ public class Planner extends XulElement {
|
|||
@Override
|
||||
public void dependenceAdded(Dependency dependency) {
|
||||
getDependencyList().addDependency(dependency);
|
||||
publishDependency(dependency);
|
||||
diagramGraph.add(dependency.getDependencyBean());
|
||||
dependencyAdder.addDependency(dependency.getDependencyBean());
|
||||
}
|
||||
};
|
||||
|
|
@ -152,54 +144,21 @@ public class Planner extends XulElement {
|
|||
}
|
||||
|
||||
public void addTask(TaskBean newTask) {
|
||||
getTaskList().addTask(newTask);
|
||||
diagramGraph.addTopLevel(newTask);
|
||||
}
|
||||
|
||||
private void publishDependency(Dependency dependency) {
|
||||
diagramGraph.add(dependency.getDependencyBean());
|
||||
}
|
||||
|
||||
private static class OneToOneMapper<T> implements IDomainAndBeansMapper<T> {
|
||||
private Map<T, TaskBean> fromDomainToTaskBean = new HashMap<T, TaskBean>();
|
||||
|
||||
private Map<TaskBean, T> fromTaskBeanToDomain = new HashMap<TaskBean, T>();
|
||||
|
||||
@Override
|
||||
public TaskBean findAssociatedBean(T domainObject)
|
||||
throws IllegalArgumentException {
|
||||
if (domainObject == null)
|
||||
throw new IllegalArgumentException("domainObject is null");
|
||||
if (!fromDomainToTaskBean.containsKey(domainObject))
|
||||
throw new IllegalArgumentException("not found " + domainObject);
|
||||
return fromDomainToTaskBean.get(domainObject);
|
||||
TaskList taskList = getTaskList();
|
||||
if (taskList != null && leftPane != null) {
|
||||
taskList.addTask(newTask);
|
||||
leftPane.addTask(newTask);
|
||||
}
|
||||
|
||||
void register(TaskBean taskBean, T domainObject) {
|
||||
fromDomainToTaskBean.put(domainObject, taskBean);
|
||||
fromTaskBeanToDomain.put(taskBean, domainObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T findAssociatedDomainObject(TaskBean taskBean)
|
||||
throws IllegalArgumentException {
|
||||
if (taskBean == null)
|
||||
throw new IllegalArgumentException("taskBean is null");
|
||||
if (!fromTaskBeanToDomain.containsKey(taskBean))
|
||||
throw new IllegalArgumentException();
|
||||
return fromTaskBeanToDomain.get(taskBean);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class DependencyAdderAdapter<T> {
|
||||
|
||||
private final IAdapterToTaskFundamentalProperties<T> adapter;
|
||||
private final OneToOneMapper<T> mapper;
|
||||
private final IDomainAndBeansMapper<T> mapper;
|
||||
|
||||
public DependencyAdderAdapter(
|
||||
IAdapterToTaskFundamentalProperties<T> adapter,
|
||||
OneToOneMapper<T> mapper) {
|
||||
IDomainAndBeansMapper<T> mapper) {
|
||||
this.adapter = adapter;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
|
@ -227,59 +186,28 @@ public class Planner extends XulElement {
|
|||
if (configuration == null)
|
||||
return;
|
||||
this.diagramGraph = new GanttDiagramGraph();
|
||||
OneToOneMapper<T> mapper = new OneToOneMapper<T>();
|
||||
domainObjectsMapper = mapper;
|
||||
List<DomainDependency<T>> dependencies = new ArrayList<DomainDependency<T>>();
|
||||
for (T domainObject : configuration.getData()) {
|
||||
IAdapterToTaskFundamentalProperties<T> adapter = configuration
|
||||
.getAdapter();
|
||||
this.diagramGraph.addTopLevel(extractTaskBean(dependencies, mapper,
|
||||
domainObject, configuration.getNavigator(), adapter));
|
||||
}
|
||||
List<DependencyBean> dependencyBeans = DomainDependency
|
||||
.toDependencyBeans(mapper, dependencies);
|
||||
for (DependencyBean dependencyBean : dependencyBeans) {
|
||||
this.diagramGraph.add(dependencyBean);
|
||||
}
|
||||
this.diagramGraph.applyAllRestrictions();
|
||||
FunctionalityExposedForExtensions<T> context = new FunctionalityExposedForExtensions<T>(
|
||||
this, configuration.getAdapter(), configuration.getNavigator(),
|
||||
diagramGraph);
|
||||
context.add(configuration.getData());
|
||||
dependencyAdder = new DependencyAdderAdapter<T>(configuration
|
||||
.getAdapter(), mapper);
|
||||
contextualizedCommands = contextualize(
|
||||
new FunctionalityExposedForExtensions(this), configuration
|
||||
.getCommands());
|
||||
.getAdapter(), context.getMapper());
|
||||
this.contextualizedCommands = contextualize(context,
|
||||
configuration
|
||||
.getCommands());
|
||||
recreate();
|
||||
}
|
||||
|
||||
private List<CommandContextualized> contextualize(IContext context,
|
||||
Collection<? extends ICommand> commands) {
|
||||
ArrayList<CommandContextualized> result = new ArrayList<CommandContextualized>();
|
||||
for (ICommand command : commands) {
|
||||
private <T> List<CommandContextualized<T>> contextualize(
|
||||
IContext<T> context,
|
||||
Collection<? extends ICommand<T>> commands) {
|
||||
ArrayList<CommandContextualized<T>> result = new ArrayList<CommandContextualized<T>>();
|
||||
for (ICommand<T> command : commands) {
|
||||
result.add(CommandContextualized.create(command, context));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private <T> TaskBean extractTaskBean(
|
||||
List<DomainDependency<T>> dependencies, OneToOneMapper<T> mapper,
|
||||
T data, IStructureNavigator<T> navigator,
|
||||
IAdapterToTaskFundamentalProperties<T> adapter) {
|
||||
ITaskFundamentalProperties adapted = adapter.adapt(data);
|
||||
dependencies.addAll(adapter.getDependenciesOriginating(data));
|
||||
TaskBean result;
|
||||
if (navigator.isLeaf(data)) {
|
||||
result = new TaskLeafBean(adapted);
|
||||
} else {
|
||||
TaskContainerBean container = new TaskContainerBean(adapted);
|
||||
for (T child : navigator.getChildren(data)) {
|
||||
container.add(extractTaskBean(dependencies, mapper, child,
|
||||
navigator, adapter));
|
||||
}
|
||||
result = container;
|
||||
}
|
||||
mapper.register(result, data);
|
||||
return result;
|
||||
}
|
||||
|
||||
public GanttDiagramGraph getGanttDiagramGraph() {
|
||||
return diagramGraph;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public class PlannerConfiguration<T> {
|
|||
|
||||
private List<? extends T> data;
|
||||
|
||||
private List<ICommand> commands = new ArrayList<ICommand>();
|
||||
private List<ICommand<T>> commands = new ArrayList<ICommand<T>>();
|
||||
|
||||
public PlannerConfiguration(IAdapterToTaskFundamentalProperties<T> adapter,
|
||||
IStructureNavigator<T> navigator, List<? extends T> data) {
|
||||
|
|
@ -39,11 +39,11 @@ public class PlannerConfiguration<T> {
|
|||
return data;
|
||||
}
|
||||
|
||||
public void addCommand(ICommand command) {
|
||||
public void addCommand(ICommand<T> command) {
|
||||
this.commands.add(command);
|
||||
}
|
||||
|
||||
public List<ICommand> getCommands() {
|
||||
public List<ICommand<T>> getCommands() {
|
||||
return Collections.unmodifiableList(commands);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
package org.zkoss.ganttz.extensions;
|
||||
|
||||
|
||||
/**
|
||||
* An action that can be applied to the planner and it's wanted to be available
|
||||
* to the user <br />
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public interface ICommand {
|
||||
public interface ICommand<T> {
|
||||
|
||||
public String getName();
|
||||
|
||||
public void doAction(IContext context);
|
||||
public void doAction(IContext<T> context);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
package org.zkoss.ganttz.extensions;
|
||||
|
||||
|
||||
/**
|
||||
* A facade for operations allowed to extensions <br />
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public interface IContext {
|
||||
public interface IContext<T> {
|
||||
|
||||
// TODO expose functionality as needed
|
||||
void add(T domainObject);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,15 @@ import org.zkoss.ganttz.adapters.AutoAdapter;
|
|||
import org.zkoss.ganttz.adapters.DomainDependency;
|
||||
import org.zkoss.ganttz.adapters.IStructureNavigator;
|
||||
import org.zkoss.ganttz.adapters.PlannerConfiguration;
|
||||
import org.zkoss.ganttz.extensions.ICommand;
|
||||
import org.zkoss.ganttz.extensions.IContext;
|
||||
import org.zkoss.ganttz.util.DefaultFundamentalProperties;
|
||||
import org.zkoss.ganttz.util.GanttDiagramGraph;
|
||||
import org.zkoss.ganttz.util.DependencyType;
|
||||
import org.zkoss.ganttz.util.GanttDiagramGraph;
|
||||
import org.zkoss.ganttz.util.ITaskFundamentalProperties;
|
||||
import org.zkoss.ganttz.util.TaskBean;
|
||||
import org.zkoss.ganttz.util.TaskContainerBean;
|
||||
import org.zkoss.ganttz.util.TaskLeafBean;
|
||||
|
||||
/**
|
||||
* Some test data for planner <br />
|
||||
|
|
@ -28,16 +32,38 @@ public class DataForPlanner {
|
|||
return new GanttDiagramGraph();
|
||||
}
|
||||
|
||||
private PlannerConfiguration<ITaskFundamentalProperties> addCommands(
|
||||
PlannerConfiguration<ITaskFundamentalProperties> configuration) {
|
||||
configuration.addCommand(new ICommand<ITaskFundamentalProperties>() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Add Task";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(IContext<ITaskFundamentalProperties> context) {
|
||||
TaskBean newTask = new TaskLeafBean();
|
||||
newTask.setName("Nova Tarefa");
|
||||
newTask.setBeginDate(new Date());
|
||||
newTask.setEndDate(twoMonthsLater(newTask.getBeginDate()));
|
||||
context.add(newTask);
|
||||
|
||||
}
|
||||
});
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public PlannerConfiguration<ITaskFundamentalProperties> getLightLoad() {
|
||||
return getModelWith(20);
|
||||
return addCommands(getModelWith(20));
|
||||
}
|
||||
|
||||
public PlannerConfiguration<ITaskFundamentalProperties> getMediumLoad() {
|
||||
return getModelWith(300);
|
||||
return addCommands(getModelWith(300));
|
||||
}
|
||||
|
||||
public PlannerConfiguration<ITaskFundamentalProperties> getHighLoad() {
|
||||
return getModelWith(500);
|
||||
return addCommands(getModelWith(500));
|
||||
}
|
||||
|
||||
private PlannerConfiguration<ITaskFundamentalProperties> getModelWith(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue