2009-10-01 18:46:46 +02:00
|
|
|
/*
|
2010-02-04 06:57:00 +01:00
|
|
|
* This file is part of NavalPlan
|
2009-10-01 18:46:46 +02:00
|
|
|
*
|
2010-07-19 09:36:44 +02:00
|
|
|
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
2010-07-19 09:47:20 +02:00
|
|
|
* Desenvolvemento Tecnolóxico de Galicia
|
2009-10-01 18:46:46 +02:00
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2009-04-14 17:51:03 +02:00
|
|
|
package org.zkoss.ganttz;
|
|
|
|
|
|
2009-12-07 21:43:05 +01:00
|
|
|
import static org.zkoss.ganttz.i18n.I18nHelper._;
|
|
|
|
|
|
2009-04-14 17:51:03 +02:00
|
|
|
import java.util.ArrayList;
|
2009-07-28 20:17:49 +02:00
|
|
|
import java.util.Arrays;
|
2009-07-20 15:37:40 +02:00
|
|
|
import java.util.Collection;
|
2010-01-19 13:15:37 +01:00
|
|
|
import java.util.HashMap;
|
2010-01-15 20:25:51 +01:00
|
|
|
import java.util.HashSet;
|
2009-04-14 17:51:03 +02:00
|
|
|
import java.util.List;
|
2010-01-15 20:25:51 +01:00
|
|
|
import java.util.Map;
|
2010-08-02 19:49:43 +02:00
|
|
|
import java.util.Set;
|
2010-08-10 14:31:19 +02:00
|
|
|
import java.util.Map.Entry;
|
2009-04-14 17:51:03 +02:00
|
|
|
|
2009-11-02 19:58:43 +01:00
|
|
|
import org.zkoss.ganttz.adapters.IDisabilityConfiguration;
|
2010-06-07 14:08:13 +02:00
|
|
|
import org.zkoss.ganttz.adapters.IDomainAndBeansMapper;
|
2009-07-16 10:40:57 +02:00
|
|
|
import org.zkoss.ganttz.adapters.PlannerConfiguration;
|
2009-07-20 18:00:11 +02:00
|
|
|
import org.zkoss.ganttz.data.Dependency;
|
2009-07-20 15:37:47 +02:00
|
|
|
import org.zkoss.ganttz.data.GanttDiagramGraph;
|
2010-08-02 19:49:43 +02:00
|
|
|
import org.zkoss.ganttz.data.Position;
|
|
|
|
|
import org.zkoss.ganttz.data.Task;
|
2010-08-10 14:31:19 +02:00
|
|
|
import org.zkoss.ganttz.data.GanttDiagramGraph.GanttZKDiagramGraph;
|
|
|
|
|
import org.zkoss.ganttz.data.GanttDiagramGraph.IGraphChangeListener;
|
2009-07-20 15:37:40 +02:00
|
|
|
import org.zkoss.ganttz.extensions.ICommand;
|
2009-07-22 18:43:31 +02:00
|
|
|
import org.zkoss.ganttz.extensions.ICommandOnTask;
|
2009-07-20 15:37:40 +02:00
|
|
|
import org.zkoss.ganttz.extensions.IContext;
|
2009-10-06 16:03:03 +02:00
|
|
|
import org.zkoss.ganttz.timetracker.TimeTracker;
|
2009-10-14 09:10:05 +02:00
|
|
|
import org.zkoss.ganttz.timetracker.TimeTrackerComponent;
|
|
|
|
|
import org.zkoss.ganttz.timetracker.TimeTrackerComponentWithoutColumns;
|
2009-12-28 11:08:33 +01:00
|
|
|
import org.zkoss.ganttz.timetracker.zoom.ZoomLevel;
|
2009-09-30 23:30:52 +02:00
|
|
|
import org.zkoss.ganttz.util.ComponentsFinder;
|
2009-12-07 21:43:05 +01:00
|
|
|
import org.zkoss.ganttz.util.LongOperationFeedback;
|
2009-08-31 16:58:07 +02:00
|
|
|
import org.zkoss.ganttz.util.OnZKDesktopRegistry;
|
2010-04-27 19:52:53 +02:00
|
|
|
import org.zkoss.ganttz.util.WeakReferencedListeners;
|
2010-08-10 14:31:19 +02:00
|
|
|
import org.zkoss.ganttz.util.LongOperationFeedback.ILongOperation;
|
2010-04-27 19:52:53 +02:00
|
|
|
import org.zkoss.ganttz.util.WeakReferencedListeners.IListenerNotification;
|
2009-09-01 11:30:02 +02:00
|
|
|
import org.zkoss.ganttz.util.script.IScriptsRegister;
|
2009-10-05 18:23:09 +02:00
|
|
|
import org.zkoss.zk.ui.Component;
|
2009-04-30 13:42:39 +02:00
|
|
|
import org.zkoss.zk.ui.Executions;
|
2009-10-02 18:28:55 +02:00
|
|
|
import org.zkoss.zk.ui.HtmlMacroComponent;
|
2010-03-24 09:22:45 +01:00
|
|
|
import org.zkoss.zk.ui.event.Event;
|
|
|
|
|
import org.zkoss.zk.ui.event.EventListener;
|
|
|
|
|
import org.zkoss.zk.ui.event.Events;
|
2009-12-08 03:36:09 +01:00
|
|
|
import org.zkoss.zk.ui.util.Clients;
|
2010-04-29 11:04:28 +02:00
|
|
|
import org.zkoss.zkex.zul.api.South;
|
2010-01-14 00:05:04 +01:00
|
|
|
import org.zkoss.zul.Button;
|
2009-12-28 11:08:33 +01:00
|
|
|
import org.zkoss.zul.ListModel;
|
2010-02-16 18:42:49 +01:00
|
|
|
import org.zkoss.zul.Listbox;
|
|
|
|
|
import org.zkoss.zul.Listitem;
|
2009-10-05 18:23:09 +02:00
|
|
|
import org.zkoss.zul.Separator;
|
2009-12-28 11:08:33 +01:00
|
|
|
import org.zkoss.zul.SimpleListModel;
|
2009-04-14 17:51:03 +02:00
|
|
|
|
2009-10-02 18:28:55 +02:00
|
|
|
public class Planner extends HtmlMacroComponent {
|
2009-04-14 17:51:03 +02:00
|
|
|
|
2009-12-05 19:53:38 +01:00
|
|
|
public static void registerNeededScripts() {
|
|
|
|
|
IScriptsRegister register = getScriptsRegister();
|
|
|
|
|
register.register(ScriptsRequiredByPlanner.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static IScriptsRegister getScriptsRegister() {
|
|
|
|
|
return OnZKDesktopRegistry.getLocatorFor(IScriptsRegister.class)
|
|
|
|
|
.retrieve();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-19 13:15:37 +01:00
|
|
|
public static boolean guessContainersExpandedByDefaultGivenPrintParameters(
|
|
|
|
|
Map<String, String> printParameters) {
|
|
|
|
|
return guessContainersExpandedByDefault(convertToURLParameters(printParameters));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Map<String, String[]> convertToURLParameters(
|
|
|
|
|
Map<String, String> printParameters) {
|
|
|
|
|
Map<String, String[]> result = new HashMap<String, String[]>();
|
|
|
|
|
for (Entry<String, String> each : printParameters.entrySet()) {
|
|
|
|
|
result.put(each.getKey(), new String[] { each.getValue() });
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-15 20:25:51 +01:00
|
|
|
public static boolean guessContainersExpandedByDefault(
|
|
|
|
|
Map<String, String[]> queryURLParameters) {
|
|
|
|
|
String[] values = queryURLParameters.get("expanded");
|
|
|
|
|
if (values == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return toLowercaseSet(values).contains("all");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Set<String> toLowercaseSet(String[] values) {
|
|
|
|
|
Set<String> result = new HashSet<String>();
|
|
|
|
|
for (String each : values) {
|
|
|
|
|
result.add(each.toLowerCase());
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-16 00:39:23 +02:00
|
|
|
private GanttZKDiagramGraph diagramGraph;
|
2009-08-18 12:26:56 +02:00
|
|
|
|
2009-07-20 15:37:40 +02:00
|
|
|
private LeftPane leftPane;
|
2009-07-16 10:40:58 +02:00
|
|
|
|
2009-06-15 21:48:54 +02:00
|
|
|
private GanttPanel ganttPanel;
|
|
|
|
|
|
2010-02-16 18:42:49 +01:00
|
|
|
private boolean fixedZoomByUser = false;
|
|
|
|
|
|
2009-07-22 18:43:31 +02:00
|
|
|
private List<? extends CommandContextualized<?>> contextualizedGlobalCommands;
|
2009-07-20 15:37:40 +02:00
|
|
|
|
2009-07-20 15:37:42 +02:00
|
|
|
private CommandContextualized<?> goingDownInLastArrowCommand;
|
|
|
|
|
|
2009-07-22 18:43:31 +02:00
|
|
|
private List<? extends CommandOnTaskContextualized<?>> commandsOnTasksContextualized;
|
|
|
|
|
|
2009-12-07 19:26:57 +01:00
|
|
|
private CommandOnTaskContextualized<?> doubleClickCommand;
|
2009-07-28 12:28:47 +02:00
|
|
|
|
2009-08-18 12:26:56 +02:00
|
|
|
private FunctionalityExposedForExtensions<?> context;
|
|
|
|
|
|
2009-11-04 00:36:09 +01:00
|
|
|
private transient IDisabilityConfiguration disabilityConfiguration;
|
2009-10-14 07:50:17 +02:00
|
|
|
|
2009-12-04 12:30:04 +01:00
|
|
|
private boolean isShowingCriticalPath = false;
|
|
|
|
|
|
2010-03-11 12:05:34 +01:00
|
|
|
private boolean isShowingLabels = false;
|
|
|
|
|
|
|
|
|
|
private boolean isShowingResources = false;
|
|
|
|
|
|
2010-02-05 14:19:58 +01:00
|
|
|
private ZoomLevel initialZoomLevel = null;
|
2010-01-15 00:28:36 +01:00
|
|
|
|
2010-02-05 16:55:10 +01:00
|
|
|
private Listbox listZoomLevels = null;
|
|
|
|
|
|
2010-04-27 19:52:53 +02:00
|
|
|
private WeakReferencedListeners<IChartVisibilityChangedListener> chartVisibilityListeners = WeakReferencedListeners
|
|
|
|
|
.create();
|
|
|
|
|
|
2009-04-14 17:51:03 +02:00
|
|
|
public Planner() {
|
2009-09-01 11:30:02 +02:00
|
|
|
registerNeededScripts();
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-29 17:40:02 +02:00
|
|
|
TaskList getTaskList() {
|
2009-11-03 20:38:03 +01:00
|
|
|
if (ganttPanel == null) {
|
2009-07-20 15:37:41 +02:00
|
|
|
return null;
|
2009-11-03 20:38:03 +01:00
|
|
|
}
|
2009-07-22 18:43:31 +02:00
|
|
|
List<Object> children = ganttPanel.getChildren();
|
2009-09-30 23:30:52 +02:00
|
|
|
return ComponentsFinder.findComponentsOfType(TaskList.class, children).get(0);
|
2009-04-14 17:51:03 +02:00
|
|
|
}
|
|
|
|
|
|
2010-01-18 14:57:57 +01:00
|
|
|
public int getTaskNumber() {
|
|
|
|
|
return getTaskList().getTasksNumber();
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-07 14:08:13 +02:00
|
|
|
private static int PIXELS_PER_TASK_LEVEL = 21;
|
|
|
|
|
private static int PIXELS_PER_CHARACTER = 5;
|
|
|
|
|
|
|
|
|
|
public int calculateMinimumWidthForTaskNameColumn(boolean expand) {
|
|
|
|
|
return calculateMinimumWidthForTaskNameColumn(expand, getTaskList().getAllTasks());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int calculateMinimumWidthForTaskNameColumn(boolean expand, List<Task> tasks) {
|
|
|
|
|
IDomainAndBeansMapper<?> mapper = getContext().getMapper();
|
|
|
|
|
int widest = 0;
|
|
|
|
|
for(Task task : tasks) {
|
|
|
|
|
int numberOfAncestors =
|
|
|
|
|
mapper.findPositionFor(task).getAncestors().size();
|
|
|
|
|
int numberOfCharacters = task.getName().length();
|
|
|
|
|
widest = Math.max(widest,
|
|
|
|
|
numberOfCharacters * PIXELS_PER_CHARACTER +
|
|
|
|
|
numberOfAncestors * PIXELS_PER_TASK_LEVEL);
|
|
|
|
|
if(expand && !task.isLeaf()) {
|
|
|
|
|
widest = Math.max(widest,
|
|
|
|
|
calculateMinimumWidthForTaskNameColumn(expand, task.getTasks()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return widest;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-19 13:15:37 +01:00
|
|
|
public int getAllTasksNumber() {
|
|
|
|
|
return diagramGraph.getTasks().size();
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-30 13:42:39 +02:00
|
|
|
public String getContextPath() {
|
|
|
|
|
return Executions.getCurrent().getContextPath();
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-29 18:35:19 +02:00
|
|
|
public DependencyList getDependencyList() {
|
2009-11-03 20:38:03 +01:00
|
|
|
if (ganttPanel == null) {
|
2009-07-26 16:17:52 +02:00
|
|
|
return null;
|
2009-11-03 20:38:03 +01:00
|
|
|
}
|
2009-06-15 21:48:54 +02:00
|
|
|
List<Object> children = ganttPanel.getChildren();
|
2009-09-30 23:30:52 +02:00
|
|
|
List<DependencyList> found = ComponentsFinder.findComponentsOfType(DependencyList.class,
|
2009-04-29 18:35:19 +02:00
|
|
|
children);
|
2009-11-03 20:38:03 +01:00
|
|
|
if (found.isEmpty()) {
|
2009-04-29 18:35:19 +02:00
|
|
|
return null;
|
2009-11-03 20:38:03 +01:00
|
|
|
}
|
2009-04-29 18:35:19 +02:00
|
|
|
return found.get(0);
|
2009-04-14 17:51:03 +02:00
|
|
|
}
|
|
|
|
|
|
2009-07-28 20:17:49 +02:00
|
|
|
public void addTasks(Position position, Collection<? extends Task> newTasks) {
|
2009-07-20 15:37:41 +02:00
|
|
|
TaskList taskList = getTaskList();
|
|
|
|
|
if (taskList != null && leftPane != null) {
|
2009-07-28 20:17:49 +02:00
|
|
|
taskList.addTasks(position, newTasks);
|
|
|
|
|
leftPane.addTasks(position, newTasks);
|
2009-07-16 10:40:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-28 20:17:49 +02:00
|
|
|
public void addTask(Position position, Task task) {
|
|
|
|
|
addTasks(position, Arrays.asList(task));
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-26 16:17:52 +02:00
|
|
|
void addDependencies(Collection<? extends Dependency> dependencies) {
|
|
|
|
|
DependencyList dependencyList = getDependencyList();
|
|
|
|
|
if (dependencyList == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (DependencyComponent d : getTaskList().asDependencyComponents(
|
|
|
|
|
dependencies)) {
|
|
|
|
|
dependencyList.addDependencyComponent(d);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-28 11:08:33 +01:00
|
|
|
public ListModel getZoomLevels() {
|
2010-05-21 09:54:39 +02:00
|
|
|
ZoomLevel[] selectableZoomlevels = { ZoomLevel.DETAIL_ONE,
|
|
|
|
|
ZoomLevel.DETAIL_TWO, ZoomLevel.DETAIL_THREE,
|
|
|
|
|
ZoomLevel.DETAIL_FOUR, ZoomLevel.DETAIL_FIVE };
|
|
|
|
|
return new SimpleListModel(selectableZoomlevels);
|
2009-12-28 11:08:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setZoomLevel(final ZoomLevel zoomLevel) {
|
|
|
|
|
if (ganttPanel == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-02-16 18:42:49 +01:00
|
|
|
this.fixedZoomByUser = true;
|
|
|
|
|
initialZoomLevel = zoomLevel;
|
2009-12-29 21:37:12 +01:00
|
|
|
ganttPanel.setZoomLevel(zoomLevel);
|
2009-12-28 11:08:33 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-05 18:09:13 +02:00
|
|
|
public void zoomIncrease() {
|
|
|
|
|
if (ganttPanel == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-12-07 21:43:05 +01:00
|
|
|
LongOperationFeedback.execute(ganttPanel, new ILongOperation() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getName() {
|
|
|
|
|
return _("increasing zoom");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doAction() throws Exception {
|
|
|
|
|
ganttPanel.zoomIncrease();
|
|
|
|
|
}
|
|
|
|
|
});
|
2009-10-05 18:09:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void zoomDecrease() {
|
|
|
|
|
if (ganttPanel == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-12-07 21:43:05 +01:00
|
|
|
LongOperationFeedback.execute(ganttPanel, new ILongOperation() {
|
|
|
|
|
@Override
|
|
|
|
|
public String getName() {
|
|
|
|
|
return _("decreasing zoom");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doAction() throws Exception {
|
|
|
|
|
ganttPanel.zoomDecrease();
|
|
|
|
|
}
|
|
|
|
|
});
|
2009-10-05 18:09:13 +02:00
|
|
|
}
|
|
|
|
|
|
2009-07-16 10:40:57 +02:00
|
|
|
public <T> void setConfiguration(PlannerConfiguration<T> configuration) {
|
2009-11-03 20:38:03 +01:00
|
|
|
if (configuration == null) {
|
2009-07-16 10:40:58 +02:00
|
|
|
return;
|
2009-11-03 20:38:03 +01:00
|
|
|
}
|
2010-03-24 09:22:45 +01:00
|
|
|
|
2010-05-15 18:05:21 +02:00
|
|
|
this.diagramGraph = GanttDiagramGraph.create(configuration
|
|
|
|
|
.getStartConstraints(), configuration.getEndConstraints(), configuration.isDependenciesConstraintsHavePriority());
|
2009-11-04 00:28:29 +01:00
|
|
|
FunctionalityExposedForExtensions<T> newContext = new FunctionalityExposedForExtensions<T>(
|
2010-01-11 14:00:37 +01:00
|
|
|
this, configuration, diagramGraph);
|
2010-05-27 10:58:09 +02:00
|
|
|
addGraphChangeListenersFromConfiguration(configuration);
|
2009-11-04 00:28:29 +01:00
|
|
|
this.contextualizedGlobalCommands = contextualize(newContext,
|
2009-07-22 18:43:31 +02:00
|
|
|
configuration.getGlobalCommands());
|
2009-11-04 00:28:29 +01:00
|
|
|
this.commandsOnTasksContextualized = contextualize(newContext,
|
2009-07-22 18:43:31 +02:00
|
|
|
configuration.getCommandsOnTasks());
|
2009-11-04 00:28:29 +01:00
|
|
|
goingDownInLastArrowCommand = contextualize(newContext, configuration
|
2009-07-20 15:37:42 +02:00
|
|
|
.getGoingDownInLastArrowCommand());
|
2009-12-07 19:26:57 +01:00
|
|
|
doubleClickCommand = contextualize(newContext, configuration
|
|
|
|
|
.getDoubleClickCommand());
|
2009-11-04 00:28:29 +01:00
|
|
|
this.context = newContext;
|
2009-11-02 19:58:43 +01:00
|
|
|
this.disabilityConfiguration = configuration;
|
2010-02-03 19:07:07 +01:00
|
|
|
resettingPreviousComponentsToNull();
|
2009-11-04 00:28:29 +01:00
|
|
|
newContext.add(configuration.getData());
|
2009-09-30 19:07:03 +02:00
|
|
|
setupComponents();
|
2009-10-02 18:28:56 +02:00
|
|
|
|
2009-10-14 00:20:56 +02:00
|
|
|
setAt("insertionPointLeftPanel", leftPane);
|
2009-10-02 18:28:56 +02:00
|
|
|
leftPane.afterCompose();
|
2009-10-14 00:20:56 +02:00
|
|
|
setAt("insertionPointRightPanel", ganttPanel);
|
2009-10-02 18:28:56 +02:00
|
|
|
ganttPanel.afterCompose();
|
2009-12-14 17:58:33 +01:00
|
|
|
leftPane.setGoingDownInLastArrowCommand(goingDownInLastArrowCommand);
|
2009-10-06 16:02:58 +02:00
|
|
|
|
2009-10-14 09:10:05 +02:00
|
|
|
TimeTrackerComponent timetrackerheader = new TimeTrackerComponentWithoutColumns(
|
2009-10-15 17:36:23 +02:00
|
|
|
ganttPanel.getTimeTracker(), "timetrackerheader");
|
2009-10-14 09:10:05 +02:00
|
|
|
|
|
|
|
|
setAt("insertionPointTimetracker", timetrackerheader);
|
|
|
|
|
timetrackerheader.afterCompose();
|
|
|
|
|
|
2009-10-06 16:02:58 +02:00
|
|
|
Component chartComponent = configuration.getChartComponent();
|
|
|
|
|
if (chartComponent != null) {
|
2009-10-14 13:14:14 +02:00
|
|
|
setAt("insertionPointChart", chartComponent);
|
2009-10-06 16:02:58 +02:00
|
|
|
}
|
2009-10-14 07:50:17 +02:00
|
|
|
|
2009-12-04 12:30:04 +01:00
|
|
|
if (!configuration.isCriticalPathEnabled()) {
|
|
|
|
|
Button showCriticalPathButton = (Button) getFellow("showCriticalPath");
|
|
|
|
|
showCriticalPathButton.setVisible(false);
|
2009-12-03 17:51:27 +01:00
|
|
|
}
|
2010-02-10 12:48:27 +01:00
|
|
|
if (!configuration.isExpandAllEnabled()) {
|
|
|
|
|
Button expandAllButton = (Button) getFellow("expandAll");
|
|
|
|
|
expandAllButton.setVisible(false);
|
|
|
|
|
}
|
2010-03-16 08:59:42 +01:00
|
|
|
if (!configuration.isFlattenTreeEnabled()) {
|
|
|
|
|
Button flattenTree = (Button) getFellow("flattenTree");
|
|
|
|
|
flattenTree.setVisible(false);
|
|
|
|
|
}
|
2010-02-05 16:55:10 +01:00
|
|
|
listZoomLevels.setSelectedIndex(getZoomLevel().ordinal());
|
2010-03-24 09:22:45 +01:00
|
|
|
|
2010-04-29 11:04:28 +02:00
|
|
|
this.visibleChart = configuration.isExpandPlanningViewCharts();
|
|
|
|
|
((South) getFellow("graphics")).setOpen(this.visibleChart);
|
2009-07-22 13:27:22 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-03 19:07:07 +01:00
|
|
|
private void resettingPreviousComponentsToNull() {
|
|
|
|
|
this.ganttPanel = null;
|
|
|
|
|
this.leftPane = null;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-14 00:20:56 +02:00
|
|
|
private void setAt(String insertionPointId, Component component) {
|
|
|
|
|
Component insertionPoint = getFellow(insertionPointId);
|
|
|
|
|
insertionPoint.getChildren().clear();
|
|
|
|
|
insertionPoint.appendChild(component);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-22 18:43:31 +02:00
|
|
|
private <T> List<CommandOnTaskContextualized<T>> contextualize(
|
|
|
|
|
FunctionalityExposedForExtensions<T> context,
|
|
|
|
|
List<ICommandOnTask<T>> commands) {
|
|
|
|
|
List<CommandOnTaskContextualized<T>> result = new ArrayList<CommandOnTaskContextualized<T>>();
|
|
|
|
|
for (ICommandOnTask<T> c : commands) {
|
2009-07-28 12:28:47 +02:00
|
|
|
result.add(contextualize(context, c));
|
2009-07-22 18:43:31 +02:00
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-28 12:28:47 +02:00
|
|
|
private <T> CommandOnTaskContextualized<T> contextualize(
|
|
|
|
|
FunctionalityExposedForExtensions<T> context,
|
|
|
|
|
ICommandOnTask<T> commandOnTask) {
|
|
|
|
|
return CommandOnTaskContextualized.create(commandOnTask, context
|
|
|
|
|
.getMapper(), context);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-22 18:43:31 +02:00
|
|
|
private <T> CommandContextualized<T> contextualize(IContext<T> context,
|
|
|
|
|
ICommand<T> command) {
|
2009-11-03 20:38:03 +01:00
|
|
|
if (command == null) {
|
2009-07-28 12:28:47 +02:00
|
|
|
return null;
|
2009-11-03 20:38:03 +01:00
|
|
|
}
|
2009-07-20 15:37:42 +02:00
|
|
|
return CommandContextualized.create(command, context);
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-20 15:37:41 +02:00
|
|
|
private <T> List<CommandContextualized<T>> contextualize(
|
2009-07-22 18:43:31 +02:00
|
|
|
IContext<T> context, Collection<? extends ICommand<T>> commands) {
|
2009-07-20 15:37:41 +02:00
|
|
|
ArrayList<CommandContextualized<T>> result = new ArrayList<CommandContextualized<T>>();
|
|
|
|
|
for (ICommand<T> command : commands) {
|
2009-07-20 15:37:42 +02:00
|
|
|
result.add(contextualize(context, command));
|
2009-07-20 15:37:40 +02:00
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-30 19:07:03 +02:00
|
|
|
private void setupComponents() {
|
2009-10-05 18:23:09 +02:00
|
|
|
insertGlobalCommands();
|
2010-03-16 08:59:42 +01:00
|
|
|
|
|
|
|
|
predicate = new FilterAndParentExpandedPredicates(context) {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean accpetsFilterPredicate(Task task) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
2010-02-15 01:20:19 +01:00
|
|
|
this.leftPane = new LeftPane(disabilityConfiguration, this.diagramGraph
|
2010-03-16 08:59:42 +01:00
|
|
|
.getTopLevelTasks(), predicate);
|
2010-08-10 14:31:19 +02:00
|
|
|
this.ganttPanel = new GanttPanel(this,
|
2009-12-07 19:26:57 +01:00
|
|
|
commandsOnTasksContextualized, doubleClickCommand,
|
2010-03-16 08:59:42 +01:00
|
|
|
disabilityConfiguration, predicate);
|
|
|
|
|
|
2010-01-27 14:28:37 +01:00
|
|
|
Button button = (Button) getFellow("btnPrint");
|
|
|
|
|
button.setDisabled(!context.isPrintEnabled());
|
2009-04-14 17:51:03 +02:00
|
|
|
}
|
2009-07-22 18:43:32 +02:00
|
|
|
|
2009-10-14 00:20:56 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
2009-10-05 18:23:09 +02:00
|
|
|
private void insertGlobalCommands() {
|
|
|
|
|
Component toolbar = getToolbar();
|
|
|
|
|
Component firstSeparator = getFirstSeparatorFromToolbar();
|
2009-10-14 00:20:56 +02:00
|
|
|
toolbar.getChildren().removeAll(getBefore(toolbar, firstSeparator));
|
2009-10-05 18:23:09 +02:00
|
|
|
for (CommandContextualized<?> c : contextualizedGlobalCommands) {
|
|
|
|
|
toolbar.insertBefore(c.toButton(), firstSeparator);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-14 00:20:56 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
private List<Component> getBefore(Component parent, Component child) {
|
|
|
|
|
List<Component> children = parent.getChildren();
|
|
|
|
|
List<Component> result = new ArrayList<Component>();
|
|
|
|
|
for (Component object : children) {
|
|
|
|
|
if (object == child) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
result.add(object);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-05 18:23:09 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
private Component getFirstSeparatorFromToolbar() {
|
|
|
|
|
Component toolbar = getToolbar();
|
|
|
|
|
List<Component> children = toolbar.getChildren();
|
|
|
|
|
List<Separator> separators = ComponentsFinder
|
|
|
|
|
.findComponentsOfType(
|
|
|
|
|
Separator.class, children);
|
|
|
|
|
return separators.get(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Component getToolbar() {
|
|
|
|
|
Component toolbar = getFellow("toolbar");
|
|
|
|
|
return toolbar;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-22 18:43:32 +02:00
|
|
|
void removeTask(Task task) {
|
|
|
|
|
TaskList taskList = getTaskList();
|
|
|
|
|
taskList.remove(task);
|
2009-09-30 23:26:32 +02:00
|
|
|
getDependencyList().taskRemoved(task);
|
2009-07-22 18:43:32 +02:00
|
|
|
leftPane.taskRemoved(task);
|
|
|
|
|
setHeight(getHeight());// forcing smart update
|
|
|
|
|
taskList.adjustZoomColumnsHeight();
|
|
|
|
|
getDependencyList().redrawDependencies();
|
|
|
|
|
}
|
2009-09-01 11:30:02 +02:00
|
|
|
|
2009-10-02 18:28:55 +02:00
|
|
|
@Override
|
|
|
|
|
public void afterCompose() {
|
|
|
|
|
super.afterCompose();
|
2010-02-05 16:55:10 +01:00
|
|
|
listZoomLevels = (Listbox) getFellow("listZoomLevels");
|
2010-03-24 09:22:45 +01:00
|
|
|
|
|
|
|
|
Component westContainer = getFellow("taskdetailsContainer");
|
|
|
|
|
westContainer.addEventListener(Events.ON_SIZE, new EventListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onEvent(Event event) throws Exception {
|
|
|
|
|
Clients.evalJavaScript("zkTaskContainer.legendResize();");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2009-10-02 18:28:55 +02:00
|
|
|
}
|
|
|
|
|
|
2009-10-06 16:03:03 +02:00
|
|
|
public TimeTracker getTimeTracker() {
|
|
|
|
|
return ganttPanel.getTimeTracker();
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-04 17:45:55 +01:00
|
|
|
private IGraphChangeListener showCriticalPathOnChange = new IGraphChangeListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
context.showCriticalPath();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2010-01-15 20:17:17 +01:00
|
|
|
private boolean containersExpandedByDefault = false;
|
|
|
|
|
|
2010-03-16 08:59:42 +01:00
|
|
|
private FilterAndParentExpandedPredicates predicate;
|
|
|
|
|
|
2010-04-29 11:04:28 +02:00
|
|
|
private boolean visibleChart;
|
2010-04-27 19:52:53 +02:00
|
|
|
|
2009-12-04 12:30:04 +01:00
|
|
|
public void showCriticalPath() {
|
2009-12-08 03:36:08 +01:00
|
|
|
Button showCriticalPathButton = (Button) getFellow("showCriticalPath");
|
2009-12-04 12:30:04 +01:00
|
|
|
if (disabilityConfiguration.isCriticalPathEnabled()) {
|
|
|
|
|
if (isShowingCriticalPath) {
|
|
|
|
|
context.hideCriticalPath();
|
2009-12-04 17:45:55 +01:00
|
|
|
diagramGraph.removePostGraphChangeListener(showCriticalPathOnChange);
|
2009-12-08 03:36:08 +01:00
|
|
|
showCriticalPathButton.setSclass("planner-command");
|
2009-12-08 03:36:09 +01:00
|
|
|
showCriticalPathButton.setTooltiptext(_("Show critical path"));
|
2009-12-04 12:30:04 +01:00
|
|
|
} else {
|
|
|
|
|
context.showCriticalPath();
|
2009-12-04 17:45:55 +01:00
|
|
|
diagramGraph.addPostGraphChangeListener(showCriticalPathOnChange);
|
2009-12-08 03:36:08 +01:00
|
|
|
showCriticalPathButton.setSclass("planner-command clicked");
|
2009-12-08 03:36:09 +01:00
|
|
|
showCriticalPathButton.setTooltiptext(_("Hide critical path"));
|
2009-12-04 12:30:04 +01:00
|
|
|
}
|
|
|
|
|
isShowingCriticalPath = !isShowingCriticalPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-08 03:36:09 +01:00
|
|
|
public void showAllLabels() {
|
|
|
|
|
Button showAllLabelsButton = (Button) getFellow("showAllLabels");
|
2010-03-11 12:05:34 +01:00
|
|
|
if (isShowingLabels) {
|
|
|
|
|
Clients.evalJavaScript("zkTasklist.hideAllTooltips();");
|
|
|
|
|
showAllLabelsButton.setSclass("planner-command show-labels");
|
|
|
|
|
} else {
|
2009-12-08 03:36:09 +01:00
|
|
|
Clients.evalJavaScript("zkTasklist.showAllTooltips();");
|
2010-01-07 10:16:31 +01:00
|
|
|
showAllLabelsButton
|
|
|
|
|
.setSclass("planner-command show-labels clicked");
|
2009-12-08 03:36:09 +01:00
|
|
|
}
|
2010-03-11 12:05:34 +01:00
|
|
|
isShowingLabels = !isShowingLabels;
|
2009-12-08 03:36:09 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-29 09:33:16 +01:00
|
|
|
public void showAllResources() {
|
|
|
|
|
Button showAllLabelsButton = (Button) getFellow("showAllResources");
|
2010-03-11 12:05:34 +01:00
|
|
|
if (isShowingResources) {
|
2009-12-29 09:33:16 +01:00
|
|
|
Clients.evalJavaScript("zkTasklist.hideResourceTooltips();");
|
2010-01-07 10:16:31 +01:00
|
|
|
showAllLabelsButton.setSclass("planner-command show-resources");
|
2010-03-11 12:05:34 +01:00
|
|
|
} else {
|
|
|
|
|
Clients.evalJavaScript("zkTasklist.showResourceTooltips();");
|
|
|
|
|
showAllLabelsButton
|
|
|
|
|
.setSclass("planner-command show-resources clicked");
|
2009-12-29 09:33:16 +01:00
|
|
|
}
|
2010-03-11 12:05:34 +01:00
|
|
|
isShowingResources = !isShowingResources;
|
2009-12-29 09:33:16 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-08 22:59:24 +01:00
|
|
|
public void print() {
|
2010-01-11 23:42:45 +01:00
|
|
|
// Pending to raise print configuration popup. Information retrieved
|
|
|
|
|
// should be passed as parameter to context print method
|
|
|
|
|
context.print();
|
2009-12-08 22:59:24 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-15 00:28:36 +01:00
|
|
|
public ZoomLevel getZoomLevel() {
|
|
|
|
|
if (ganttPanel == null) {
|
2010-02-05 14:19:58 +01:00
|
|
|
return initialZoomLevel != null ? initialZoomLevel
|
|
|
|
|
: ZoomLevel.DETAIL_ONE;
|
2010-01-15 00:28:36 +01:00
|
|
|
}
|
|
|
|
|
return ganttPanel.getTimeTracker().getDetailLevel();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 18:42:49 +01:00
|
|
|
public boolean isFixedZoomByUser() {
|
|
|
|
|
return this.fixedZoomByUser;
|
2010-02-05 14:19:58 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-15 00:28:36 +01:00
|
|
|
public void setInitialZoomLevel(final ZoomLevel zoomLevel) {
|
2010-08-02 19:49:43 +02:00
|
|
|
if (this.initialZoomLevel != null) {
|
|
|
|
|
// already initialized
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-01-15 00:28:36 +01:00
|
|
|
this.initialZoomLevel = zoomLevel;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-15 20:17:17 +01:00
|
|
|
public boolean areContainersExpandedByDefault() {
|
|
|
|
|
return containersExpandedByDefault;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAreContainersExpandedByDefault(
|
|
|
|
|
boolean containersExpandedByDefault) {
|
|
|
|
|
this.containersExpandedByDefault = containersExpandedByDefault;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-10 12:48:27 +01:00
|
|
|
public void expandAll() {
|
|
|
|
|
Button expandAllButton = (Button) getFellow("expandAll");
|
|
|
|
|
if (disabilityConfiguration.isExpandAllEnabled()) {
|
|
|
|
|
if (expandAllButton.getSclass().equals("planner-command")) {
|
|
|
|
|
context.expandAll();
|
|
|
|
|
expandAllButton.setSclass("planner-command clicked");
|
|
|
|
|
} else {
|
|
|
|
|
context.collapseAll();
|
|
|
|
|
expandAllButton.setSclass("planner-command");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-19 10:57:00 +02:00
|
|
|
public void expandAllAlways() {
|
|
|
|
|
Button expandAllButton = (Button) getFellow("expandAll");
|
|
|
|
|
if (disabilityConfiguration.isExpandAllEnabled()) {
|
|
|
|
|
context.expandAll();
|
|
|
|
|
expandAllButton.setSclass("planner-command clicked");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 18:42:49 +01:00
|
|
|
public void updateSelectedZoomLevel() {
|
|
|
|
|
if (!isFixedZoomByUser()) {
|
|
|
|
|
Listitem selectedItem = (Listitem) listZoomLevels.getItems().get(
|
|
|
|
|
initialZoomLevel.ordinal());
|
|
|
|
|
listZoomLevels.setSelectedItem(selectedItem);
|
|
|
|
|
listZoomLevels.invalidate();
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-17 09:10:02 +01:00
|
|
|
|
|
|
|
|
public IContext<?> getContext() {
|
|
|
|
|
return context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTaskListPredicate(FilterAndParentExpandedPredicates predicate) {
|
2010-03-16 08:59:42 +01:00
|
|
|
this.predicate = predicate;
|
2010-02-17 09:10:02 +01:00
|
|
|
leftPane.setPredicate(predicate);
|
|
|
|
|
getTaskList().setPredicate(predicate);
|
|
|
|
|
getDependencyList().redrawDependencies();
|
2010-03-11 12:05:34 +01:00
|
|
|
|
|
|
|
|
if (isShowingLabels) {
|
|
|
|
|
Clients.evalJavaScript("zkTasklist.showAllTooltips();");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isShowingResources) {
|
|
|
|
|
Clients.evalJavaScript("zkTasklist.showResourceTooltips();");
|
|
|
|
|
}
|
2010-02-17 09:10:02 +01:00
|
|
|
}
|
2010-03-16 08:59:42 +01:00
|
|
|
|
|
|
|
|
public void flattenTree() {
|
|
|
|
|
Button flattenTreeButton = (Button) getFellow("flattenTree");
|
|
|
|
|
if (disabilityConfiguration.isFlattenTreeEnabled()) {
|
|
|
|
|
if (flattenTreeButton.getSclass().equals("planner-command")) {
|
|
|
|
|
predicate.setFilterContainers(true);
|
|
|
|
|
flattenTreeButton.setSclass("planner-command clicked");
|
|
|
|
|
} else {
|
|
|
|
|
predicate.setFilterContainers(false);
|
|
|
|
|
flattenTreeButton.setSclass("planner-command");
|
|
|
|
|
}
|
|
|
|
|
setTaskListPredicate(predicate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FilterAndParentExpandedPredicates getPredicate() {
|
|
|
|
|
return predicate;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-27 19:52:53 +02:00
|
|
|
public void changeChartVisibility(boolean visible) {
|
|
|
|
|
visibleChart = visible;
|
|
|
|
|
chartVisibilityListeners
|
|
|
|
|
.fireEvent(new IListenerNotification<IChartVisibilityChangedListener>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void doNotify(
|
|
|
|
|
IChartVisibilityChangedListener listener) {
|
|
|
|
|
listener.chartVisibilityChanged(visibleChart);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isVisibleChart() {
|
|
|
|
|
return visibleChart;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addChartVisibilityListener(
|
|
|
|
|
IChartVisibilityChangedListener chartVisibilityChangedListener) {
|
|
|
|
|
chartVisibilityListeners.addListener(chartVisibilityChangedListener);
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-27 10:58:09 +02:00
|
|
|
public void addGraphChangeListenersFromConfiguration(
|
|
|
|
|
PlannerConfiguration<?> configuration) {
|
|
|
|
|
diagramGraph.addPreChangeListeners(configuration
|
|
|
|
|
.getPreChangeListeners());
|
|
|
|
|
diagramGraph.addPostChangeListeners(configuration
|
|
|
|
|
.getPostChangeListeners());
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-11 08:46:56 +02:00
|
|
|
public boolean isShowingCriticalPath() {
|
|
|
|
|
return isShowingCriticalPath;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:31:19 +02:00
|
|
|
public boolean isShowingLabels() {
|
|
|
|
|
return isShowingLabels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isShowingResources() {
|
|
|
|
|
return isShowingResources;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-06 16:02:57 +02:00
|
|
|
}
|