ItEr17S10CUCreacionProxectoPlanificacionItEr16S12: Removing Bean sufix to data classes. To avoid name collisions with the components of the same name, Component is appended.
This commit is contained in:
parent
55cede5979
commit
91f1e0e97d
26 changed files with 503 additions and 503 deletions
|
|
@ -5,5 +5,5 @@ package org.zkoss.ganttz;
|
|||
|
||||
public interface DependencyAddedListener {
|
||||
|
||||
public void dependenceAdded(Dependency dependency);
|
||||
public void dependenceAdded(DependencyComponent dependencyComponent);
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ package org.zkoss.ganttz;
|
|||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
import org.zkoss.ganttz.data.DependencyBean;
|
||||
import org.zkoss.ganttz.data.Dependency;
|
||||
import org.zkoss.ganttz.data.DependencyType;
|
||||
import org.zkoss.zk.au.out.AuInvoke;
|
||||
import org.zkoss.zk.ui.ext.AfterCompose;
|
||||
|
|
@ -19,18 +19,18 @@ import org.zkoss.zul.impl.XulElement;
|
|||
* @author Francisco Javier Moran Rúa
|
||||
*
|
||||
*/
|
||||
public class Dependency extends XulElement implements AfterCompose {
|
||||
public class DependencyComponent extends XulElement implements AfterCompose {
|
||||
|
||||
private Task source;
|
||||
private TaskComponent source;
|
||||
|
||||
private Task destination;
|
||||
private TaskComponent destination;
|
||||
|
||||
public Dependency() {
|
||||
public DependencyComponent() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Dependency(Task source, Task destination) {
|
||||
public DependencyComponent(TaskComponent source, TaskComponent destination) {
|
||||
this();
|
||||
if (source == null)
|
||||
throw new IllegalArgumentException("source cannot be null");
|
||||
|
|
@ -49,8 +49,8 @@ public class Dependency extends XulElement implements AfterCompose {
|
|||
redrawDependency();
|
||||
}
|
||||
};
|
||||
this.source.getTaskBean().addFundamentalPropertiesChangeListener(listener);
|
||||
this.destination.getTaskBean().addFundamentalPropertiesChangeListener(listener);
|
||||
this.source.getTask().addFundamentalPropertiesChangeListener(listener);
|
||||
this.destination.getTask().addFundamentalPropertiesChangeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -61,12 +61,12 @@ public class Dependency extends XulElement implements AfterCompose {
|
|||
}
|
||||
|
||||
public void setIdTaskOrig(String idTaskOrig) {
|
||||
this.source = findTask(idTaskOrig);
|
||||
this.source = findTaskComponent(idTaskOrig);
|
||||
|
||||
}
|
||||
|
||||
private Task findTask(String idTaskOrig) {
|
||||
return (Task) getFellow(idTaskOrig);
|
||||
private TaskComponent findTaskComponent(String idTaskOrig) {
|
||||
return (TaskComponent) getFellow(idTaskOrig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -77,7 +77,7 @@ public class Dependency extends XulElement implements AfterCompose {
|
|||
}
|
||||
|
||||
public void setIdTaskEnd(String idTaskEnd) {
|
||||
this.destination = findTask(idTaskEnd);
|
||||
this.destination = findTaskComponent(idTaskEnd);
|
||||
}
|
||||
|
||||
public void zoomChanged() {
|
||||
|
|
@ -88,21 +88,21 @@ public class Dependency extends XulElement implements AfterCompose {
|
|||
response("zoomChanged", new AuInvoke(this, "draw"));
|
||||
}
|
||||
|
||||
public boolean contains(Task task) {
|
||||
return getSource().equals(task) || getDestination().equals(task);
|
||||
public boolean contains(TaskComponent taskComponent) {
|
||||
return getSource().equals(taskComponent) || getDestination().equals(taskComponent);
|
||||
}
|
||||
|
||||
public Task getSource() {
|
||||
public TaskComponent getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public Task getDestination() {
|
||||
public TaskComponent getDestination() {
|
||||
return destination;
|
||||
}
|
||||
|
||||
public DependencyBean getDependencyBean() {
|
||||
return new DependencyBean(source.getTaskBean(), destination
|
||||
.getTaskBean(), DependencyType.END_START);
|
||||
public Dependency getDependency() {
|
||||
return new Dependency(source.getTask(), destination
|
||||
.getTask(), DependencyType.END_START);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.zkoss.ganttz.data.TaskBean;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.ganttz.util.MenuBuilder;
|
||||
import org.zkoss.ganttz.util.WeakReferencedListeners;
|
||||
import org.zkoss.ganttz.util.MenuBuilder.ItemAction;
|
||||
|
|
@ -31,15 +31,15 @@ public class DependencyList extends XulElement implements AfterCompose {
|
|||
|
||||
private final class DependencyVisibilityToggler implements
|
||||
PropertyChangeListener {
|
||||
private final TaskBean source;
|
||||
private final TaskBean destination;
|
||||
private final Dependency dependency;
|
||||
private final Task source;
|
||||
private final Task destination;
|
||||
private final DependencyComponent dependencyComponent;
|
||||
|
||||
private DependencyVisibilityToggler(TaskBean source,
|
||||
TaskBean destination, Dependency dependency) {
|
||||
private DependencyVisibilityToggler(Task source,
|
||||
Task destination, DependencyComponent dependencyComponent) {
|
||||
this.source = source;
|
||||
this.destination = destination;
|
||||
this.dependency = dependency;
|
||||
this.dependencyComponent = dependencyComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -53,15 +53,15 @@ public class DependencyList extends XulElement implements AfterCompose {
|
|||
|
||||
void toggleDependencyExistence(boolean visible) {
|
||||
if (visible) {
|
||||
appendChild(dependency);
|
||||
addContextMenu(dependency);
|
||||
appendChild(dependencyComponent);
|
||||
addContextMenu(dependencyComponent);
|
||||
} else {
|
||||
removeChild(dependency);
|
||||
removeChild(dependencyComponent);
|
||||
}
|
||||
}
|
||||
|
||||
boolean isDependencyNowVisible() {
|
||||
return dependency.getParent() != null;
|
||||
return dependencyComponent.getParent() != null;
|
||||
}
|
||||
|
||||
boolean dependencyMustBeVisible() {
|
||||
|
|
@ -81,39 +81,39 @@ public class DependencyList extends XulElement implements AfterCompose {
|
|||
public DependencyList() {
|
||||
}
|
||||
|
||||
private List<Dependency> getDependencies() {
|
||||
private List<DependencyComponent> getDependencyComponents() {
|
||||
List<Object> children = getChildren();
|
||||
return Planner.findComponentsOfType(Dependency.class, children);
|
||||
return Planner.findComponentsOfType(DependencyComponent.class, children);
|
||||
}
|
||||
|
||||
void addDependency(final Dependency dependency) {
|
||||
Task source = dependency.getSource();
|
||||
Task destination = dependency.getDestination();
|
||||
void addDependencyComponent(final DependencyComponent dependencyComponent) {
|
||||
TaskComponent source = dependencyComponent.getSource();
|
||||
TaskComponent destination = dependencyComponent.getDestination();
|
||||
DependencyVisibilityToggler visibilityToggler = new DependencyVisibilityToggler(
|
||||
source.getTaskBean(), destination.getTaskBean(), dependency);
|
||||
source.getTaskBean().addVisibilityPropertiesChangeListener(
|
||||
source.getTask(), destination.getTask(), dependencyComponent);
|
||||
source.getTask().addVisibilityPropertiesChangeListener(
|
||||
visibilityToggler);
|
||||
destination.getTaskBean().addVisibilityPropertiesChangeListener(
|
||||
destination.getTask().addVisibilityPropertiesChangeListener(
|
||||
visibilityToggler);
|
||||
boolean dependencyMustBeVisible = visibilityToggler
|
||||
.dependencyMustBeVisible();
|
||||
visibilityToggler.toggleDependencyExistence(dependencyMustBeVisible);
|
||||
if (dependencyMustBeVisible) {
|
||||
dependency.redrawDependency();
|
||||
dependencyComponent.redrawDependency();
|
||||
}
|
||||
}
|
||||
|
||||
private void addContextMenu(Dependency dependency) {
|
||||
dependency.setContext(getContextMenu());
|
||||
private void addContextMenu(DependencyComponent dependencyComponent) {
|
||||
dependencyComponent.setContext(getContextMenu());
|
||||
}
|
||||
|
||||
private GanttPanel getGanttPanel() {
|
||||
return (GanttPanel) getParent();
|
||||
}
|
||||
|
||||
public void setDependencies(List<Dependency> dependencies) {
|
||||
for (Dependency dependency : dependencies) {
|
||||
addDependency(dependency);
|
||||
public void setDependencyComponents(List<DependencyComponent> dependencyComponents) {
|
||||
for (DependencyComponent dependencyComponent : dependencyComponents) {
|
||||
addDependencyComponent(dependencyComponent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,8 +123,8 @@ public class DependencyList extends XulElement implements AfterCompose {
|
|||
listener = new ZoomLevelChangedListener() {
|
||||
@Override
|
||||
public void zoomLevelChanged(ZoomLevel detailLevel) {
|
||||
for (Dependency dependency : getDependencies()) {
|
||||
dependency.zoomChanged();
|
||||
for (DependencyComponent dependencyComponent : getDependencyComponents()) {
|
||||
dependencyComponent.zoomChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -134,11 +134,11 @@ public class DependencyList extends XulElement implements AfterCompose {
|
|||
taskRemovedListener = new TaskRemovedListener() {
|
||||
|
||||
@Override
|
||||
public void taskRemoved(Task taskRemoved) {
|
||||
for (Dependency dependency : DependencyList.this
|
||||
.getDependencies()) {
|
||||
if (dependency.contains(taskRemoved)) {
|
||||
dependency.detach();
|
||||
public void taskComponentRemoved(TaskComponent taskComponentRemoved) {
|
||||
for (DependencyComponent dependencyComponent : DependencyList.this
|
||||
.getDependencyComponents()) {
|
||||
if (dependencyComponent.contains(taskComponentRemoved)) {
|
||||
dependencyComponent.detach();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -151,8 +151,8 @@ public class DependencyList extends XulElement implements AfterCompose {
|
|||
}
|
||||
|
||||
private void addContextMenu() {
|
||||
for (Dependency dependency : getDependencies()) {
|
||||
addContextMenu(dependency);
|
||||
for (DependencyComponent dependencyComponent : getDependencyComponents()) {
|
||||
addContextMenu(dependencyComponent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,10 +160,10 @@ public class DependencyList extends XulElement implements AfterCompose {
|
|||
|
||||
private Menupopup getContextMenu() {
|
||||
if (contextMenu == null) {
|
||||
contextMenu = MenuBuilder.on(getPage(), getDependencies()).item(
|
||||
"Erase", new ItemAction<Dependency>() {
|
||||
contextMenu = MenuBuilder.on(getPage(), getDependencyComponents()).item(
|
||||
"Erase", new ItemAction<DependencyComponent>() {
|
||||
@Override
|
||||
public void onEvent(final Dependency choosen,
|
||||
public void onEvent(final DependencyComponent choosen,
|
||||
Event event) {
|
||||
removeChild(choosen);
|
||||
dependencyRemovedListeners
|
||||
|
|
@ -191,28 +191,28 @@ public class DependencyList extends XulElement implements AfterCompose {
|
|||
return getGanttPanel().getTimeTracker();
|
||||
}
|
||||
|
||||
public void redrawDependenciesConnectedTo(Task task) {
|
||||
redrawDependencies(getDependenciesConnectedTo(task));
|
||||
public void redrawDependenciesConnectedTo(TaskComponent taskComponent) {
|
||||
redrawDependencyComponents(getDependencyComponentsConnectedTo(taskComponent));
|
||||
}
|
||||
|
||||
private List<Dependency> getDependenciesConnectedTo(Task task) {
|
||||
ArrayList<Dependency> result = new ArrayList<Dependency>();
|
||||
for (Dependency dependency : getDependencies()) {
|
||||
if (dependency.getSource().equals(task)
|
||||
|| dependency.getDestination().equals(task)) {
|
||||
result.add(dependency);
|
||||
private List<DependencyComponent> getDependencyComponentsConnectedTo(TaskComponent taskComponent) {
|
||||
ArrayList<DependencyComponent> result = new ArrayList<DependencyComponent>();
|
||||
for (DependencyComponent dependencyComponent : getDependencyComponents()) {
|
||||
if (dependencyComponent.getSource().equals(taskComponent)
|
||||
|| dependencyComponent.getDestination().equals(taskComponent)) {
|
||||
result.add(dependencyComponent);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void redrawDependencies() {
|
||||
redrawDependencies(getDependencies());
|
||||
redrawDependencyComponents(getDependencyComponents());
|
||||
}
|
||||
|
||||
public void redrawDependencies(List<Dependency> dependencies) {
|
||||
for (Dependency dependency : dependencies) {
|
||||
dependency.redrawDependency();
|
||||
public void redrawDependencyComponents(List<DependencyComponent> dependencyComponents) {
|
||||
for (DependencyComponent dependencyComponent : dependencyComponents) {
|
||||
dependencyComponent.redrawDependency();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ package org.zkoss.ganttz;
|
|||
*/
|
||||
public interface DependencyRemovedListener {
|
||||
|
||||
public void dependenceRemoved(Dependency dependency);
|
||||
public void dependenceRemoved(DependencyComponent dependencyComponent);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,44 +11,44 @@ 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.data.DependencyBean;
|
||||
import org.zkoss.ganttz.data.Dependency;
|
||||
import org.zkoss.ganttz.data.GanttDiagramGraph;
|
||||
import org.zkoss.ganttz.data.ITaskFundamentalProperties;
|
||||
import org.zkoss.ganttz.data.TaskBean;
|
||||
import org.zkoss.ganttz.data.TaskContainerBean;
|
||||
import org.zkoss.ganttz.data.TaskLeafBean;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.ganttz.data.TaskContainer;
|
||||
import org.zkoss.ganttz.data.TaskLeaf;
|
||||
import org.zkoss.ganttz.extensions.IContext;
|
||||
|
||||
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<T, Task> fromDomainToTask = new HashMap<T, Task>();
|
||||
|
||||
private Map<TaskBean, T> fromTaskBeanToDomain = new HashMap<TaskBean, T>();
|
||||
private Map<Task, T> fromTaskToDomain = new HashMap<Task, T>();
|
||||
|
||||
@Override
|
||||
public TaskBean findAssociatedBean(T domainObject)
|
||||
public Task findAssociatedBean(T domainObject)
|
||||
throws IllegalArgumentException {
|
||||
if (domainObject == null)
|
||||
throw new IllegalArgumentException("domainObject is null");
|
||||
if (!fromDomainToTaskBean.containsKey(domainObject))
|
||||
if (!fromDomainToTask.containsKey(domainObject))
|
||||
throw new IllegalArgumentException("not found " + domainObject);
|
||||
return fromDomainToTaskBean.get(domainObject);
|
||||
return fromDomainToTask.get(domainObject);
|
||||
}
|
||||
|
||||
void register(TaskBean taskBean, T domainObject) {
|
||||
fromDomainToTaskBean.put(domainObject, taskBean);
|
||||
fromTaskBeanToDomain.put(taskBean, domainObject);
|
||||
void register(Task task, T domainObject) {
|
||||
fromDomainToTask.put(domainObject, task);
|
||||
fromTaskToDomain.put(task, domainObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T findAssociatedDomainObject(TaskBean taskBean)
|
||||
public T findAssociatedDomainObject(Task task)
|
||||
throws IllegalArgumentException {
|
||||
if (taskBean == null)
|
||||
if (task == null)
|
||||
throw new IllegalArgumentException("taskBean is null");
|
||||
if (!fromTaskBeanToDomain.containsKey(taskBean))
|
||||
if (!fromTaskToDomain.containsKey(task))
|
||||
throw new IllegalArgumentException();
|
||||
return fromTaskBeanToDomain.get(taskBean);
|
||||
return fromTaskToDomain.get(task);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -68,18 +68,18 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
this.diagramGraph = diagramGraph;
|
||||
}
|
||||
|
||||
private TaskBean extractTaskBean(
|
||||
private Task extractTask(
|
||||
List<DomainDependency<T>> accumulatedDependencies, T data) {
|
||||
ITaskFundamentalProperties adapted = adapter.adapt(data);
|
||||
accumulatedDependencies
|
||||
.addAll(adapter.getDependenciesOriginating(data));
|
||||
final TaskBean result;
|
||||
final Task result;
|
||||
if (navigator.isLeaf(data)) {
|
||||
result = new TaskLeafBean(adapted);
|
||||
result = new TaskLeaf(adapted);
|
||||
} else {
|
||||
TaskContainerBean container = new TaskContainerBean(adapted);
|
||||
TaskContainer container = new TaskContainer(adapted);
|
||||
for (T child : navigator.getChildren(data)) {
|
||||
container.add(extractTaskBean(accumulatedDependencies, child));
|
||||
container.add(extractTask(accumulatedDependencies, child));
|
||||
}
|
||||
result = container;
|
||||
}
|
||||
|
|
@ -90,13 +90,13 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
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);
|
||||
Task task = extractTask(totalDependencies, object);
|
||||
diagramGraph.addTopLevel(task);
|
||||
this.planner.addTask(task);
|
||||
}
|
||||
for (DependencyBean dependencyBean : DomainDependency
|
||||
.toDependencyBeans(mapper, totalDependencies)) {
|
||||
this.diagramGraph.add(dependencyBean);
|
||||
for (Dependency dependency : DomainDependency
|
||||
.toDependencies(mapper, totalDependencies)) {
|
||||
this.diagramGraph.add(dependency);
|
||||
}
|
||||
this.diagramGraph.applyAllRestrictions();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ public class GanttPanel extends XulElement implements AfterCompose {
|
|||
@Override
|
||||
public void afterCompose() {
|
||||
tasksLists.afterCompose();
|
||||
dependencyList.setDependencies(tasksLists
|
||||
.asDependencies(diagramGraph.getVisibleDependencies()));
|
||||
dependencyList.setDependencyComponents(tasksLists
|
||||
.asDependencyComponents(diagramGraph.getVisibleDependencies()));
|
||||
timeTracker.afterCompose();
|
||||
dependencyList.afterCompose();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package org.zkoss.ganttz;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.zkoss.ganttz.data.TaskBean;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.HtmlMacroComponent;
|
||||
import org.zkoss.zul.Button;
|
||||
|
|
@ -14,7 +14,7 @@ import org.zkoss.zul.Button;
|
|||
*/
|
||||
public class LeftPane extends HtmlMacroComponent {
|
||||
|
||||
private final List<TaskBean> topLevelTasks;
|
||||
private final List<Task> topLevelTasks;
|
||||
|
||||
private List<? extends CommandContextualized<?>> commands;
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ public class LeftPane extends HtmlMacroComponent {
|
|||
|
||||
public LeftPane(
|
||||
List<? extends CommandContextualized<?>> contextualizedCommands,
|
||||
List<TaskBean> topLevelTasks) {
|
||||
List<Task> topLevelTasks) {
|
||||
this.commands = contextualizedCommands;
|
||||
this.topLevelTasks = topLevelTasks;
|
||||
}
|
||||
|
|
@ -61,11 +61,11 @@ public class LeftPane extends HtmlMacroComponent {
|
|||
return commandsContainer;
|
||||
}
|
||||
|
||||
public void taskRemoved(TaskBean taskBean) {
|
||||
leftTasksTree.taskRemoved(taskBean);
|
||||
public void taskRemoved(Task task) {
|
||||
leftTasksTree.taskRemoved(task);
|
||||
}
|
||||
|
||||
public void addTask(TaskBean newTask) {
|
||||
public void addTask(Task newTask) {
|
||||
leftTasksTree.addTask(newTask);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import java.util.Set;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.zkoss.ganttz.LeftTasksTreeRow.ILeftTasksTreeNavigator;
|
||||
import org.zkoss.ganttz.data.TaskBean;
|
||||
import org.zkoss.ganttz.data.TaskContainerBean;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.ganttz.data.TaskContainer;
|
||||
import org.zkoss.ganttz.util.MutableTreeModel;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
|
@ -32,15 +32,15 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
|
||||
private final class TaskBeanRenderer implements TreeitemRenderer {
|
||||
public void render(Treeitem item, Object data) throws Exception {
|
||||
TaskBean taskBean = (TaskBean) data;
|
||||
item.setOpen(isOpened(taskBean));
|
||||
Task task = (Task) data;
|
||||
item.setOpen(isOpened(task));
|
||||
final int[] path = tasksTreeModel.getPath(tasksTreeModel.getRoot(),
|
||||
taskBean);
|
||||
task);
|
||||
String cssClass = "depth_" + path.length;
|
||||
LeftTasksTreeRow leftTasksTreeRow = LeftTasksTreeRow.create(taskBean,
|
||||
new TreeNavigator(tasksTreeModel, taskBean));
|
||||
if (taskBean.isContainer()) {
|
||||
expandWhenOpened((TaskContainerBean) taskBean, item);
|
||||
LeftTasksTreeRow leftTasksTreeRow = LeftTasksTreeRow.create(task,
|
||||
new TreeNavigator(tasksTreeModel, task));
|
||||
if (task.isContainer()) {
|
||||
expandWhenOpened((TaskContainer) task, item);
|
||||
}
|
||||
Component row = Executions.getCurrent().createComponents(
|
||||
"~./ganttz/zul/leftTasksTreeRow.zul", item, null);
|
||||
|
|
@ -51,10 +51,10 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
for (Treecell cell : treeCells) {
|
||||
cell.setSclass(cssClass);
|
||||
}
|
||||
detailsForBeans.put(taskBean, leftTasksTreeRow);
|
||||
detailsForBeans.put(task, leftTasksTreeRow);
|
||||
}
|
||||
|
||||
private void expandWhenOpened(final TaskContainerBean taskBean,
|
||||
private void expandWhenOpened(final TaskContainer taskBean,
|
||||
Treeitem item) {
|
||||
item.addEventListener("onOpen", new EventListener() {
|
||||
@Override
|
||||
|
|
@ -67,28 +67,28 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
|
||||
}
|
||||
|
||||
public boolean isOpened(TaskBean taskBean) {
|
||||
return taskBean.isLeaf() || taskBean.isExpanded();
|
||||
public boolean isOpened(Task task) {
|
||||
return task.isLeaf() || task.isExpanded();
|
||||
}
|
||||
|
||||
private final class DetailsForBeans {
|
||||
private Map<TaskBean, LeftTasksTreeRow> map = new HashMap<TaskBean, LeftTasksTreeRow>();
|
||||
private Map<Task, LeftTasksTreeRow> map = new HashMap<Task, LeftTasksTreeRow>();
|
||||
|
||||
private Set<TaskBean> focusRequested = new HashSet<TaskBean>();
|
||||
private Set<Task> focusRequested = new HashSet<Task>();
|
||||
|
||||
public void put(TaskBean taskBean, LeftTasksTreeRow leftTasksTreeRow) {
|
||||
map.put(taskBean, leftTasksTreeRow);
|
||||
if (focusRequested.contains(taskBean)) {
|
||||
focusRequested.remove(taskBean);
|
||||
public void put(Task task, LeftTasksTreeRow leftTasksTreeRow) {
|
||||
map.put(task, leftTasksTreeRow);
|
||||
if (focusRequested.contains(task)) {
|
||||
focusRequested.remove(task);
|
||||
leftTasksTreeRow.receiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
public void requestFocusFor(TaskBean taskBean) {
|
||||
focusRequested.add(taskBean);
|
||||
public void requestFocusFor(Task task) {
|
||||
focusRequested.add(task);
|
||||
}
|
||||
|
||||
public LeftTasksTreeRow get(TaskBean taskbean) {
|
||||
public LeftTasksTreeRow get(Task taskbean) {
|
||||
return map.get(taskbean);
|
||||
}
|
||||
|
||||
|
|
@ -98,9 +98,9 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
|
||||
private final class TreeNavigator implements ILeftTasksTreeNavigator {
|
||||
private final int[] pathToNode;
|
||||
private final TaskBean task;
|
||||
private final Task task;
|
||||
|
||||
private TreeNavigator(TreeModel treemodel, TaskBean task) {
|
||||
private TreeNavigator(TreeModel treemodel, Task task) {
|
||||
this.task = task;
|
||||
this.pathToNode = tasksTreeModel.getPath(tasksTreeModel.getRoot(),
|
||||
task);
|
||||
|
|
@ -108,7 +108,7 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
|
||||
@Override
|
||||
public LeftTasksTreeRow getAboveRow() {
|
||||
TaskBean parent = getParent(pathToNode);
|
||||
Task parent = getParent(pathToNode);
|
||||
int lastPosition = pathToNode[pathToNode.length - 1];
|
||||
if (lastPosition != 0) {
|
||||
return getChild(parent, lastPosition - 1);
|
||||
|
|
@ -118,12 +118,12 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
return null;
|
||||
}
|
||||
|
||||
private LeftTasksTreeRow getChild(TaskBean parent, int position) {
|
||||
TaskBean child = tasksTreeModel.getChild(parent, position);
|
||||
private LeftTasksTreeRow getChild(Task parent, int position) {
|
||||
Task child = tasksTreeModel.getChild(parent, position);
|
||||
return getDetailFor(child);
|
||||
}
|
||||
|
||||
private LeftTasksTreeRow getDetailFor(TaskBean child) {
|
||||
private LeftTasksTreeRow getDetailFor(Task child) {
|
||||
return detailsForBeans.get(child);
|
||||
}
|
||||
|
||||
|
|
@ -142,12 +142,12 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<ChildAndParent> group(TaskBean origin,
|
||||
List<TaskBean> parents) {
|
||||
public List<ChildAndParent> group(Task origin,
|
||||
List<Task> parents) {
|
||||
ArrayList<ChildAndParent> result = new ArrayList<ChildAndParent>();
|
||||
TaskBean child = origin;
|
||||
TaskBean parent;
|
||||
ListIterator<TaskBean> listIterator = parents.listIterator();
|
||||
Task child = origin;
|
||||
Task parent;
|
||||
ListIterator<Task> listIterator = parents.listIterator();
|
||||
while (listIterator.hasNext()) {
|
||||
parent = listIterator.next();
|
||||
result.add(new ChildAndParent(child, parent));
|
||||
|
|
@ -157,18 +157,18 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
private class ChildAndParent {
|
||||
private final TaskBean parent;
|
||||
private final Task parent;
|
||||
|
||||
private final TaskBean child;
|
||||
private final Task child;
|
||||
|
||||
private Integer positionOfChildCached;
|
||||
|
||||
private ChildAndParent(TaskBean child, TaskBean parent) {
|
||||
private ChildAndParent(Task child, Task parent) {
|
||||
this.parent = parent;
|
||||
this.child = child;
|
||||
}
|
||||
|
||||
public TaskBean getNextToChild() {
|
||||
public Task getNextToChild() {
|
||||
return tasksTreeModel
|
||||
.getChild(parent, getPositionOfChild() + 1);
|
||||
}
|
||||
|
|
@ -197,8 +197,8 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
return task.isContainer() && task.isExpanded();
|
||||
}
|
||||
|
||||
private TaskBean getParent(int[] path) {
|
||||
TaskBean current = tasksTreeModel.getRoot();
|
||||
private Task getParent(int[] path) {
|
||||
Task current = tasksTreeModel.getRoot();
|
||||
for (int i = 0; i < path.length - 1; i++) {
|
||||
current = tasksTreeModel.getChild(current, path[i]);
|
||||
}
|
||||
|
|
@ -211,30 +211,30 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
|
||||
private TaskRemovedListener taskRemovedListener;
|
||||
|
||||
private final List<TaskBean> taskBeans;
|
||||
private final List<Task> tasks;
|
||||
|
||||
private MutableTreeModel<TaskBean> tasksTreeModel;
|
||||
private MutableTreeModel<Task> tasksTreeModel;
|
||||
|
||||
private Tree tasksTree;
|
||||
|
||||
private CommandContextualized<?> goingDownInLastArrowCommand;
|
||||
|
||||
public LeftTasksTree(List<TaskBean> taskBeans) {
|
||||
this.taskBeans = taskBeans;
|
||||
public LeftTasksTree(List<Task> tasks) {
|
||||
this.tasks = tasks;
|
||||
}
|
||||
|
||||
private static void fillModel(MutableTreeModel<TaskBean> treeModel,
|
||||
List<TaskBean> taskBeans) {
|
||||
for (TaskBean taskBean : taskBeans) {
|
||||
fillModel(treeModel, treeModel.getRoot(), taskBean);
|
||||
private static void fillModel(MutableTreeModel<Task> treeModel,
|
||||
List<Task> tasks) {
|
||||
for (Task task : tasks) {
|
||||
fillModel(treeModel, treeModel.getRoot(), task);
|
||||
}
|
||||
}
|
||||
|
||||
private static void fillModel(MutableTreeModel<TaskBean> treeModel,
|
||||
TaskBean parent, TaskBean node) {
|
||||
private static void fillModel(MutableTreeModel<Task> treeModel,
|
||||
Task parent, Task node) {
|
||||
treeModel.add(parent, node);
|
||||
if (node.isContainer()) {
|
||||
for (TaskBean child : node.getTasks()) {
|
||||
for (Task child : node.getTasks()) {
|
||||
fillModel(treeModel, node, child);
|
||||
}
|
||||
}
|
||||
|
|
@ -244,7 +244,7 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
return (Planner) getParent();
|
||||
}
|
||||
|
||||
public void taskRemoved(TaskBean taskRemoved) {
|
||||
public void taskRemoved(Task taskRemoved) {
|
||||
tasksTreeModel.remove(taskRemoved);
|
||||
}
|
||||
|
||||
|
|
@ -260,15 +260,15 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
setClass("listdetails");
|
||||
super.afterCompose();
|
||||
tasksTree = (Tree) getFellow("tasksTree");
|
||||
tasksTreeModel = MutableTreeModel.create(TaskBean.class);
|
||||
fillModel(tasksTreeModel, taskBeans);
|
||||
tasksTreeModel = MutableTreeModel.create(Task.class);
|
||||
fillModel(tasksTreeModel, tasks);
|
||||
tasksTree.setModel(tasksTreeModel);
|
||||
tasksTree.setTreeitemRenderer(new TaskBeanRenderer());
|
||||
}
|
||||
|
||||
void addTask(TaskBean taskBean) {
|
||||
detailsForBeans.requestFocusFor(taskBean);
|
||||
tasksTreeModel.add(tasksTreeModel.getRoot(), taskBean);
|
||||
void addTask(Task task) {
|
||||
detailsForBeans.requestFocusFor(task);
|
||||
tasksTreeModel.add(tasksTreeModel.getRoot(), task);
|
||||
}
|
||||
|
||||
public CommandContextualized<?> getGoingDownInLastArrowCommand() {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.zkoss.ganttz.data.TaskBean;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.util.Locales;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
|
|
@ -31,7 +31,7 @@ public class LeftTasksTreeRow extends GenericForwardComposer {
|
|||
|
||||
private static final Log LOG = LogFactory.getLog(LeftTasksTreeRow.class);
|
||||
|
||||
private final TaskBean taskBean;
|
||||
private final Task task;
|
||||
|
||||
private Textbox nameBox;
|
||||
|
||||
|
|
@ -47,21 +47,21 @@ public class LeftTasksTreeRow extends GenericForwardComposer {
|
|||
|
||||
private final ILeftTasksTreeNavigator leftTasksTreeNavigator;
|
||||
|
||||
public static LeftTasksTreeRow create(TaskBean bean,
|
||||
public static LeftTasksTreeRow create(Task bean,
|
||||
ILeftTasksTreeNavigator taskDetailnavigator) {
|
||||
return new LeftTasksTreeRow(bean, taskDetailnavigator);
|
||||
}
|
||||
|
||||
private LeftTasksTreeRow(TaskBean task,
|
||||
private LeftTasksTreeRow(Task task,
|
||||
ILeftTasksTreeNavigator leftTasksTreeNavigator) {
|
||||
this.taskBean = task;
|
||||
this.task = task;
|
||||
this.dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locales
|
||||
.getCurrent());
|
||||
this.leftTasksTreeNavigator = leftTasksTreeNavigator;
|
||||
}
|
||||
|
||||
public TaskBean getTaskBean() {
|
||||
return taskBean;
|
||||
public Task getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
public Textbox getNameBox() {
|
||||
|
|
@ -91,8 +91,8 @@ public class LeftTasksTreeRow extends GenericForwardComposer {
|
|||
this.endDateBox.setFormat("dd/MM/yyyy");
|
||||
}
|
||||
|
||||
public TaskBean getData() {
|
||||
return taskBean;
|
||||
public Task getData() {
|
||||
return task;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -216,7 +216,7 @@ public class LeftTasksTreeRow extends GenericForwardComposer {
|
|||
findComponents((Treerow) component);
|
||||
registerListeners();
|
||||
updateComponents();
|
||||
taskBean
|
||||
task
|
||||
.addFundamentalPropertiesChangeListener(new PropertyChangeListener() {
|
||||
|
||||
@Override
|
||||
|
|
@ -333,19 +333,19 @@ public class LeftTasksTreeRow extends GenericForwardComposer {
|
|||
Date begin = getStartDateBox().getValue();
|
||||
Date end = getEndDateBox().getValue();
|
||||
if (end.before(begin)) {
|
||||
end = new Date(begin.getTime() + taskBean.getLengthMilliseconds());
|
||||
end = new Date(begin.getTime() + task.getLengthMilliseconds());
|
||||
}
|
||||
taskBean.setName(getNameBox().getValue());
|
||||
taskBean.setBeginDate(begin);
|
||||
taskBean.setEndDate(end);
|
||||
task.setName(getNameBox().getValue());
|
||||
task.setBeginDate(begin);
|
||||
task.setEndDate(end);
|
||||
}
|
||||
|
||||
private void updateComponents() {
|
||||
getNameBox().setValue(taskBean.getName());
|
||||
getStartDateBox().setValue(taskBean.getBeginDate());
|
||||
getEndDateBox().setValue(taskBean.getEndDate());
|
||||
getStartDateTextBox().setValue(asString(taskBean.getBeginDate()));
|
||||
getEndDateTextBox().setValue(asString(taskBean.getEndDate()));
|
||||
getNameBox().setValue(task.getName());
|
||||
getStartDateBox().setValue(task.getBeginDate());
|
||||
getEndDateBox().setValue(task.getEndDate());
|
||||
getStartDateTextBox().setValue(asString(task.getBeginDate()));
|
||||
getEndDateTextBox().setValue(asString(task.getEndDate()));
|
||||
}
|
||||
|
||||
private String asString(Date date) {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ import org.zkoss.ganttz.adapters.DomainDependency;
|
|||
import org.zkoss.ganttz.adapters.IAdapterToTaskFundamentalProperties;
|
||||
import org.zkoss.ganttz.adapters.IDomainAndBeansMapper;
|
||||
import org.zkoss.ganttz.adapters.PlannerConfiguration;
|
||||
import org.zkoss.ganttz.data.DependencyBean;
|
||||
import org.zkoss.ganttz.data.Dependency;
|
||||
import org.zkoss.ganttz.data.GanttDiagramGraph;
|
||||
import org.zkoss.ganttz.data.TaskBean;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.ganttz.extensions.ICommand;
|
||||
import org.zkoss.ganttz.extensions.IContext;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
|
|
@ -104,7 +104,7 @@ public class Planner extends XulElement {
|
|||
return taskEditFormComposer;
|
||||
}
|
||||
|
||||
public boolean canAddDependency(DependencyBean dependency) {
|
||||
public boolean canAddDependency(Dependency dependency) {
|
||||
return dependencyAdder.canAddDependency(dependency);
|
||||
}
|
||||
|
||||
|
|
@ -114,19 +114,19 @@ public class Planner extends XulElement {
|
|||
dependencyAddedListener = new DependencyAddedListener() {
|
||||
|
||||
@Override
|
||||
public void dependenceAdded(Dependency dependency) {
|
||||
getDependencyList().addDependency(dependency);
|
||||
diagramGraph.add(dependency.getDependencyBean());
|
||||
dependencyAdder.addDependency(dependency.getDependencyBean());
|
||||
public void dependenceAdded(DependencyComponent dependencyComponent) {
|
||||
getDependencyList().addDependencyComponent(dependencyComponent);
|
||||
diagramGraph.add(dependencyComponent.getDependency());
|
||||
dependencyAdder.addDependency(dependencyComponent.getDependency());
|
||||
}
|
||||
};
|
||||
taskList.addDependencyListener(dependencyAddedListener);
|
||||
taskRemovedListener = new TaskRemovedListener() {
|
||||
|
||||
@Override
|
||||
public void taskRemoved(Task taskRemoved) {
|
||||
diagramGraph.remove(taskRemoved.getTaskBean());
|
||||
leftPane.taskRemoved(taskRemoved.getTaskBean());
|
||||
public void taskComponentRemoved(TaskComponent taskComponentRemoved) {
|
||||
diagramGraph.remove(taskComponentRemoved.getTask());
|
||||
leftPane.taskRemoved(taskComponentRemoved.getTask());
|
||||
TaskList taskList = getTaskList();
|
||||
setHeight(getHeight());// forcing smart update
|
||||
taskList.adjustZoomColumnsHeight();
|
||||
|
|
@ -137,15 +137,15 @@ public class Planner extends XulElement {
|
|||
dependencyRemovedListener = new DependencyRemovedListener() {
|
||||
|
||||
@Override
|
||||
public void dependenceRemoved(Dependency dependency) {
|
||||
diagramGraph.remove(dependency);
|
||||
public void dependenceRemoved(DependencyComponent dependencyComponent) {
|
||||
diagramGraph.remove(dependencyComponent);
|
||||
}
|
||||
};
|
||||
getDependencyList().addDependencyRemovedListener(
|
||||
dependencyRemovedListener);
|
||||
}
|
||||
|
||||
public void addTask(TaskBean newTask) {
|
||||
public void addTask(Task newTask) {
|
||||
TaskList taskList = getTaskList();
|
||||
if (taskList != null && leftPane != null) {
|
||||
taskList.addTask(newTask);
|
||||
|
|
@ -165,11 +165,11 @@ public class Planner extends XulElement {
|
|||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public void addDependency(DependencyBean bean) {
|
||||
public void addDependency(Dependency bean) {
|
||||
adapter.addDependency(toDomainDependency(bean));
|
||||
}
|
||||
|
||||
private DomainDependency<T> toDomainDependency(DependencyBean bean) {
|
||||
private DomainDependency<T> toDomainDependency(Dependency bean) {
|
||||
T source = mapper.findAssociatedDomainObject(bean.getSource());
|
||||
T destination = mapper.findAssociatedDomainObject(bean
|
||||
.getDestination());
|
||||
|
|
@ -178,7 +178,7 @@ public class Planner extends XulElement {
|
|||
return dep;
|
||||
}
|
||||
|
||||
public boolean canAddDependency(DependencyBean bean) {
|
||||
public boolean canAddDependency(Dependency bean) {
|
||||
return adapter.canAddDependency(toDomainDependency(bean));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ import java.util.UUID;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.zkoss.ganttz.data.TaskBean;
|
||||
import org.zkoss.ganttz.data.TaskContainerBean;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.ganttz.data.TaskContainer;
|
||||
import org.zkoss.lang.Objects;
|
||||
import org.zkoss.xml.HTMLs;
|
||||
import org.zkoss.zk.au.AuRequest;
|
||||
|
|
@ -36,7 +36,7 @@ import org.zkoss.zul.Div;
|
|||
/**
|
||||
* @author javi
|
||||
*/
|
||||
public class Task extends Div implements AfterCompose {
|
||||
public class TaskComponent extends Div implements AfterCompose {
|
||||
|
||||
private static final int HEIGHT_PER_TASK = 10;
|
||||
private static final String STANDARD_TASK_COLOR = "#007bbe";
|
||||
|
|
@ -58,7 +58,7 @@ public class Task extends Div implements AfterCompose {
|
|||
|
||||
protected void process(AuRequest request) {
|
||||
|
||||
final Task ta = (Task) request.getComponent();
|
||||
final TaskComponent ta = (TaskComponent) request.getComponent();
|
||||
|
||||
if (ta == null) {
|
||||
throw new UiException(MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED,
|
||||
|
|
@ -84,7 +84,7 @@ public class Task extends Div implements AfterCompose {
|
|||
|
||||
protected void process(AuRequest request) {
|
||||
|
||||
final Task ta = (Task) request.getComponent();
|
||||
final TaskComponent ta = (TaskComponent) request.getComponent();
|
||||
|
||||
if (ta == null) {
|
||||
throw new UiException(MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED,
|
||||
|
|
@ -109,9 +109,9 @@ public class Task extends Div implements AfterCompose {
|
|||
|
||||
protected void process(AuRequest request) {
|
||||
|
||||
final Task task = (Task) request.getComponent();
|
||||
final TaskComponent taskComponent = (TaskComponent) request.getComponent();
|
||||
|
||||
if (task == null) {
|
||||
if (taskComponent == null) {
|
||||
throw new UiException(MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED,
|
||||
this);
|
||||
}
|
||||
|
|
@ -122,23 +122,23 @@ public class Task extends Div implements AfterCompose {
|
|||
throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA,
|
||||
new Object[] { Objects.toString(requestData), this });
|
||||
} else {
|
||||
task.doAddDependency(requestData[0]);
|
||||
Events.postEvent(new Event(getId(), task, request.getData()));
|
||||
taskComponent.doAddDependency(requestData[0]);
|
||||
Events.postEvent(new Event(getId(), taskComponent, request.getData()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static Task asTask(TaskBean taskBean, TaskList taskList) {
|
||||
if (taskBean.isContainer()) {
|
||||
return TaskContainer.asTask((TaskContainerBean) taskBean, taskList);
|
||||
public static TaskComponent asTaskComponent(Task task, TaskList taskList) {
|
||||
if (task.isContainer()) {
|
||||
return TaskContainerComponent.asTask((TaskContainer) task, taskList);
|
||||
}
|
||||
return new Task(taskBean);
|
||||
return new TaskComponent(task);
|
||||
}
|
||||
|
||||
public Task(TaskBean taskBean) {
|
||||
public TaskComponent(Task task) {
|
||||
setHeight(HEIGHT_PER_TASK + "px");
|
||||
setContext("idContextMenuTaskAssigment");
|
||||
this.taskBean = taskBean;
|
||||
this.task = task;
|
||||
setColor(STANDARD_TASK_COLOR);
|
||||
setId(UUID.randomUUID().toString());
|
||||
}
|
||||
|
|
@ -165,7 +165,7 @@ public class Task extends Div implements AfterCompose {
|
|||
}
|
||||
};
|
||||
}
|
||||
this.taskBean
|
||||
this.task
|
||||
.addFundamentalPropertiesChangeListener(propertiesListener);
|
||||
updateClass();
|
||||
}
|
||||
|
|
@ -174,15 +174,15 @@ public class Task extends Div implements AfterCompose {
|
|||
|
||||
private List<WeakReference<DependencyAddedListener>> dependencyListeners = new LinkedList<WeakReference<DependencyAddedListener>>();
|
||||
|
||||
private final TaskBean taskBean;
|
||||
private final Task task;
|
||||
private PropertyChangeListener propertiesListener;
|
||||
|
||||
public TaskBean getTaskBean() {
|
||||
return taskBean;
|
||||
public Task getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
public String getTaskName() {
|
||||
return taskBean.getName();
|
||||
return task.getName();
|
||||
}
|
||||
|
||||
public String getLength() {
|
||||
|
|
@ -194,7 +194,7 @@ public class Task extends Div implements AfterCompose {
|
|||
listener));
|
||||
}
|
||||
|
||||
private void fireDependenceAdded(Dependency dependency) {
|
||||
private void fireDependenceAdded(DependencyComponent dependencyComponent) {
|
||||
ArrayList<DependencyAddedListener> active = new ArrayList<DependencyAddedListener>();
|
||||
synchronized (this) {
|
||||
ListIterator<WeakReference<DependencyAddedListener>> iterator = dependencyListeners
|
||||
|
|
@ -210,7 +210,7 @@ public class Task extends Div implements AfterCompose {
|
|||
}
|
||||
}
|
||||
for (DependencyAddedListener listener : active) {
|
||||
listener.dependenceAdded(dependency);
|
||||
listener.dependenceAdded(dependencyComponent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -230,19 +230,19 @@ public class Task extends Div implements AfterCompose {
|
|||
|
||||
// Command action to do
|
||||
void doUpdatePosition(String leftX, String topY) {
|
||||
this.taskBean.setBeginDate(getMapper().toDate(stripPx(leftX)));
|
||||
this.task.setBeginDate(getMapper().toDate(stripPx(leftX)));
|
||||
}
|
||||
|
||||
void doUpdateSize(String size) {
|
||||
int pixels = stripPx(size);
|
||||
this.taskBean.setLengthMilliseconds(getMapper().toMilliseconds(pixels));
|
||||
this.task.setLengthMilliseconds(getMapper().toMilliseconds(pixels));
|
||||
}
|
||||
|
||||
void doAddDependency(String destinyTaskId) {
|
||||
Dependency dependency = new Dependency(this,
|
||||
((Task) getFellow(destinyTaskId)));
|
||||
if (getPlanner().canAddDependency(dependency.getDependencyBean())) {
|
||||
fireDependenceAdded(dependency);
|
||||
DependencyComponent dependencyComponent = new DependencyComponent(this,
|
||||
((TaskComponent) getFellow(destinyTaskId)));
|
||||
if (getPlanner().canAddDependency(dependencyComponent.getDependency())) {
|
||||
fireDependenceAdded(dependencyComponent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -312,11 +312,11 @@ public class Task extends Div implements AfterCompose {
|
|||
|
||||
private void updateProperties() {
|
||||
setLeft("0");
|
||||
setLeft(getMapper().toPixels(this.taskBean.getBeginDate()) + "px");
|
||||
setLeft(getMapper().toPixels(this.task.getBeginDate()) + "px");
|
||||
setWidth("0");
|
||||
setWidth(getMapper().toPixels(this.taskBean.getLengthMilliseconds())
|
||||
setWidth(getMapper().toPixels(this.task.getLengthMilliseconds())
|
||||
+ "px");
|
||||
smartUpdate("name", this.taskBean.getName());
|
||||
smartUpdate("name", this.task.getName());
|
||||
DependencyList dependencyList = getDependencyList();
|
||||
if (dependencyList != null) {
|
||||
dependencyList.redrawDependenciesConnectedTo(this);
|
||||
|
|
@ -332,15 +332,15 @@ public class Task extends Div implements AfterCompose {
|
|||
}
|
||||
|
||||
public void remove() {
|
||||
getTaskList().removeTask(this);
|
||||
getTaskList().removeTaskComponent(this);
|
||||
}
|
||||
|
||||
void publishTasks(Map<TaskBean, Task> resultAccumulated) {
|
||||
resultAccumulated.put(getTaskBean(), this);
|
||||
void publishTaskComponents(Map<Task, TaskComponent> resultAccumulated) {
|
||||
resultAccumulated.put(getTask(), this);
|
||||
publishDescendants(resultAccumulated);
|
||||
}
|
||||
|
||||
protected void publishDescendants(Map<TaskBean, Task> resultAccumulated) {
|
||||
protected void publishDescendants(Map<Task, TaskComponent> resultAccumulated) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
package org.zkoss.ganttz;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.zkoss.ganttz.data.TaskBean;
|
||||
import org.zkoss.ganttz.data.TaskContainerBean;
|
||||
import org.zkoss.ganttz.data.TaskContainerBean.IExpandListener;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.ext.AfterCompose;
|
||||
|
||||
/**
|
||||
* This class contains the information of a task container. It can be modified
|
||||
* and notifies of the changes to the interested parties. <br/>
|
||||
* Created at Jul 1, 2009
|
||||
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
|
||||
*/
|
||||
public class TaskContainer extends Task implements AfterCompose {
|
||||
|
||||
public static TaskContainer asTask(TaskBean taskContainerBean,
|
||||
TaskList taskList) {
|
||||
return new TaskContainer((TaskContainerBean) taskContainerBean,
|
||||
taskList);
|
||||
}
|
||||
|
||||
private List<Task> subtasks = new ArrayList<Task>();
|
||||
final TaskList taskList;
|
||||
|
||||
private IExpandListener expandListener;
|
||||
|
||||
public TaskContainer(TaskContainerBean taskContainerBean, TaskList taskList) {
|
||||
super(taskContainerBean);
|
||||
if (!taskContainerBean.isContainer())
|
||||
throw new IllegalArgumentException();
|
||||
this.expandListener = new IExpandListener() {
|
||||
|
||||
@Override
|
||||
public void expandStateChanged(boolean isNowExpanded) {
|
||||
if (isNowExpanded) {
|
||||
open();
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
updateClass();
|
||||
}
|
||||
};
|
||||
taskContainerBean.addExpandListener(expandListener);
|
||||
this.taskList = taskList;
|
||||
for (TaskBean taskBean : taskContainerBean.getTasks()) {
|
||||
subtasks.add(Task.asTask(taskBean, taskList));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishDescendants(Map<TaskBean, Task> resultAccumulated) {
|
||||
for (Task task : subtasks) {
|
||||
task.publishTasks(resultAccumulated);
|
||||
}
|
||||
}
|
||||
|
||||
public void open() {
|
||||
Component previous = this;
|
||||
for (Task subtask : subtasks) {
|
||||
taskList.addTask(previous, subtask, true);
|
||||
previous = subtask;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isExpanded() {
|
||||
return getTaskContainerBean().isExpanded();
|
||||
}
|
||||
|
||||
private TaskContainerBean getTaskContainerBean() {
|
||||
return (TaskContainerBean) getTaskBean();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String calculateClass() {
|
||||
return super.calculateClass() +" "+ (getTaskContainerBean().isExpanded()?
|
||||
"expanded":"closed");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void close() {
|
||||
for (Task subtask : subtasks) {
|
||||
if (subtask instanceof TaskContainer) {
|
||||
TaskContainer container = (TaskContainer) subtask;
|
||||
container.close();
|
||||
}
|
||||
taskList.hideTask(subtask);
|
||||
taskList.redrawDependencies();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
package org.zkoss.ganttz;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.ganttz.data.TaskContainer;
|
||||
import org.zkoss.ganttz.data.TaskContainer.IExpandListener;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.ext.AfterCompose;
|
||||
|
||||
/**
|
||||
* This class contains the information of a task container. It can be modified
|
||||
* and notifies of the changes to the interested parties. <br/>
|
||||
* Created at Jul 1, 2009
|
||||
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
|
||||
*/
|
||||
public class TaskContainerComponent extends TaskComponent implements AfterCompose {
|
||||
|
||||
public static TaskContainerComponent asTask(Task taskContainerBean,
|
||||
TaskList taskList) {
|
||||
return new TaskContainerComponent((TaskContainer) taskContainerBean,
|
||||
taskList);
|
||||
}
|
||||
|
||||
private List<TaskComponent> subtaskComponents = new ArrayList<TaskComponent>();
|
||||
final TaskList taskList;
|
||||
|
||||
private IExpandListener expandListener;
|
||||
|
||||
public TaskContainerComponent(TaskContainer taskContainer, TaskList taskList) {
|
||||
super(taskContainer);
|
||||
if (!taskContainer.isContainer())
|
||||
throw new IllegalArgumentException();
|
||||
this.expandListener = new IExpandListener() {
|
||||
|
||||
@Override
|
||||
public void expandStateChanged(boolean isNowExpanded) {
|
||||
if (isNowExpanded) {
|
||||
open();
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
updateClass();
|
||||
}
|
||||
};
|
||||
taskContainer.addExpandListener(expandListener);
|
||||
this.taskList = taskList;
|
||||
for (Task task : taskContainer.getTasks()) {
|
||||
subtaskComponents.add(TaskComponent.asTaskComponent(task, taskList));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void publishDescendants(Map<Task, TaskComponent> resultAccumulated) {
|
||||
for (TaskComponent taskComponent : subtaskComponents) {
|
||||
taskComponent.publishTaskComponents(resultAccumulated);
|
||||
}
|
||||
}
|
||||
|
||||
public void open() {
|
||||
Component previous = this;
|
||||
for (TaskComponent subtaskComponent : subtaskComponents) {
|
||||
taskList.addTaskComponent(previous, subtaskComponent, true);
|
||||
previous = subtaskComponent;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isExpanded() {
|
||||
return getTaskContainer().isExpanded();
|
||||
}
|
||||
|
||||
private TaskContainer getTaskContainer() {
|
||||
return (TaskContainer) getTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String calculateClass() {
|
||||
return super.calculateClass() +" "+ (getTaskContainer().isExpanded()?
|
||||
"expanded":"closed");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void close() {
|
||||
for (TaskComponent subtaskComponent : subtaskComponents) {
|
||||
if (subtaskComponent instanceof TaskContainerComponent) {
|
||||
TaskContainerComponent container = (TaskContainerComponent) subtaskComponent;
|
||||
container.close();
|
||||
}
|
||||
taskList.hideTaskComponent(subtaskComponent);
|
||||
taskList.redrawDependencies();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package org.zkoss.ganttz;
|
|||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
import org.zkoss.ganttz.data.TaskBean;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
|
|
@ -19,7 +19,7 @@ public class TaskEditFormComposer extends GenericForwardComposer {
|
|||
|
||||
private Popup popUp;
|
||||
|
||||
private TaskBean currentTask;
|
||||
private Task currentTask;
|
||||
|
||||
private Textbox name;
|
||||
|
||||
|
|
@ -37,10 +37,10 @@ public class TaskEditFormComposer extends GenericForwardComposer {
|
|||
popUp = (Popup) comp;
|
||||
}
|
||||
|
||||
public void showEditFormFor(Task task) {
|
||||
public void showEditFormFor(TaskComponent taskComponent) {
|
||||
cleanListener();
|
||||
this.currentTask = task.getTaskBean();
|
||||
popUp.open(task, "after_start");
|
||||
this.currentTask = taskComponent.getTask();
|
||||
popUp.open(taskComponent, "after_start");
|
||||
propertyChangeListener = new PropertyChangeListener() {
|
||||
|
||||
@Override
|
||||
|
|
@ -61,7 +61,7 @@ public class TaskEditFormComposer extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateComponentValuesForTask(TaskBean currentTask) {
|
||||
private void updateComponentValuesForTask(Task currentTask) {
|
||||
// popUp.setTitle(currentTask.getName());
|
||||
name.setValue(currentTask.getName());
|
||||
startDateBox.setValue(currentTask.getBeginDate());
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import java.util.List;
|
|||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.zkoss.ganttz.data.DependencyBean;
|
||||
import org.zkoss.ganttz.data.TaskBean;
|
||||
import org.zkoss.ganttz.data.Dependency;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.ganttz.util.MenuBuilder;
|
||||
import org.zkoss.ganttz.util.WeakReferencedListeners;
|
||||
import org.zkoss.ganttz.util.MenuBuilder.ItemAction;
|
||||
|
|
@ -46,66 +46,66 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
|
||||
private Menupopup contextMenu;
|
||||
|
||||
private List<TaskBean> originalTasks;
|
||||
private List<Task> originalTasks;
|
||||
|
||||
private final TaskEditFormComposer taskEditFormComposer;
|
||||
|
||||
public TaskList(TaskEditFormComposer formComposer, List<TaskBean> tasks) {
|
||||
public TaskList(TaskEditFormComposer formComposer, List<Task> tasks) {
|
||||
this.taskEditFormComposer = formComposer;
|
||||
this.originalTasks = tasks;
|
||||
}
|
||||
|
||||
public static TaskList createFor(TaskEditFormComposer formComposer,
|
||||
List<TaskBean> tasks) {
|
||||
List<Task> tasks) {
|
||||
TaskList result = new TaskList(formComposer, tasks);
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Dependency> asDependencies(List<DependencyBean> dependencies) {
|
||||
public List<DependencyComponent> asDependencyComponents(List<Dependency> dependencies) {
|
||||
List<? extends Object> children = getChildren();
|
||||
List<Task> tasks = Planner.findComponentsOfType(Task.class, children);
|
||||
Map<TaskBean, Task> taskByTaskBean = new HashMap<TaskBean, Task>();
|
||||
for (Task task : tasks) {
|
||||
task.publishTasks(taskByTaskBean);
|
||||
List<TaskComponent> taskComponents = Planner.findComponentsOfType(TaskComponent.class, children);
|
||||
Map<Task, TaskComponent> taskComponentByTask = new HashMap<Task, TaskComponent>();
|
||||
for (TaskComponent taskComponent : taskComponents) {
|
||||
taskComponent.publishTaskComponents(taskComponentByTask);
|
||||
}
|
||||
List<Dependency> result = new ArrayList<Dependency>();
|
||||
for (DependencyBean dependencyBean : dependencies) {
|
||||
result.add(new Dependency(taskByTaskBean.get(dependencyBean
|
||||
.getSource()), taskByTaskBean.get(dependencyBean
|
||||
List<DependencyComponent> result = new ArrayList<DependencyComponent>();
|
||||
for (Dependency dependency : dependencies) {
|
||||
result.add(new DependencyComponent(taskComponentByTask.get(dependency
|
||||
.getSource()), taskComponentByTask.get(dependency
|
||||
.getDestination())));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addTask(TaskBean newTask) {
|
||||
addTask(Task.asTask(newTask, this), true);
|
||||
public void addTask(Task newTask) {
|
||||
addTaskComponent(TaskComponent.asTaskComponent(newTask, this), true);
|
||||
}
|
||||
|
||||
public synchronized void addTask(Component afterThis, final Task task,
|
||||
public synchronized void addTaskComponent(Component afterThis, final TaskComponent taskComponent,
|
||||
boolean relocate) {
|
||||
insertBefore(task, afterThis == null ? null : afterThis
|
||||
insertBefore(taskComponent, afterThis == null ? null : afterThis
|
||||
.getNextSibling());
|
||||
addContextMenu(task);
|
||||
addListenerForTaskEditForm(task);
|
||||
addContextMenu(taskComponent);
|
||||
addListenerForTaskComponentEditForm(taskComponent);
|
||||
ListIterator<WeakReference<DependencyAddedListener>> iterator = listeners
|
||||
.listIterator();
|
||||
while (iterator.hasNext()) {
|
||||
DependencyAddedListener listener = iterator.next().get();
|
||||
if (listener != null) {
|
||||
task.addDependencyListener(listener);
|
||||
taskComponent.addDependencyListener(listener);
|
||||
} else {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
task.afterCompose();
|
||||
taskComponent.afterCompose();
|
||||
if (relocate) {
|
||||
response(null, new AuInvoke(task, "relocateAfterAdding"));
|
||||
response(null, new AuInvoke(taskComponent, "relocateAfterAdding"));
|
||||
setHeight(getHeight());// forcing smart update
|
||||
adjustZoomColumnsHeight();
|
||||
getGanttPanel().getDependencyList().redrawDependencies();
|
||||
}
|
||||
if (task instanceof TaskContainer) {
|
||||
TaskContainer container = (TaskContainer) task;
|
||||
if (taskComponent instanceof TaskContainerComponent) {
|
||||
TaskContainerComponent container = (TaskContainerComponent) taskComponent;
|
||||
if (container.isExpanded()) {
|
||||
container.open();
|
||||
}
|
||||
|
|
@ -113,27 +113,27 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
|
||||
}
|
||||
|
||||
public synchronized void addTask(final Task task, boolean relocate) {
|
||||
addTask(null, task, relocate);
|
||||
public synchronized void addTaskComponent(final TaskComponent taskComponent, boolean relocate) {
|
||||
addTaskComponent(null, taskComponent, relocate);
|
||||
}
|
||||
|
||||
private void addListenerForTaskEditForm(final Task task) {
|
||||
task.addEventListener("onDoubleClick", new EventListener() {
|
||||
private void addListenerForTaskComponentEditForm(final TaskComponent taskComponent) {
|
||||
taskComponent.addEventListener("onDoubleClick", new EventListener() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
taskEditFormComposer.showEditFormFor(task);
|
||||
taskEditFormComposer.showEditFormFor(taskComponent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addContextMenu(final Task task) {
|
||||
task.addEventListener("onRightClick", new EventListener() {
|
||||
private void addContextMenu(final TaskComponent taskComponent) {
|
||||
taskComponent.addEventListener("onRightClick", new EventListener() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
try {
|
||||
getContextMenuForTasks().open(task);
|
||||
getContextMenuForTasks().open(taskComponent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -145,14 +145,14 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
taskRemovedListeners.addListener(listener);
|
||||
}
|
||||
|
||||
public void removeTask(final Task task) {
|
||||
removeChild(task);
|
||||
task.detach();
|
||||
public void removeTaskComponent(final TaskComponent taskComponent) {
|
||||
removeChild(taskComponent);
|
||||
taskComponent.detach();
|
||||
taskRemovedListeners
|
||||
.fireEvent(new ListenerNotification<TaskRemovedListener>() {
|
||||
@Override
|
||||
public void doNotify(TaskRemovedListener listener) {
|
||||
listener.taskRemoved(task);
|
||||
listener.taskComponentRemoved(taskComponent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -170,18 +170,18 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
return getTimeTracker().getMapper();
|
||||
}
|
||||
|
||||
private List<Task> getTasks() {
|
||||
ArrayList<Task> result = new ArrayList<Task>();
|
||||
private List<TaskComponent> getTaskComponents() {
|
||||
ArrayList<TaskComponent> result = new ArrayList<TaskComponent>();
|
||||
for (Object child : getChildren()) {
|
||||
if (child instanceof Task) {
|
||||
result.add((Task) child);
|
||||
if (child instanceof TaskComponent) {
|
||||
result.add((TaskComponent) child);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getTasksNumber() {
|
||||
return getTasks().size();
|
||||
return getTaskComponents().size();
|
||||
}
|
||||
|
||||
public void addTaskRemovedListener(TaskRemovedListener taskRemovedListener) {
|
||||
|
|
@ -190,22 +190,22 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
|
||||
public void addDependencyListener(DependencyAddedListener listener) {
|
||||
listeners.add(new WeakReference<DependencyAddedListener>(listener));
|
||||
for (Task task : getTasks()) {
|
||||
task.addDependencyListener(listener);
|
||||
for (TaskComponent taskComponent : getTaskComponents()) {
|
||||
taskComponent.addDependencyListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompose() {
|
||||
for (TaskBean taskBean : originalTasks) {
|
||||
addTask(Task.asTask(taskBean, this), false);
|
||||
for (Task task : originalTasks) {
|
||||
addTaskComponent(TaskComponent.asTaskComponent(task, this), false);
|
||||
}
|
||||
if (zoomLevelChangedListener == null) {
|
||||
zoomLevelChangedListener = new ZoomLevelChangedListener() {
|
||||
@Override
|
||||
public void zoomLevelChanged(ZoomLevel detailLevel) {
|
||||
for (Task task : getTasks()) {
|
||||
task.zoomChanged();
|
||||
for (TaskComponent taskComponent : getTaskComponents()) {
|
||||
taskComponent.zoomChanged();
|
||||
}
|
||||
adjustZoomColumnsHeight();
|
||||
}
|
||||
|
|
@ -216,16 +216,16 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
|
||||
private Menupopup getContextMenuForTasks() {
|
||||
if (contextMenu == null) {
|
||||
contextMenu = MenuBuilder.on(getPage(), getTasks()).item(
|
||||
"Add Dependency", new ItemAction<Task>() {
|
||||
contextMenu = MenuBuilder.on(getPage(), getTaskComponents()).item(
|
||||
"Add Dependency", new ItemAction<TaskComponent>() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Task choosen, Event event) {
|
||||
public void onEvent(TaskComponent choosen, Event event) {
|
||||
choosen.addDependency();
|
||||
}
|
||||
}).item("Erase", new ItemAction<Task>() {
|
||||
}).item("Erase", new ItemAction<TaskComponent>() {
|
||||
@Override
|
||||
public void onEvent(Task choosen, Event event) {
|
||||
public void onEvent(TaskComponent choosen, Event event) {
|
||||
choosen.remove();
|
||||
}
|
||||
}).createWithoutSettingContext();
|
||||
|
|
@ -249,9 +249,9 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
response("adjust_height", new AuInvoke(TaskList.this, "adjust_height"));
|
||||
}
|
||||
|
||||
public void hideTask(Task subtask) {
|
||||
removeChild(subtask);
|
||||
subtask.setParent(null);
|
||||
public void hideTaskComponent(TaskComponent subtaskComponent) {
|
||||
removeChild(subtaskComponent);
|
||||
subtaskComponent.setParent(null);
|
||||
}
|
||||
|
||||
public void redrawDependencies() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ package org.zkoss.ganttz;
|
|||
|
||||
public interface TaskRemovedListener {
|
||||
|
||||
public void taskRemoved(Task taskRemoved);
|
||||
public void taskComponentRemoved(TaskComponent taskComponentRemoved);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.zkoss.ganttz.data.DependencyBean;
|
||||
import org.zkoss.ganttz.data.Dependency;
|
||||
import org.zkoss.ganttz.data.DependencyType;
|
||||
|
||||
/**
|
||||
|
|
@ -13,12 +13,12 @@ import org.zkoss.ganttz.data.DependencyType;
|
|||
*/
|
||||
public class DomainDependency<T> {
|
||||
|
||||
public static <T> List<DependencyBean> toDependencyBeans(
|
||||
public static <T> List<Dependency> toDependencies(
|
||||
IDomainAndBeansMapper<T> mapper,
|
||||
Collection<DomainDependency<T>> dependencies) {
|
||||
List<DependencyBean> result = new ArrayList<DependencyBean>();
|
||||
List<Dependency> result = new ArrayList<Dependency>();
|
||||
for (DomainDependency<T> domainDependency : dependencies) {
|
||||
result.add(domainDependency.toDependencyBean(mapper));
|
||||
result.add(domainDependency.toDependency(mapper));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -53,8 +53,8 @@ public class DomainDependency<T> {
|
|||
return type;
|
||||
}
|
||||
|
||||
public DependencyBean toDependencyBean(IDomainAndBeansMapper<T> mapper) {
|
||||
return new DependencyBean(mapper.findAssociatedBean(source), mapper
|
||||
public Dependency toDependency(IDomainAndBeansMapper<T> mapper) {
|
||||
return new Dependency(mapper.findAssociatedBean(source), mapper
|
||||
.findAssociatedBean(destination), type);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package org.zkoss.ganttz.adapters;
|
||||
|
||||
import org.zkoss.ganttz.data.TaskBean;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
|
||||
/**
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
|
|
@ -8,21 +8,21 @@ import org.zkoss.ganttz.data.TaskBean;
|
|||
public interface IDomainAndBeansMapper<T> {
|
||||
|
||||
/**
|
||||
* @param taskBean
|
||||
* @param task
|
||||
* @return the associated domain object
|
||||
* @throws IllegalArgumentException
|
||||
* if <code>taskBean</code> is null or not domain object found
|
||||
*/
|
||||
T findAssociatedDomainObject(TaskBean taskBean)
|
||||
T findAssociatedDomainObject(Task task)
|
||||
throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* @param domainObject
|
||||
* @return the associated {@link TaskBean}
|
||||
* @return the associated {@link Task}
|
||||
* @throws IllegalArgumentException
|
||||
* if <code>domainObject</code> is null or not {@link TaskBean}
|
||||
* if <code>domainObject</code> is null or not {@link Task}
|
||||
* is found
|
||||
*/
|
||||
TaskBean findAssociatedBean(T domainObject) throws IllegalArgumentException;
|
||||
Task findAssociatedBean(T domainObject) throws IllegalArgumentException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,25 +9,25 @@ import java.util.Date;
|
|||
* Created at Apr 24, 2009
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public class DependencyBean {
|
||||
public class Dependency {
|
||||
|
||||
private enum Calculation {
|
||||
START, END;
|
||||
}
|
||||
|
||||
public static Date calculateStart(TaskBean origin, Date current,
|
||||
Collection<? extends DependencyBean> dependencies) {
|
||||
public static Date calculateStart(Task origin, Date current,
|
||||
Collection<? extends Dependency> dependencies) {
|
||||
return apply(Calculation.START, origin, current, dependencies);
|
||||
}
|
||||
|
||||
public static Date calculateEnd(TaskBean origin, Date current,
|
||||
Collection<? extends DependencyBean> depencencies) {
|
||||
public static Date calculateEnd(Task origin, Date current,
|
||||
Collection<? extends Dependency> depencencies) {
|
||||
return apply(Calculation.END, origin, current, depencencies);
|
||||
}
|
||||
|
||||
private static Date apply(Calculation calculation, TaskBean origin,
|
||||
Date current, Collection<? extends DependencyBean> dependencies) {
|
||||
for (DependencyBean dependency : dependencies) {
|
||||
private static Date apply(Calculation calculation, Task origin,
|
||||
Date current, Collection<? extends Dependency> dependencies) {
|
||||
for (Dependency dependency : dependencies) {
|
||||
switch (calculation) {
|
||||
case START:
|
||||
current = dependency.getType().calculateStartDestinyTask(
|
||||
|
|
@ -45,15 +45,15 @@ public class DependencyBean {
|
|||
return current;
|
||||
}
|
||||
|
||||
private final TaskBean source;
|
||||
private final Task source;
|
||||
|
||||
private final TaskBean destination;
|
||||
private final Task destination;
|
||||
|
||||
private final DependencyType type;
|
||||
|
||||
private final boolean visible;
|
||||
|
||||
public DependencyBean(TaskBean source, TaskBean destination,
|
||||
public Dependency(Task source, Task destination,
|
||||
DependencyType type, boolean visible) {
|
||||
if (source == null)
|
||||
throw new IllegalArgumentException("source cannot be null");
|
||||
|
|
@ -67,7 +67,7 @@ public class DependencyBean {
|
|||
this.visible = visible;
|
||||
}
|
||||
|
||||
public DependencyBean(TaskBean source, TaskBean destination,
|
||||
public Dependency(Task source, Task destination,
|
||||
DependencyType type) {
|
||||
this(source, destination, type, true);
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ public class DependencyBean {
|
|||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
DependencyBean other = (DependencyBean) obj;
|
||||
Dependency other = (Dependency) obj;
|
||||
if (destination == null) {
|
||||
if (other.destination != null)
|
||||
return false;
|
||||
|
|
@ -104,11 +104,11 @@ public class DependencyBean {
|
|||
return true;
|
||||
}
|
||||
|
||||
public TaskBean getSource() {
|
||||
public Task getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public TaskBean getDestination() {
|
||||
public Task getDestination() {
|
||||
return destination;
|
||||
}
|
||||
|
||||
|
|
@ -12,24 +12,24 @@ public enum DependencyType {
|
|||
|
||||
VOID {
|
||||
@Override
|
||||
public Date calculateEndDestinyTask(TaskBean originalTask, Date current) {
|
||||
public Date calculateEndDestinyTask(Task originalTask, Date current) {
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date calculateStartDestinyTask(TaskBean originalTask,
|
||||
public Date calculateStartDestinyTask(Task originalTask,
|
||||
Date current) {
|
||||
return current;
|
||||
}
|
||||
},
|
||||
END_START {
|
||||
@Override
|
||||
public Date calculateEndDestinyTask(TaskBean originalTask, Date current) {
|
||||
public Date calculateEndDestinyTask(Task originalTask, Date current) {
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date calculateStartDestinyTask(TaskBean originalTask,
|
||||
public Date calculateStartDestinyTask(Task originalTask,
|
||||
Date current) {
|
||||
return getBigger(originalTask.getEndDate(), current);
|
||||
}
|
||||
|
|
@ -37,24 +37,24 @@ public enum DependencyType {
|
|||
START_START {
|
||||
|
||||
@Override
|
||||
public Date calculateEndDestinyTask(TaskBean originTask, Date current) {
|
||||
public Date calculateEndDestinyTask(Task originTask, Date current) {
|
||||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date calculateStartDestinyTask(TaskBean originTask, Date current) {
|
||||
public Date calculateStartDestinyTask(Task originTask, Date current) {
|
||||
return getBigger(originTask.getBeginDate(), current);
|
||||
}
|
||||
},
|
||||
END_END {
|
||||
|
||||
@Override
|
||||
public Date calculateEndDestinyTask(TaskBean originTask, Date current) {
|
||||
public Date calculateEndDestinyTask(Task originTask, Date current) {
|
||||
return getBigger(originTask.getEndDate(), current);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date calculateStartDestinyTask(TaskBean originTask, Date current) {
|
||||
public Date calculateStartDestinyTask(Task originTask, Date current) {
|
||||
return current;
|
||||
}
|
||||
};
|
||||
|
|
@ -65,9 +65,9 @@ public enum DependencyType {
|
|||
return date1;
|
||||
}
|
||||
|
||||
public abstract Date calculateEndDestinyTask(TaskBean originTask,
|
||||
public abstract Date calculateEndDestinyTask(Task originTask,
|
||||
Date current);
|
||||
|
||||
public abstract Date calculateStartDestinyTask(TaskBean originTask,
|
||||
public abstract Date calculateStartDestinyTask(Task originTask,
|
||||
Date current);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,42 +12,42 @@ import java.util.Set;
|
|||
|
||||
import org.jgrapht.DirectedGraph;
|
||||
import org.jgrapht.graph.SimpleDirectedGraph;
|
||||
import org.zkoss.ganttz.Dependency;
|
||||
import org.zkoss.ganttz.DependencyComponent;
|
||||
|
||||
/**
|
||||
* This class contains a graph with the {@link TaskBean tasks} as vertexes and
|
||||
* the {@link DependencyBean dependency} as arcs. It enforces the rules embodied
|
||||
* This class contains a graph with the {@link Task tasks} as vertexes and
|
||||
* the {@link Dependency dependency} as arcs. It enforces the rules embodied
|
||||
* in the dependencies and in the duration of the tasks using listeners. <br/>
|
||||
* Created at Apr 24, 2009
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public class GanttDiagramGraph {
|
||||
|
||||
private final DirectedGraph<TaskBean, DependencyBean> graph = new SimpleDirectedGraph<TaskBean, DependencyBean>(
|
||||
DependencyBean.class);
|
||||
private final DirectedGraph<Task, Dependency> graph = new SimpleDirectedGraph<Task, Dependency>(
|
||||
Dependency.class);
|
||||
|
||||
private Map<TaskBean, DependencyRulesEnforcer> rulesEnforcersByTask = new HashMap<TaskBean, DependencyRulesEnforcer>();
|
||||
private Map<Task, DependencyRulesEnforcer> rulesEnforcersByTask = new HashMap<Task, DependencyRulesEnforcer>();
|
||||
|
||||
private List<TaskBean> topLevelTasks = new ArrayList<TaskBean>();
|
||||
private List<Task> topLevelTasks = new ArrayList<Task>();
|
||||
|
||||
private List<DependencyRulesEnforcer> getOutgoing(TaskBean task) {
|
||||
private List<DependencyRulesEnforcer> getOutgoing(Task task) {
|
||||
ArrayList<DependencyRulesEnforcer> result = new ArrayList<DependencyRulesEnforcer>();
|
||||
for (DependencyBean dependencyBean : graph.outgoingEdgesOf(task)) {
|
||||
for (Dependency dependency : graph.outgoingEdgesOf(task)) {
|
||||
result.add(rulesEnforcersByTask
|
||||
.get(dependencyBean.getDestination()));
|
||||
.get(dependency.getDestination()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private class ParentShrinkingEnforcer {
|
||||
|
||||
private final TaskContainerBean container;
|
||||
private final TaskContainer container;
|
||||
|
||||
private ParentShrinkingEnforcer(final TaskContainerBean container) {
|
||||
private ParentShrinkingEnforcer(final TaskContainer container) {
|
||||
if (container == null)
|
||||
throw new IllegalArgumentException("container cannot be null");
|
||||
this.container = container;
|
||||
for (TaskBean subtask : this.container.getTasks()) {
|
||||
for (Task subtask : this.container.getTasks()) {
|
||||
subtask
|
||||
.addFundamentalPropertiesChangeListener(new PropertyChangeListener() {
|
||||
|
||||
|
|
@ -67,9 +67,9 @@ public class GanttDiagramGraph {
|
|||
}
|
||||
|
||||
private class DependencyRulesEnforcer {
|
||||
private final TaskBean task;
|
||||
private final Task task;
|
||||
|
||||
private DependencyRulesEnforcer(TaskBean task) {
|
||||
private DependencyRulesEnforcer(Task task) {
|
||||
if (task == null)
|
||||
throw new IllegalArgumentException("task cannot be null");
|
||||
this.task = task;
|
||||
|
|
@ -85,14 +85,14 @@ public class GanttDiagramGraph {
|
|||
}
|
||||
|
||||
void update() {
|
||||
Set<DependencyBean> incoming = graph.incomingEdgesOf(task);
|
||||
Set<Dependency> incoming = graph.incomingEdgesOf(task);
|
||||
Date beginDate = task.getBeginDate();
|
||||
Date newStart = DependencyBean.calculateStart(task, beginDate,
|
||||
Date newStart = Dependency.calculateStart(task, beginDate,
|
||||
incoming);
|
||||
if (!beginDate.equals(newStart))
|
||||
task.setBeginDate(newStart);
|
||||
Date endDate = task.getEndDate();
|
||||
Date newEnd = DependencyBean.calculateEnd(task, endDate, incoming);
|
||||
Date newEnd = Dependency.calculateEnd(task, endDate, incoming);
|
||||
if (!endDate.equals(newEnd)) {
|
||||
task.setEndDate(newEnd);
|
||||
}
|
||||
|
|
@ -106,34 +106,34 @@ public class GanttDiagramGraph {
|
|||
}
|
||||
}
|
||||
|
||||
public void addTopLevel(TaskBean task) {
|
||||
public void addTopLevel(Task task) {
|
||||
topLevelTasks.add(task);
|
||||
addTask(task);
|
||||
}
|
||||
|
||||
private void addTask(TaskBean task) {
|
||||
private void addTask(Task task) {
|
||||
graph.addVertex(task);
|
||||
rulesEnforcersByTask.put(task, new DependencyRulesEnforcer(task));
|
||||
if (task.isContainer()) {
|
||||
new ParentShrinkingEnforcer((TaskContainerBean) task);
|
||||
for (TaskBean child : task.getTasks()) {
|
||||
new ParentShrinkingEnforcer((TaskContainer) task);
|
||||
for (Task child : task.getTasks()) {
|
||||
addTask(child);
|
||||
add(new DependencyBean(child, task, DependencyType.END_END,
|
||||
add(new Dependency(child, task, DependencyType.END_END,
|
||||
false));
|
||||
add(new DependencyBean(task, child, DependencyType.START_START,
|
||||
add(new Dependency(task, child, DependencyType.START_START,
|
||||
false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(TaskBean task) {
|
||||
public void remove(Task task) {
|
||||
List<DependencyRulesEnforcer> outgoing = getOutgoing(task);
|
||||
graph.removeVertex(task);
|
||||
rulesEnforcersByTask.remove(task);
|
||||
update(outgoing);
|
||||
}
|
||||
|
||||
private void updateOutgoing(TaskBean task) {
|
||||
private void updateOutgoing(Task task) {
|
||||
update(getOutgoing(task));
|
||||
}
|
||||
|
||||
|
|
@ -143,39 +143,39 @@ public class GanttDiagramGraph {
|
|||
}
|
||||
}
|
||||
|
||||
public void remove(Dependency dependency) {
|
||||
graph.removeEdge(dependency.getDependencyBean());
|
||||
TaskBean destination = dependency.getDependencyBean().getDestination();
|
||||
public void remove(DependencyComponent dependencyComponent) {
|
||||
graph.removeEdge(dependencyComponent.getDependency());
|
||||
Task destination = dependencyComponent.getDependency().getDestination();
|
||||
rulesEnforcersByTask.get(destination).update();
|
||||
}
|
||||
|
||||
public void add(DependencyBean dependency) {
|
||||
TaskBean source = dependency.getSource();
|
||||
TaskBean destination = dependency.getDestination();
|
||||
public void add(Dependency dependency) {
|
||||
Task source = dependency.getSource();
|
||||
Task destination = dependency.getDestination();
|
||||
graph.addEdge(source, destination, dependency);
|
||||
getEnforcer(destination).update();
|
||||
}
|
||||
|
||||
private DependencyRulesEnforcer getEnforcer(TaskBean destination) {
|
||||
private DependencyRulesEnforcer getEnforcer(Task destination) {
|
||||
return rulesEnforcersByTask.get(destination);
|
||||
}
|
||||
|
||||
public List<TaskBean> getTasks() {
|
||||
return new ArrayList<TaskBean>(graph.vertexSet());
|
||||
public List<Task> getTasks() {
|
||||
return new ArrayList<Task>(graph.vertexSet());
|
||||
}
|
||||
|
||||
public List<DependencyBean> getVisibleDependencies() {
|
||||
Set<DependencyBean> edgeSet = graph.edgeSet();
|
||||
ArrayList<DependencyBean> result = new ArrayList<DependencyBean>();
|
||||
for (DependencyBean dependencyBean : edgeSet) {
|
||||
if (dependencyBean.isVisible()) {
|
||||
result.add(dependencyBean);
|
||||
public List<Dependency> getVisibleDependencies() {
|
||||
Set<Dependency> edgeSet = graph.edgeSet();
|
||||
ArrayList<Dependency> result = new ArrayList<Dependency>();
|
||||
for (Dependency dependency : edgeSet) {
|
||||
if (dependency.isVisible()) {
|
||||
result.add(dependency);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<TaskBean> getTopLevelTasks() {
|
||||
public List<Task> getTopLevelTasks() {
|
||||
return Collections.unmodifiableList(topLevelTasks);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import java.util.List;
|
|||
* Created at Apr 24, 2009
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public abstract class TaskBean implements ITaskFundamentalProperties {
|
||||
public abstract class Task implements ITaskFundamentalProperties {
|
||||
|
||||
private PropertyChangeSupport fundamentalPropertiesListeners = new PropertyChangeSupport(
|
||||
this);
|
||||
|
|
@ -23,15 +23,15 @@ public abstract class TaskBean implements ITaskFundamentalProperties {
|
|||
|
||||
private boolean visible = true;
|
||||
|
||||
public TaskBean(ITaskFundamentalProperties fundamentalProperties) {
|
||||
public Task(ITaskFundamentalProperties fundamentalProperties) {
|
||||
this.fundamentalProperties = fundamentalProperties;
|
||||
}
|
||||
|
||||
public TaskBean() {
|
||||
public Task() {
|
||||
this(new DefaultFundamentalProperties());
|
||||
}
|
||||
|
||||
public TaskBean(String name, Date beginDate, long lengthMilliseconds) {
|
||||
public Task(String name, Date beginDate, long lengthMilliseconds) {
|
||||
this();
|
||||
if (name == null)
|
||||
throw new IllegalArgumentException("name cannot be null");
|
||||
|
|
@ -54,7 +54,7 @@ public abstract class TaskBean implements ITaskFundamentalProperties {
|
|||
|
||||
public abstract boolean isExpanded() throws UnsupportedOperationException;
|
||||
|
||||
public abstract List<TaskBean> getTasks()
|
||||
public abstract List<Task> getTasks()
|
||||
throws UnsupportedOperationException;
|
||||
|
||||
public boolean isVisible() {
|
||||
|
|
@ -15,13 +15,13 @@ import org.zkoss.ganttz.util.WeakReferencedListeners.ListenerNotification;
|
|||
* Created at Jul 1, 2009
|
||||
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
|
||||
*/
|
||||
public class TaskContainerBean extends TaskBean {
|
||||
public class TaskContainer extends Task {
|
||||
|
||||
public TaskContainerBean() {
|
||||
public TaskContainer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TaskContainerBean(ITaskFundamentalProperties fundamentalProperties) {
|
||||
public TaskContainer(ITaskFundamentalProperties fundamentalProperties) {
|
||||
super(fundamentalProperties);
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ public class TaskContainerBean extends TaskBean {
|
|||
});
|
||||
}
|
||||
|
||||
private List<TaskBean> tasks = new ArrayList<TaskBean>();
|
||||
private List<Task> tasks = new ArrayList<Task>();
|
||||
|
||||
private boolean expanded = false;
|
||||
|
||||
|
|
@ -85,13 +85,13 @@ public class TaskContainerBean extends TaskBean {
|
|||
expandListeners.addListener(expandListener);
|
||||
}
|
||||
|
||||
public void add(TaskBean task) {
|
||||
public void add(Task task) {
|
||||
tasks.add(task);
|
||||
task.setVisible(expanded);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskBean> getTasks() {
|
||||
public List<Task> getTasks() {
|
||||
return tasks;
|
||||
}
|
||||
|
||||
|
|
@ -103,16 +103,16 @@ public class TaskContainerBean extends TaskBean {
|
|||
|
||||
private List<Date> getStartDates() {
|
||||
ArrayList<Date> result = new ArrayList<Date>();
|
||||
for (TaskBean taskBean : tasks) {
|
||||
result.add(taskBean.getBeginDate());
|
||||
for (Task task : tasks) {
|
||||
result.add(task.getBeginDate());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<Date> getEndDates() {
|
||||
ArrayList<Date> result = new ArrayList<Date>();
|
||||
for (TaskBean taskBean : tasks) {
|
||||
result.add(taskBean.getEndDate());
|
||||
for (Task task : tasks) {
|
||||
result.add(task.getEndDate());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -134,16 +134,16 @@ public class TaskContainerBean extends TaskBean {
|
|||
if (!this.expanded) {
|
||||
return;
|
||||
}
|
||||
for (TaskBean taskBean : tasks) {
|
||||
taskBean.setVisible(true);
|
||||
for (Task task : tasks) {
|
||||
task.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setExpanded(boolean expanded) {
|
||||
boolean valueChanged = expanded != this.expanded;
|
||||
this.expanded = expanded;
|
||||
for (TaskBean taskBean : tasks) {
|
||||
taskBean.setVisible(this.expanded);
|
||||
for (Task task : tasks) {
|
||||
task.setVisible(this.expanded);
|
||||
}
|
||||
if (valueChanged) {
|
||||
expandListeners
|
||||
|
|
@ -152,7 +152,7 @@ public class TaskContainerBean extends TaskBean {
|
|||
@Override
|
||||
public void doNotify(IExpandListener listener) {
|
||||
listener
|
||||
.expandStateChanged(TaskContainerBean.this.expanded);
|
||||
.expandStateChanged(TaskContainer.this.expanded);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -3,21 +3,21 @@ package org.zkoss.ganttz.data;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A {@link TaskBean} that can't have children
|
||||
* A {@link Task} that can't have children
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public class TaskLeafBean extends TaskBean {
|
||||
public class TaskLeaf extends Task {
|
||||
|
||||
public TaskLeafBean() {
|
||||
public TaskLeaf() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TaskLeafBean(ITaskFundamentalProperties fundamentalProperties) {
|
||||
public TaskLeaf(ITaskFundamentalProperties fundamentalProperties) {
|
||||
super(fundamentalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskBean> getTasks() throws UnsupportedOperationException {
|
||||
public List<Task> getTasks() throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
<component>
|
||||
<component-name>task</component-name>
|
||||
<component-class>org.zkoss.ganttz.Task</component-class>
|
||||
<component-class>org.zkoss.ganttz.TaskComponent</component-class>
|
||||
<mold>
|
||||
<mold-name>default</mold-name>
|
||||
<mold-uri>~./ganttz/task.dsp</mold-uri>
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
<component>
|
||||
<component-name>taskcontainer</component-name>
|
||||
<component-class>org.zkoss.ganttz.TaskContainer</component-class>
|
||||
<component-class>org.zkoss.ganttz.TaskContainerComponent</component-class>
|
||||
<mold>
|
||||
<mold-name>default</mold-name>
|
||||
<mold-uri>~./ganttz/taskcontainer.dsp</mold-uri>
|
||||
|
|
@ -79,7 +79,7 @@
|
|||
|
||||
<component>
|
||||
<component-name>dependency</component-name>
|
||||
<component-class>org.zkoss.ganttz.Dependency</component-class>
|
||||
<component-class>org.zkoss.ganttz.DependencyComponent</component-class>
|
||||
<mold>
|
||||
<mold-name>default</mold-name>
|
||||
<mold-uri>~./ganttz/dependency.dsp</mold-uri>
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ import org.zkoss.ganttz.data.DefaultFundamentalProperties;
|
|||
import org.zkoss.ganttz.data.DependencyType;
|
||||
import org.zkoss.ganttz.data.GanttDiagramGraph;
|
||||
import org.zkoss.ganttz.data.ITaskFundamentalProperties;
|
||||
import org.zkoss.ganttz.data.TaskBean;
|
||||
import org.zkoss.ganttz.data.TaskContainerBean;
|
||||
import org.zkoss.ganttz.data.TaskLeafBean;
|
||||
import org.zkoss.ganttz.data.Task;
|
||||
import org.zkoss.ganttz.data.TaskContainer;
|
||||
import org.zkoss.ganttz.data.TaskLeaf;
|
||||
import org.zkoss.ganttz.extensions.ICommand;
|
||||
import org.zkoss.ganttz.extensions.IContext;
|
||||
|
||||
|
|
@ -135,8 +135,8 @@ public class DataForPlanner {
|
|||
}, navigator, list);
|
||||
}
|
||||
|
||||
private TaskContainerBean createContainer(String name, Date start, Date end) {
|
||||
TaskContainerBean container = new TaskContainerBean();
|
||||
private TaskContainer createContainer(String name, Date start, Date end) {
|
||||
TaskContainer container = new TaskContainer();
|
||||
container.setBeginDate(start);
|
||||
container.setEndDate(end);
|
||||
container.setName(name);
|
||||
|
|
@ -150,7 +150,7 @@ public class DataForPlanner {
|
|||
}
|
||||
|
||||
private void addNewTask(IContext<ITaskFundamentalProperties> context) {
|
||||
TaskBean newTask = new TaskLeafBean();
|
||||
Task newTask = new TaskLeaf();
|
||||
newTask.setName("Nova Tarefa");
|
||||
newTask.setBeginDate(new Date());
|
||||
newTask.setEndDate(twoMonthsLater(newTask.getBeginDate()));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue