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
|
|
|
*
|
|
|
|
|
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
|
|
|
|
* Desenvolvemento Tecnolóxico de Galicia
|
|
|
|
|
*
|
|
|
|
|
* 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;
|
|
|
|
|
import java.util.Set;
|
2010-01-19 13:15:37 +01: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;
|
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;
|
2009-07-28 20:17:49 +02:00
|
|
|
import org.zkoss.ganttz.data.Position;
|
2009-07-20 18:00:11 +02:00
|
|
|
import org.zkoss.ganttz.data.Task;
|
2009-12-04 17:45:55 +01:00
|
|
|
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;
|
2009-12-07 21:43:05 +01:00
|
|
|
import org.zkoss.ganttz.util.LongOperationFeedback.ILongOperation;
|
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;
|
2009-12-08 03:36:09 +01:00
|
|
|
import org.zkoss.zk.ui.util.Clients;
|
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;
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-07 14:05:13 +01:00
|
|
|
private GanttDiagramGraph 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;
|
|
|
|
|
|
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-01-15 00:28:36 +01:00
|
|
|
private ZoomLevel initialZoomLevel = ZoomLevel.DETAIL_ONE;
|
|
|
|
|
|
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-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() {
|
|
|
|
|
return new SimpleListModel(ZoomLevel.values());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setZoomLevel(final ZoomLevel zoomLevel) {
|
2010-01-14 00:05:04 +01:00
|
|
|
|
2009-12-28 11:08:33 +01:00
|
|
|
if (ganttPanel == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
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
|
|
|
}
|
2009-11-07 16:08:47 +01:00
|
|
|
this.diagramGraph = new GanttDiagramGraph(configuration
|
2009-11-08 23:41:44 +01:00
|
|
|
.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);
|
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
|
|
|
}
|
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();
|
|
|
|
|
this.leftPane = new LeftPane(this.diagramGraph.getTopLevelTasks());
|
2009-08-18 12:26:56 +02:00
|
|
|
this.ganttPanel = new GanttPanel(this.context,
|
2009-12-07 19:26:57 +01:00
|
|
|
commandsOnTasksContextualized, doubleClickCommand,
|
2009-11-02 19:58:43 +01:00
|
|
|
disabilityConfiguration);
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
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-01-07 10:16:31 +01:00
|
|
|
if (showAllLabelsButton.getSclass().equals(
|
|
|
|
|
"planner-command show-labels")) {
|
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
|
|
|
} else {
|
|
|
|
|
Clients.evalJavaScript("zkTasklist.hideAllTooltips();");
|
2010-01-07 10:16:31 +01:00
|
|
|
showAllLabelsButton.setSclass("planner-command show-labels");
|
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-01-07 10:16:31 +01:00
|
|
|
if (showAllLabelsButton.getSclass().equals(
|
|
|
|
|
"planner-command show-resources")) {
|
2009-12-29 09:33:16 +01:00
|
|
|
Clients.evalJavaScript("zkTasklist.showResourceTooltips();");
|
2010-01-07 10:16:31 +01:00
|
|
|
showAllLabelsButton
|
|
|
|
|
.setSclass("planner-command show-resources clicked");
|
2009-12-29 09:33:16 +01:00
|
|
|
} else {
|
|
|
|
|
Clients.evalJavaScript("zkTasklist.hideResourceTooltips();");
|
2010-01-07 10:16:31 +01:00
|
|
|
showAllLabelsButton.setSclass("planner-command show-resources");
|
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) {
|
|
|
|
|
return initialZoomLevel;
|
|
|
|
|
}
|
|
|
|
|
return ganttPanel.getTimeTracker().getDetailLevel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setInitialZoomLevel(final ZoomLevel zoomLevel) {
|
|
|
|
|
this.initialZoomLevel = zoomLevel;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-15 20:17:17 +01:00
|
|
|
public boolean areContainersExpandedByDefault() {
|
|
|
|
|
return containersExpandedByDefault;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAreContainersExpandedByDefault(
|
|
|
|
|
boolean containersExpandedByDefault) {
|
|
|
|
|
this.containersExpandedByDefault = containersExpandedByDefault;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-06 16:02:57 +02:00
|
|
|
}
|