2009-10-01 18:46:46 +02:00
|
|
|
/*
|
2011-10-28 08:17:54 +02:00
|
|
|
* This file is part of LibrePlan
|
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
|
2012-03-16 11:51:32 +01:00
|
|
|
* Copyright (C) 2010-2012 Igalia, S.L.
|
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._;
|
|
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
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;
|
2016-10-13 11:49:04 +03:00
|
|
|
import java.util.List;
|
2010-01-15 20:25:51 +01:00
|
|
|
import java.util.Map;
|
2010-12-01 09:04:24 +01:00
|
|
|
import java.util.Map.Entry;
|
2010-12-10 17:49:50 +01:00
|
|
|
import java.util.Set;
|
2009-04-14 17:51:03 +02:00
|
|
|
|
2011-07-01 17:25:25 +02:00
|
|
|
import org.apache.commons.logging.Log;
|
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-12-01 09:04:24 +01:00
|
|
|
import org.zkoss.ganttz.data.GanttDiagramGraph.GanttZKDiagramGraph;
|
|
|
|
|
import org.zkoss.ganttz.data.GanttDiagramGraph.IGraphChangeListener;
|
2010-12-10 17:49:50 +01:00
|
|
|
import org.zkoss.ganttz.data.Position;
|
|
|
|
|
import org.zkoss.ganttz.data.Task;
|
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;
|
2010-12-10 17:49:50 +01:00
|
|
|
import org.zkoss.ganttz.util.LongOperationFeedback.ILongOperation;
|
2011-07-01 17:25:25 +02:00
|
|
|
import org.zkoss.ganttz.util.ProfilingLogFactory;
|
2010-04-27 19:52:53 +02:00
|
|
|
import org.zkoss.ganttz.util.WeakReferencedListeners;
|
2010-10-22 09:54:37 +02:00
|
|
|
import org.zkoss.zk.au.AuRequest;
|
|
|
|
|
import org.zkoss.zk.au.AuService;
|
|
|
|
|
import org.zkoss.zk.mesg.MZk;
|
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-10-22 09:54:37 +02:00
|
|
|
import org.zkoss.zk.ui.UiException;
|
2010-03-24 09:22:45 +01:00
|
|
|
import org.zkoss.zk.ui.event.Events;
|
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;
|
2010-02-16 18:42:49 +01:00
|
|
|
import org.zkoss.zul.Listbox;
|
|
|
|
|
import org.zkoss.zul.Listitem;
|
2009-12-28 11:08:33 +01:00
|
|
|
import org.zkoss.zul.SimpleListModel;
|
2010-08-02 12:36:25 +02:00
|
|
|
import org.zkoss.zul.South;
|
2016-10-13 11:49:04 +03:00
|
|
|
import org.zkoss.zul.Combobox;
|
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
|
|
|
|
2016-11-15 11:13:21 +02:00
|
|
|
private static final String PLANNER_COMMAND = "planner-command";
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2016-11-15 11:13:21 +02:00
|
|
|
private static final Log PROFILING_LOG = ProfilingLogFactory.getLog(Planner.class);
|
2016-10-13 11:49:04 +03:00
|
|
|
|
|
|
|
|
private String EXPAND_ALL_BUTTON = "expandAll";
|
|
|
|
|
|
|
|
|
|
private GanttZKDiagramGraph diagramGraph;
|
|
|
|
|
|
|
|
|
|
private LeftPane leftPane;
|
|
|
|
|
|
|
|
|
|
private GanttPanel ganttPanel;
|
|
|
|
|
|
|
|
|
|
private List<? extends CommandContextualized<?>> contextualizedGlobalCommands;
|
|
|
|
|
|
|
|
|
|
private CommandContextualized<?> goingDownInLastArrowCommand;
|
|
|
|
|
|
|
|
|
|
private List<? extends CommandOnTaskContextualized<?>> commandsOnTasksContextualized;
|
|
|
|
|
|
|
|
|
|
private CommandOnTaskContextualized<?> doubleClickCommand;
|
|
|
|
|
|
|
|
|
|
private FunctionalityExposedForExtensions<?> context;
|
|
|
|
|
|
|
|
|
|
private transient IDisabilityConfiguration disabilityConfiguration;
|
|
|
|
|
|
|
|
|
|
private boolean isShowingCriticalPath = false;
|
|
|
|
|
|
|
|
|
|
private boolean isShowingAdvances = false;
|
|
|
|
|
|
|
|
|
|
private boolean isShowingLabels = false;
|
|
|
|
|
|
|
|
|
|
private boolean isShowingReportedHours = false;
|
|
|
|
|
|
|
|
|
|
private boolean isShowingMoneyCostBar = false;
|
|
|
|
|
|
|
|
|
|
private boolean isShowingResources = false;
|
|
|
|
|
|
|
|
|
|
private boolean isExpandAll = false;
|
|
|
|
|
|
|
|
|
|
private boolean isFlattenTree = false;
|
|
|
|
|
|
|
|
|
|
private ZoomLevel zoomLevel = null;
|
|
|
|
|
|
|
|
|
|
private Listbox listZoomLevels = null;
|
|
|
|
|
|
2016-11-15 11:13:21 +02:00
|
|
|
private WeakReferencedListeners<IChartVisibilityChangedListener> chartVisibilityListeners = WeakReferencedListeners.create();
|
2016-10-13 11:49:04 +03:00
|
|
|
|
|
|
|
|
private IGraphChangeListener showCriticalPathOnChange = new IGraphChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
context.showCriticalPath();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private IGraphChangeListener showAdvanceOnChange = new IGraphChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
context.showAdvances();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private IGraphChangeListener showReportedHoursOnChange = new IGraphChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
context.showReportedHours();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private IGraphChangeListener showMoneyCostBarOnChange = new IGraphChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
context.showMoneyCostBar();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private boolean containersExpandedByDefault = false;
|
|
|
|
|
|
|
|
|
|
private boolean shownAdvanceByDefault = false;
|
|
|
|
|
|
|
|
|
|
private boolean shownReportedHoursByDefault = false;
|
|
|
|
|
|
|
|
|
|
private boolean shownMoneyCostBarByDefault = false;
|
|
|
|
|
|
|
|
|
|
private FilterAndParentExpandedPredicates predicate;
|
|
|
|
|
|
|
|
|
|
private boolean visibleChart;
|
|
|
|
|
|
2016-11-15 11:13:21 +02:00
|
|
|
public Planner() {
|
|
|
|
|
}
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
public static boolean guessContainersExpandedByDefaultGivenPrintParameters(Map<String, String> printParameters) {
|
2010-01-19 13:15:37 +01:00
|
|
|
return guessContainersExpandedByDefault(convertToURLParameters(printParameters));
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
private static Map<String, String[]> convertToURLParameters(Map<String, String> printParameters) {
|
|
|
|
|
Map<String, String[]> result = new HashMap<>();
|
2010-01-19 13:15:37 +01:00
|
|
|
for (Entry<String, String> each : printParameters.entrySet()) {
|
|
|
|
|
result.put(each.getKey(), new String[] { each.getValue() });
|
|
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2010-01-19 13:15:37 +01:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
public static boolean guessContainersExpandedByDefault(Map<String, String[]> queryURLParameters) {
|
2010-01-15 20:25:51 +01:00
|
|
|
String[] values = queryURLParameters.get("expanded");
|
2016-05-12 17:41:35 +03:00
|
|
|
return values != null && toLowercaseSet(values).contains("all");
|
2010-01-15 20:25:51 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
public static boolean guessShowAdvancesByDefault(Map<String, String[]> queryURLParameters) {
|
2010-12-01 09:04:24 +01:00
|
|
|
String[] values = queryURLParameters.get("advances");
|
2016-05-12 17:41:35 +03:00
|
|
|
return values != null && toLowercaseSet(values).contains("all");
|
2010-12-01 09:04:24 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
public static boolean guessShowReportedHoursByDefault(Map<String, String[]> queryURLParameters) {
|
2010-11-30 11:14:55 +01:00
|
|
|
String[] values = queryURLParameters.get("reportedHours");
|
2016-05-12 17:41:35 +03:00
|
|
|
return values != null && toLowercaseSet(values).contains("all");
|
2010-11-30 11:14:55 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
public static boolean guessShowMoneyCostBarByDefault(Map<String, String[]> queryURLParameters) {
|
2012-03-16 11:51:32 +01:00
|
|
|
String[] values = queryURLParameters.get("moneyCostBar");
|
2016-05-12 17:41:35 +03:00
|
|
|
return values != null && toLowercaseSet(values).contains("all");
|
2012-03-16 11:51:32 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-15 20:25:51 +01:00
|
|
|
private static Set<String> toLowercaseSet(String[] values) {
|
2016-05-12 17:41:35 +03:00
|
|
|
Set<String> result = new HashSet<>();
|
2010-01-15 20:25:51 +01:00
|
|
|
for (String each : values) {
|
|
|
|
|
result.add(each.toLowerCase());
|
|
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2010-01-15 20:25:51 +01:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-29 17:40:02 +02:00
|
|
|
TaskList getTaskList() {
|
2016-10-13 11:49:04 +03:00
|
|
|
return ganttPanel == null
|
|
|
|
|
? null
|
|
|
|
|
: ComponentsFinder.findComponentsOfType(TaskList.class, ganttPanel.getChildren()).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
|
|
|
public int calculateMinimumWidthForTaskNameColumn(boolean expand) {
|
|
|
|
|
return calculateMinimumWidthForTaskNameColumn(expand, getTaskList().getAllTasks());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int calculateMinimumWidthForTaskNameColumn(boolean expand, List<Task> tasks) {
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2010-06-07 14:08:13 +02:00
|
|
|
IDomainAndBeansMapper<?> mapper = getContext().getMapper();
|
|
|
|
|
int widest = 0;
|
2016-11-15 11:13:21 +02:00
|
|
|
int pixelsPerTaskLevel = 21;
|
|
|
|
|
int pixelsPerCharacter = 5;
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
for (Task task : tasks) {
|
2016-05-12 17:41:35 +03:00
|
|
|
int numberOfAncestors = mapper.findPositionFor(task).getAncestors().size();
|
2010-06-07 14:08:13 +02:00
|
|
|
int numberOfCharacters = task.getName().length();
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
widest = Math.max(
|
|
|
|
|
widest,
|
2016-11-15 11:13:21 +02:00
|
|
|
numberOfCharacters * pixelsPerCharacter + numberOfAncestors * pixelsPerTaskLevel);
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
if ( expand && !task.isLeaf() ) {
|
2016-05-12 17:41:35 +03:00
|
|
|
widest = Math.max(widest, calculateMinimumWidthForTaskNameColumn(expand, task.getTasks()));
|
2010-06-07 14:08:13 +02:00
|
|
|
}
|
|
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2010-06-07 14:08:13 +02:00
|
|
|
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() {
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( ganttPanel == null ) {
|
2009-07-26 16:17:52 +02:00
|
|
|
return null;
|
2009-11-03 20:38:03 +01:00
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
List<Component> children = ganttPanel.getChildren();
|
2016-05-12 17:41:35 +03:00
|
|
|
List<DependencyList> found = ComponentsFinder.findComponentsOfType(DependencyList.class, children);
|
|
|
|
|
|
|
|
|
|
if ( found.isEmpty() ) {
|
2009-04-29 18:35:19 +02:00
|
|
|
return null;
|
2009-11-03 20:38:03 +01:00
|
|
|
}
|
2016-05-12 17:41:35 +03: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();
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
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) {
|
2016-05-12 17:41:35 +03:00
|
|
|
addTasks(position, Collections.singletonList(task));
|
2009-07-28 20:17:49 +02:00
|
|
|
}
|
|
|
|
|
|
2009-07-26 16:17:52 +02:00
|
|
|
void addDependencies(Collection<? extends Dependency> dependencies) {
|
|
|
|
|
DependencyList dependencyList = getDependencyList();
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( dependencyList == null ) {
|
2009-07-26 16:17:52 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
for (DependencyComponent d : getTaskList().asDependencyComponents(dependencies)) {
|
2009-07-26 16:17:52 +02:00
|
|
|
dependencyList.addDependencyComponent(d);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
public ListModel<ZoomLevel> getZoomLevels() {
|
2016-05-12 17:41:35 +03:00
|
|
|
ZoomLevel[] selectableZoomlevels = {
|
|
|
|
|
ZoomLevel.DETAIL_ONE,
|
|
|
|
|
ZoomLevel.DETAIL_TWO,
|
|
|
|
|
ZoomLevel.DETAIL_THREE,
|
|
|
|
|
ZoomLevel.DETAIL_FOUR,
|
2016-10-13 11:49:04 +03:00
|
|
|
ZoomLevel.DETAIL_FIVE
|
|
|
|
|
};
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
return new SimpleListModel<>(selectableZoomlevels);
|
2009-12-28 11:08:33 +01:00
|
|
|
}
|
|
|
|
|
|
2010-10-25 12:03:52 +02:00
|
|
|
public void setZoomLevel(final ZoomLevel zoomLevel, int scrollLeft) {
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( ganttPanel == null ) {
|
2009-12-28 11:08:33 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2013-02-07 13:07:29 +01:00
|
|
|
this.zoomLevel = zoomLevel;
|
2010-10-25 12:03:52 +02:00
|
|
|
ganttPanel.setZoomLevel(zoomLevel, scrollLeft);
|
2009-12-28 11:08:33 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-05 18:09:13 +02:00
|
|
|
public void zoomIncrease() {
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( ganttPanel == null ) {
|
2009-10-05 18:09:13 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2009-12-07 21:43:05 +01:00
|
|
|
LongOperationFeedback.execute(ganttPanel, new ILongOperation() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getName() {
|
|
|
|
|
return _("increasing zoom");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2011-06-06 17:46:26 +02:00
|
|
|
public void doAction() {
|
2009-12-07 21:43:05 +01:00
|
|
|
ganttPanel.zoomIncrease();
|
|
|
|
|
}
|
|
|
|
|
});
|
2009-10-05 18:09:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void zoomDecrease() {
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( ganttPanel == null ) {
|
2009-10-05 18:09:13 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2009-12-07 21:43:05 +01:00
|
|
|
LongOperationFeedback.execute(ganttPanel, new ILongOperation() {
|
|
|
|
|
@Override
|
|
|
|
|
public String getName() {
|
|
|
|
|
return _("decreasing zoom");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2011-06-06 17:46:26 +02:00
|
|
|
public void doAction() {
|
2009-12-07 21:43:05 +01:00
|
|
|
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) {
|
2016-05-12 17:41:35 +03: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
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( isShowingLabels )
|
2011-10-18 11:44:36 +02:00
|
|
|
Clients.evalJavaScript("ganttz.TaskList.getInstance().showAllTaskLabels()");
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
if ( isShowingResources )
|
2011-10-18 11:44:36 +02:00
|
|
|
Clients.evalJavaScript("ganttz.TaskList.getInstance().showResourceTooltips()");
|
|
|
|
|
|
2010-12-10 17:49:50 +01:00
|
|
|
this.diagramGraph = GanttDiagramGraph.create(
|
|
|
|
|
configuration.isScheduleBackwards(),
|
|
|
|
|
configuration.getStartConstraints(),
|
|
|
|
|
configuration.getEndConstraints(),
|
|
|
|
|
configuration.isDependenciesConstraintsHavePriority());
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
FunctionalityExposedForExtensions<T> newContext =
|
|
|
|
|
new FunctionalityExposedForExtensions<>(this, configuration, diagramGraph);
|
|
|
|
|
|
2010-05-27 10:58:09 +02:00
|
|
|
addGraphChangeListenersFromConfiguration(configuration);
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
this.contextualizedGlobalCommands = contextualize(newContext, configuration.getGlobalCommands());
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
this.commandsOnTasksContextualized = contextualize(newContext, configuration.getCommandsOnTasks());
|
|
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
goingDownInLastArrowCommand = contextualize(newContext, configuration.getGoingDownInLastArrowCommand());
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
doubleClickCommand = contextualize(newContext, configuration.getDoubleClickCommand());
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2009-11-04 00:28:29 +01:00
|
|
|
this.context = newContext;
|
2009-11-02 19:58:43 +01:00
|
|
|
this.disabilityConfiguration = configuration;
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2010-02-03 19:07:07 +01:00
|
|
|
resettingPreviousComponentsToNull();
|
2011-07-01 17:25:25 +02:00
|
|
|
long timeAddingData = System.currentTimeMillis();
|
2009-11-04 00:28:29 +01:00
|
|
|
newContext.add(configuration.getData());
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
PROFILING_LOG.debug("It took to add data: " + (System.currentTimeMillis() - timeAddingData) + " ms");
|
2011-07-01 17:25:25 +02:00
|
|
|
long timeSetupingAndAddingComponents = System.currentTimeMillis();
|
2009-09-30 19:07:03 +02:00
|
|
|
setupComponents();
|
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
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
TimeTrackerComponent timetrackerheader =
|
|
|
|
|
new TimeTrackerComponentWithoutColumns(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();
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
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
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( !configuration.isCriticalPathEnabled() ) {
|
2009-12-04 12:30:04 +01:00
|
|
|
Button showCriticalPathButton = (Button) getFellow("showCriticalPath");
|
|
|
|
|
showCriticalPathButton.setVisible(false);
|
2009-12-03 17:51:27 +01:00
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
if ( !configuration.isExpandAllEnabled() ) {
|
2016-10-13 11:49:04 +03:00
|
|
|
Button expandAllButton = (Button) getFellow(EXPAND_ALL_BUTTON);
|
2010-02-10 12:48:27 +01:00
|
|
|
expandAllButton.setVisible(false);
|
|
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
if (!configuration.isFlattenTreeEnabled()) {
|
2010-03-16 08:59:42 +01:00
|
|
|
Button flattenTree = (Button) getFellow("flattenTree");
|
|
|
|
|
flattenTree.setVisible(false);
|
|
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
if ( !configuration.isShowAllResourcesEnabled() ) {
|
2010-09-02 19:32:22 +02:00
|
|
|
Button showAllResources = (Button) getFellow("showAllResources");
|
|
|
|
|
showAllResources.setVisible(false);
|
|
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
if ( !configuration.isMoneyCostBarEnabled() ) {
|
2012-03-26 10:27:15 +02:00
|
|
|
Button showMoneyCostBarButton = (Button) getFellow("showMoneyCostBar");
|
|
|
|
|
showMoneyCostBarButton.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);
|
2010-10-22 09:54:37 +02:00
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
if (!visibleChart) {
|
|
|
|
|
((South) getFellow("graphics")).setTitle(_("Graphics are disabled"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PROFILING_LOG.debug("it took doing the setup of components and adding them: "
|
|
|
|
|
+ (System.currentTimeMillis() - timeSetupingAndAddingComponents) + " ms");
|
2011-07-01 17:25:25 +02:00
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
setAuService(new AuService() {
|
2016-11-15 11:13:21 +02:00
|
|
|
public boolean service(AuRequest request, boolean everError) {
|
2010-10-22 09:54:37 +02:00
|
|
|
String command = request.getCommand();
|
2010-10-22 13:28:47 +02:00
|
|
|
int zoomindex;
|
2010-10-22 13:31:47 +02:00
|
|
|
int scrollLeft;
|
2010-10-22 09:54:37 +02:00
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
if ( "onZoomLevelChange".equals(command) ) {
|
2010-10-22 13:28:47 +02:00
|
|
|
zoomindex= (Integer) retrieveData(request, "zoomindex");
|
2010-10-22 13:31:47 +02:00
|
|
|
scrollLeft = (Integer) retrieveData(request, "scrollLeft");
|
2013-02-06 13:42:52 +01:00
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
setZoomLevel(
|
|
|
|
|
(ZoomLevel)((Listbox) getFellow("listZoomLevels")).getModel().getElementAt(zoomindex),
|
|
|
|
|
scrollLeft);
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2010-10-22 09:54:37 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2010-10-22 09:54:37 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
private Object retrieveData(AuRequest request, String key) {
|
2010-10-22 13:28:47 +02:00
|
|
|
Object value = request.getData().get(key);
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( value == null )
|
|
|
|
|
throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA, new Object[] { key, this });
|
2010-10-22 09:54:37 +02:00
|
|
|
|
2010-10-22 13:28:47 +02:00
|
|
|
return value;
|
|
|
|
|
}
|
2010-10-22 09:54:37 +02: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);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
private <T> List<CommandOnTaskContextualized<T>> contextualize(FunctionalityExposedForExtensions<T> context,
|
|
|
|
|
List<ICommandOnTask<T>> commands) {
|
2016-11-15 11:13:21 +02:00
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
List<CommandOnTaskContextualized<T>> result = new ArrayList<>();
|
2009-07-22 18:43:31 +02:00
|
|
|
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
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2009-07-22 18:43:31 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
private <T> CommandOnTaskContextualized<T> contextualize(FunctionalityExposedForExtensions<T> context,
|
|
|
|
|
ICommandOnTask<T> commandOnTask) {
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
return CommandOnTaskContextualized.create(commandOnTask, context.getMapper(), context);
|
2009-07-28 12:28:47 +02:00
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
private <T> CommandContextualized<T> contextualize(IContext<T> context, ICommand<T> command) {
|
2016-10-13 11:49:04 +03:00
|
|
|
return command == null ? null : CommandContextualized.create(command, context);
|
2009-07-20 15:37:42 +02:00
|
|
|
}
|
|
|
|
|
|
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) {
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
ArrayList<CommandContextualized<T>> result = new ArrayList<>();
|
2009-07-20 15:37:41 +02:00
|
|
|
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
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2011-11-14 19:18:23 +01:00
|
|
|
this.leftPane = new LeftPane(disabilityConfiguration, this, predicate);
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
this.ganttPanel = new GanttPanel(
|
|
|
|
|
this, commandsOnTasksContextualized, doubleClickCommand, disabilityConfiguration, predicate);
|
2010-03-16 08:59:42 +01:00
|
|
|
|
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
|
|
|
|
2011-11-14 19:18:23 +01:00
|
|
|
public GanttZKDiagramGraph getDiagramGraph() {
|
|
|
|
|
return this.diagramGraph;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateTooltips() {
|
|
|
|
|
this.ganttPanel.updateTooltips();
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-14 00:20:56 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
2009-10-05 18:23:09 +02:00
|
|
|
private void insertGlobalCommands() {
|
2016-11-15 11:13:21 +02:00
|
|
|
Component commonToolbar = getCommonCommandsInsertionPoint();
|
2011-10-19 18:41:15 +02:00
|
|
|
Component plannerToolbar = getSpecificCommandsInsertionPoint();
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
if ( !contextualizedGlobalCommands.isEmpty() ) {
|
2016-11-15 11:13:21 +02:00
|
|
|
commonToolbar.getChildren().removeAll(commonToolbar.getChildren());
|
2011-11-02 15:11:14 +01:00
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2009-10-05 18:23:09 +02:00
|
|
|
for (CommandContextualized<?> c : contextualizedGlobalCommands) {
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2011-10-19 18:41:15 +02:00
|
|
|
// Comparison through icon as name is internationalized
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( c.getCommand().isPlannerCommand() ) {
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2012-11-05 09:40:45 +01:00
|
|
|
// FIXME Avoid hard-coding the number of planner commands
|
2016-05-12 17:41:35 +03:00
|
|
|
// At this moment we have 2 planner commands: reassign and adapt planning
|
|
|
|
|
if ( plannerToolbar.getChildren().size() < 2 ) {
|
2011-10-19 18:41:15 +02:00
|
|
|
plannerToolbar.appendChild(c.toButton());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2016-11-15 11:13:21 +02:00
|
|
|
commonToolbar.appendChild(c.toButton());
|
2011-10-19 18:41:15 +02:00
|
|
|
}
|
2009-10-05 18:23:09 +02:00
|
|
|
}
|
2011-10-19 18:41:15 +02:00
|
|
|
|
2009-10-05 18:23:09 +02:00
|
|
|
}
|
|
|
|
|
|
2011-10-19 18:41:15 +02:00
|
|
|
private Component getCommonCommandsInsertionPoint() {
|
2016-05-12 17:41:35 +03:00
|
|
|
return getPage().getFellow("perspectiveButtonsInsertionPoint");
|
2009-10-05 18:23:09 +02:00
|
|
|
}
|
|
|
|
|
|
2011-10-19 18:41:15 +02:00
|
|
|
private Component getSpecificCommandsInsertionPoint() {
|
2016-05-12 17:41:35 +03:00
|
|
|
return getFellow("plannerButtonsInsertionPoint");
|
2011-10-19 18:41:15 +02:00
|
|
|
}
|
|
|
|
|
|
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);
|
2016-10-13 11:49:04 +03:00
|
|
|
setHeight(getHeight());// forcing smart update
|
2010-08-23 13:01:11 +02:00
|
|
|
ganttPanel.adjustZoomColumnsHeight();
|
2009-07-22 18:43:32 +02:00
|
|
|
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");
|
|
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
westContainer.addEventListener(
|
|
|
|
|
Events.ON_SIZE,
|
|
|
|
|
event -> Clients.evalJavaScript("ganttz.TaskList.getInstance().legendResize();"));
|
2010-03-24 09:22:45 +01:00
|
|
|
|
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 12:30:04 +01:00
|
|
|
public void showCriticalPath() {
|
2009-12-08 03:36:08 +01:00
|
|
|
Button showCriticalPathButton = (Button) getFellow("showCriticalPath");
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( disabilityConfiguration.isCriticalPathEnabled() ) {
|
|
|
|
|
if ( isShowingCriticalPath ) {
|
2009-12-04 12:30:04 +01:00
|
|
|
context.hideCriticalPath();
|
2009-12-04 17:45:55 +01:00
|
|
|
diagramGraph.removePostGraphChangeListener(showCriticalPathOnChange);
|
2016-11-15 11:13:21 +02: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);
|
2016-11-15 11:13:21 +02: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
|
|
|
}
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2009-12-04 12:30:04 +01:00
|
|
|
isShowingCriticalPath = !isShowingCriticalPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-03 21:15:23 +02:00
|
|
|
public void forcedShowAdvances() {
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( !isShowingAdvances ) {
|
2011-10-03 21:15:23 +02:00
|
|
|
showAdvances();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-01 09:03:34 +01:00
|
|
|
public void showAdvances() {
|
|
|
|
|
Button showAdvancesButton = (Button) getFellow("showAdvances");
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( disabilityConfiguration.isAdvancesEnabled() ) {
|
2012-11-23 12:57:55 +01:00
|
|
|
Combobox progressTypesCombo = (Combobox) getFellow("cbProgressTypes");
|
2016-05-12 17:41:35 +03:00
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
if ( isShowingAdvances ) {
|
2010-12-01 09:03:34 +01:00
|
|
|
context.hideAdvances();
|
|
|
|
|
diagramGraph.removePostGraphChangeListener(showAdvanceOnChange);
|
2016-11-15 11:13:21 +02:00
|
|
|
showAdvancesButton.setSclass(PLANNER_COMMAND);
|
2011-01-05 11:42:01 +01:00
|
|
|
showAdvancesButton.setTooltiptext(_("Show progress"));
|
2016-05-12 17:41:35 +03:00
|
|
|
|
|
|
|
|
if ( progressTypesCombo.getItemCount() > 0 ) {
|
2012-12-04 09:42:30 +01:00
|
|
|
progressTypesCombo.setSelectedIndex(0);
|
|
|
|
|
}
|
2010-12-01 09:03:34 +01:00
|
|
|
} else {
|
|
|
|
|
context.showAdvances();
|
|
|
|
|
diagramGraph.addPostGraphChangeListener(showAdvanceOnChange);
|
2016-11-15 11:13:21 +02:00
|
|
|
showAdvancesButton.setSclass(PLANNER_COMMAND + " clicked");
|
2011-01-05 11:42:01 +01:00
|
|
|
showAdvancesButton.setTooltiptext(_("Hide progress"));
|
2010-12-01 09:03:34 +01:00
|
|
|
}
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2010-12-01 09:03:34 +01:00
|
|
|
isShowingAdvances = !isShowingAdvances;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-30 10:54:22 +01:00
|
|
|
public void showReportedHours() {
|
|
|
|
|
Button showReportedHoursButton = (Button) getFellow("showReportedHours");
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( disabilityConfiguration.isReportedHoursEnabled() ) {
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( isShowingReportedHours ) {
|
2010-11-30 10:54:22 +01:00
|
|
|
context.hideReportedHours();
|
2016-05-12 17:41:35 +03:00
|
|
|
diagramGraph.removePostGraphChangeListener(showReportedHoursOnChange);
|
2016-11-15 11:13:21 +02:00
|
|
|
showReportedHoursButton.setSclass(PLANNER_COMMAND);
|
2016-05-12 17:41:35 +03:00
|
|
|
showReportedHoursButton.setTooltiptext(_("Show reported hours"));
|
2010-11-30 10:54:22 +01:00
|
|
|
} else {
|
|
|
|
|
context.showReportedHours();
|
2016-05-12 17:41:35 +03:00
|
|
|
diagramGraph.addPostGraphChangeListener(showReportedHoursOnChange);
|
2016-11-15 11:13:21 +02:00
|
|
|
showReportedHoursButton.setSclass(PLANNER_COMMAND + " clicked");
|
2016-05-12 17:41:35 +03:00
|
|
|
showReportedHoursButton.setTooltiptext(_("Hide reported hours"));
|
2010-11-30 10:54:22 +01:00
|
|
|
}
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2010-11-30 10:54:22 +01:00
|
|
|
isShowingReportedHours = !isShowingReportedHours;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-16 11:51:32 +01:00
|
|
|
public void showMoneyCostBar() {
|
|
|
|
|
Button showMoneyCostBarButton = (Button) getFellow("showMoneyCostBar");
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( disabilityConfiguration.isMoneyCostBarEnabled() ) {
|
|
|
|
|
if ( isShowingMoneyCostBar ) {
|
2012-03-16 11:51:32 +01:00
|
|
|
context.hideMoneyCostBar();
|
2016-05-12 17:41:35 +03:00
|
|
|
diagramGraph.removePostGraphChangeListener(showMoneyCostBarOnChange);
|
2016-11-15 11:13:21 +02:00
|
|
|
showMoneyCostBarButton.setSclass(PLANNER_COMMAND);
|
2012-03-16 11:51:32 +01:00
|
|
|
showMoneyCostBarButton.setTooltiptext(_("Show money cost bar"));
|
|
|
|
|
} else {
|
|
|
|
|
context.showMoneyCostBar();
|
2016-05-12 17:41:35 +03:00
|
|
|
diagramGraph.addPostGraphChangeListener(showMoneyCostBarOnChange);
|
2016-11-15 11:13:21 +02:00
|
|
|
showMoneyCostBarButton.setSclass(PLANNER_COMMAND + " clicked");
|
2012-03-16 11:51:32 +01:00
|
|
|
showMoneyCostBarButton.setTooltiptext(_("Hide money cost bar"));
|
|
|
|
|
}
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2012-03-16 11:51:32 +01:00
|
|
|
isShowingMoneyCostBar = !isShowingMoneyCostBar;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-08 03:36:09 +01:00
|
|
|
public void showAllLabels() {
|
|
|
|
|
Button showAllLabelsButton = (Button) getFellow("showAllLabels");
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( isShowingLabels ) {
|
2010-08-25 14:12:01 +02:00
|
|
|
Clients.evalJavaScript("ganttz.TaskList.getInstance().hideAllTaskLabels()");
|
2010-03-11 12:05:34 +01:00
|
|
|
showAllLabelsButton.setSclass("planner-command show-labels");
|
|
|
|
|
} else {
|
2010-08-25 14:12:01 +02:00
|
|
|
Clients.evalJavaScript("ganttz.TaskList.getInstance().showAllTaskLabels()");
|
2016-05-12 17:41:35 +03:00
|
|
|
showAllLabelsButton.setSclass("planner-command show-labels clicked");
|
2009-12-08 03:36:09 +01:00
|
|
|
}
|
2016-10-13 11:49:04 +03: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");
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( isShowingResources ) {
|
2010-08-25 14:29:11 +02:00
|
|
|
Clients.evalJavaScript("ganttz.TaskList.getInstance().hideResourceTooltips()");
|
2010-01-07 10:16:31 +01:00
|
|
|
showAllLabelsButton.setSclass("planner-command show-resources");
|
2010-03-11 12:05:34 +01:00
|
|
|
} else {
|
2010-08-25 14:29:11 +02:00
|
|
|
Clients.evalJavaScript("ganttz.TaskList.getInstance().showResourceTooltips()");
|
2016-05-12 17:41:35 +03:00
|
|
|
showAllLabelsButton.setSclass("planner-command show-resources clicked");
|
2009-12-29 09:33:16 +01:00
|
|
|
}
|
2016-10-13 11:49:04 +03: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() {
|
2016-05-12 17:41:35 +03:00
|
|
|
// Pending to raise print configuration popup.
|
|
|
|
|
// Information retrieved should be passed as parameter to context print method.
|
2010-01-11 23:42:45 +01:00
|
|
|
context.print();
|
2009-12-08 22:59:24 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-15 00:28:36 +01:00
|
|
|
public ZoomLevel getZoomLevel() {
|
2016-10-13 11:49:04 +03:00
|
|
|
return ganttPanel == null
|
|
|
|
|
? zoomLevel != null ? zoomLevel : ZoomLevel.DETAIL_ONE
|
|
|
|
|
: ganttPanel.getTimeTracker().getDetailLevel();
|
2010-01-15 00:28:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setInitialZoomLevel(final ZoomLevel zoomLevel) {
|
2013-02-07 13:07:29 +01:00
|
|
|
this.zoomLevel = zoomLevel;
|
2010-01-15 00:28:36 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-15 20:17:17 +01:00
|
|
|
public boolean areContainersExpandedByDefault() {
|
|
|
|
|
return containersExpandedByDefault;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
public void setAreContainersExpandedByDefault(boolean containersExpandedByDefault) {
|
2010-01-15 20:17:17 +01:00
|
|
|
this.containersExpandedByDefault = containersExpandedByDefault;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-01 09:04:24 +01:00
|
|
|
public boolean areShownAdvancesByDefault() {
|
|
|
|
|
return shownAdvanceByDefault;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-02 09:28:13 +01:00
|
|
|
public boolean showAdvancesRightNow() {
|
2016-10-13 11:49:04 +03:00
|
|
|
return areShownAdvancesByDefault() || isShowingAdvances;
|
2010-12-02 09:28:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-01 09:04:24 +01:00
|
|
|
public void setAreShownAdvancesByDefault(boolean shownAdvanceByDefault) {
|
|
|
|
|
this.shownAdvanceByDefault = shownAdvanceByDefault;
|
2010-12-02 09:28:13 +01:00
|
|
|
this.isShowingAdvances = shownAdvanceByDefault;
|
2010-12-01 09:04:24 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
public void setAreShownReportedHoursByDefault(boolean shownReportedHoursByDefault) {
|
2010-11-30 11:14:55 +01:00
|
|
|
this.shownReportedHoursByDefault = shownReportedHoursByDefault;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean areShownReportedHoursByDefault() {
|
|
|
|
|
return shownReportedHoursByDefault;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-02 09:28:13 +01:00
|
|
|
public boolean showReportedHoursRightNow() {
|
2016-10-13 11:49:04 +03:00
|
|
|
return areShownReportedHoursByDefault() || isShowingReportedHours;
|
2010-12-02 09:28:13 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
public void setAreShownMoneyCostBarByDefault(boolean shownMoneyCostBarByDefault) {
|
2012-03-16 11:51:32 +01:00
|
|
|
this.shownMoneyCostBarByDefault = shownMoneyCostBarByDefault;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean areShownMoneyCostBarByDefault() {
|
|
|
|
|
return shownMoneyCostBarByDefault;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean showMoneyCostBarRightNow() {
|
2016-10-13 11:49:04 +03:00
|
|
|
return areShownMoneyCostBarByDefault() || isShowingMoneyCostBar;
|
2012-03-16 11:51:32 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-10 12:48:27 +01:00
|
|
|
public void expandAll() {
|
2016-10-13 11:49:04 +03:00
|
|
|
Button expandAllButton = (Button) getFellow(EXPAND_ALL_BUTTON);
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( disabilityConfiguration.isExpandAllEnabled() ) {
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( isExpandAll ) {
|
2010-02-10 12:48:27 +01:00
|
|
|
context.collapseAll();
|
2016-11-15 11:13:21 +02:00
|
|
|
expandAllButton.setSclass(PLANNER_COMMAND);
|
2010-08-11 10:32:22 +02:00
|
|
|
} else {
|
|
|
|
|
context.expandAll();
|
2016-11-15 11:13:21 +02:00
|
|
|
expandAllButton.setSclass(PLANNER_COMMAND + " clicked");
|
2010-02-10 12:48:27 +01:00
|
|
|
}
|
|
|
|
|
}
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2010-08-11 10:32:22 +02:00
|
|
|
isExpandAll = !isExpandAll;
|
2010-02-10 12:48:27 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-19 10:57:00 +02:00
|
|
|
public void expandAllAlways() {
|
2016-10-13 11:49:04 +03:00
|
|
|
Button expandAllButton = (Button) getFellow(EXPAND_ALL_BUTTON);
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( disabilityConfiguration.isExpandAllEnabled() ) {
|
2016-10-13 11:49:04 +03:00
|
|
|
context.expandAll();
|
2016-11-15 11:13:21 +02:00
|
|
|
expandAllButton.setSclass(PLANNER_COMMAND + " clicked");
|
2010-04-19 10:57:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-16 18:42:49 +01:00
|
|
|
public void updateSelectedZoomLevel() {
|
2013-02-07 13:07:29 +01:00
|
|
|
ganttPanel.getTimeTracker().setZoomLevel(zoomLevel);
|
2016-10-13 11:49:04 +03:00
|
|
|
Listitem selectedItem = listZoomLevels.getItems().get(zoomLevel.ordinal());
|
2013-02-06 13:44:06 +01:00
|
|
|
listZoomLevels.setSelectedItem(selectedItem);
|
|
|
|
|
listZoomLevels.invalidate();
|
2010-02-16 18:42:49 +01:00
|
|
|
}
|
2010-02-17 09:10:02 +01:00
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
public IContext getContext() {
|
2010-02-17 09:10:02 +01:00
|
|
|
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
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( isShowingLabels ) {
|
2011-10-27 20:14:16 +02:00
|
|
|
Clients.evalJavaScript("ganttz.TaskList.getInstance().showAllTaskLabels();");
|
2010-03-11 12:05:34 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( isShowingResources ) {
|
2011-10-27 20:14:16 +02:00
|
|
|
Clients.evalJavaScript("ganttz.TaskList.getInstance().showResourceTooltips();");
|
2010-03-11 12:05:34 +01:00
|
|
|
}
|
2010-02-17 09:10:02 +01:00
|
|
|
}
|
2010-03-16 08:59:42 +01:00
|
|
|
|
|
|
|
|
public void flattenTree() {
|
|
|
|
|
Button flattenTreeButton = (Button) getFellow("flattenTree");
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( disabilityConfiguration.isFlattenTreeEnabled() ) {
|
2016-10-13 11:49:04 +03:00
|
|
|
if (isFlattenTree) {
|
2010-03-16 08:59:42 +01:00
|
|
|
predicate.setFilterContainers(false);
|
2016-11-15 11:13:21 +02:00
|
|
|
flattenTreeButton.setSclass(PLANNER_COMMAND);
|
2010-08-11 10:08:11 +02:00
|
|
|
} else {
|
|
|
|
|
predicate.setFilterContainers(true);
|
2016-11-15 11:13:21 +02:00
|
|
|
flattenTreeButton.setSclass(PLANNER_COMMAND + " clicked");
|
2010-03-16 08:59:42 +01:00
|
|
|
}
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2010-03-16 08:59:42 +01:00
|
|
|
setTaskListPredicate(predicate);
|
|
|
|
|
}
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2010-08-11 10:08:11 +02:00
|
|
|
isFlattenTree = !isFlattenTree;
|
2011-10-17 18:19:39 +02:00
|
|
|
Clients.evalJavaScript("ganttz.Planner.getInstance().adjustScrollableDimensions()");
|
2010-03-16 08:59:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FilterAndParentExpandedPredicates getPredicate() {
|
|
|
|
|
return predicate;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-27 19:52:53 +02:00
|
|
|
public void changeChartVisibility(boolean visible) {
|
|
|
|
|
visibleChart = visible;
|
2016-10-13 11:49:04 +03:00
|
|
|
chartVisibilityListeners.fireEvent(listener -> listener.chartVisibilityChanged(visibleChart));
|
2010-04-27 19:52:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isVisibleChart() {
|
|
|
|
|
return visibleChart;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
public void addChartVisibilityListener(IChartVisibilityChangedListener chartVisibilityChangedListener) {
|
2010-04-27 19:52:53 +02:00
|
|
|
chartVisibilityListeners.addListener(chartVisibilityChangedListener);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
public void addGraphChangeListenersFromConfiguration(PlannerConfiguration<?> configuration) {
|
|
|
|
|
diagramGraph.addPreChangeListeners(configuration.getPreChangeListeners());
|
|
|
|
|
diagramGraph.addPostChangeListeners(configuration.getPostChangeListeners());
|
2010-05-27 10:58:09 +02:00
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-01 13:38:10 +01:00
|
|
|
public boolean isShowingAdvances() {
|
|
|
|
|
return isShowingAdvances;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-11 10:32:22 +02:00
|
|
|
public boolean isExpandAll() {
|
|
|
|
|
return isExpandAll;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-11 10:08:11 +02:00
|
|
|
public boolean isFlattenTree() {
|
|
|
|
|
return isFlattenTree;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-24 12:53:53 +02:00
|
|
|
public Button findCommandComponent(String name) {
|
|
|
|
|
for (CommandContextualized<?> c : contextualizedGlobalCommands) {
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( c.getCommand().getName().equals(name) ) {
|
2010-08-24 12:53:53 +02:00
|
|
|
return c.toButton();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2010-11-05 13:56:59 +01:00
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
@Override
|
2010-08-23 13:01:11 +02:00
|
|
|
public String getWidgetClass(){
|
2016-10-13 11:49:04 +03:00
|
|
|
return getDefinition().getDefaultWidgetClass(this);
|
2010-08-23 13:01:11 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-05 13:56:59 +01:00
|
|
|
public List getCriticalPath() {
|
|
|
|
|
return context.getCriticalPath();
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-23 19:14:44 +01:00
|
|
|
public void updateCompletion(String progressType) {
|
2011-11-17 14:51:19 +01:00
|
|
|
TaskList taskList = getTaskList();
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( taskList != null ) {
|
2011-11-17 14:51:19 +01:00
|
|
|
taskList.updateCompletion(progressType);
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2011-12-28 18:23:56 +01:00
|
|
|
for (TaskComponent each : taskList.getTaskComponents()) {
|
|
|
|
|
each.invalidate();
|
|
|
|
|
}
|
2011-11-17 14:51:19 +01:00
|
|
|
}
|
2010-11-23 19:14:44 +01:00
|
|
|
}
|
|
|
|
|
|
2016-10-13 11:49:04 +03:00
|
|
|
public TaskComponent getTaskComponentRelatedTo(Task task) {
|
2012-11-06 19:20:41 +01:00
|
|
|
TaskList taskList = getTaskList();
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( taskList != null ) {
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2012-11-06 19:20:41 +01:00
|
|
|
for (TaskComponent each : taskList.getTaskComponents()) {
|
2016-10-13 11:49:04 +03:00
|
|
|
|
2016-05-12 17:41:35 +03:00
|
|
|
if ( each.getTask().equals(task) ) {
|
2012-11-06 19:20:41 +01:00
|
|
|
return each;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-06 16:02:57 +02:00
|
|
|
}
|