Update Commons Collections. Code refactoring.
This commit is contained in:
parent
68bc4a6fa5
commit
7bb48bec9b
12 changed files with 931 additions and 864 deletions
28
NEWS.rst
28
NEWS.rst
|
|
@ -24,27 +24,33 @@ Thanks to all the contributors to this new version:
|
|||
Changes
|
||||
~~~~~~~
|
||||
|
||||
* Update MPXJ
|
||||
* Update Maven Gettext Plugin
|
||||
* Update Maven Compiler Plugin
|
||||
* Update Maven War Plugin
|
||||
* Update Maven Surfire Plugin
|
||||
* Update Bonecp
|
||||
* Update Slf4j API
|
||||
* Update Slf4j Simple
|
||||
* Update Guava
|
||||
* Update Maven Cobertura Plugin
|
||||
* Update Maven Liquibase Plugin
|
||||
* Update Liquibase Core
|
||||
* Update Jackson
|
||||
* Update LibrePlan version to 1.6.0
|
||||
* Update Javax Servlet
|
||||
* Update Jfree
|
||||
|
||||
* Update Slf4j API
|
||||
* Update Slf4j Simple
|
||||
* Update Log4j
|
||||
* Update Slf4j
|
||||
|
||||
* Update Commons Lang
|
||||
* Update Commons Math
|
||||
* Update Commons Collections
|
||||
|
||||
* Update MPXJ
|
||||
* Update Bonecp
|
||||
* Update Guava
|
||||
* Update Liquibase Core
|
||||
* Update Jackson
|
||||
* Update Javax Servlet
|
||||
* Update Jfree
|
||||
* Update JGraphT
|
||||
* Update DBUnit
|
||||
* Update Log4j
|
||||
|
||||
* Update LibrePlan version to 1.6.0
|
||||
|
||||
* Remove Ezmorph
|
||||
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@
|
|||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ZK -->
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.zkoss.ganttz.adapters.DomainDependency;
|
||||
import org.zkoss.ganttz.adapters.IAdapterToTaskFundamentalProperties;
|
||||
|
|
@ -65,23 +65,25 @@ import org.zkoss.zul.Window;
|
|||
public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
||||
|
||||
private static class OneToOneMapper<T> implements IDomainAndBeansMapper<T> {
|
||||
private Map<T, Task> fromDomainToTask = new HashMap<T, Task>();
|
||||
|
||||
private Map<Task, T> fromTaskToDomain = new HashMap<Task, T>();
|
||||
private Map<T, Task> fromDomainToTask = new HashMap<>();
|
||||
|
||||
private Map<Task, TaskContainer> fromTaskToParent = new HashMap<Task, TaskContainer>();
|
||||
private Map<Task, T> fromTaskToDomain = new HashMap<>();
|
||||
|
||||
private List<Task> topLevel = new ArrayList<Task>();
|
||||
private Map<Task, TaskContainer> fromTaskToParent = new HashMap<>();
|
||||
|
||||
private List<Task> topLevel = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public Task findAssociatedBean(T domainObject)
|
||||
throws IllegalArgumentException {
|
||||
if (domainObject == null) {
|
||||
public Task findAssociatedBean(T domainObject) throws IllegalArgumentException {
|
||||
if ( domainObject == null ) {
|
||||
throw new IllegalArgumentException("domainObject is null");
|
||||
}
|
||||
if (!fromDomainToTask.containsKey(domainObject)) {
|
||||
|
||||
if ( !fromDomainToTask.containsKey(domainObject) ) {
|
||||
throw new IllegalArgumentException("not found " + domainObject);
|
||||
}
|
||||
|
||||
return fromDomainToTask.get(domainObject);
|
||||
}
|
||||
|
||||
|
|
@ -96,9 +98,9 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
fromDomainToTask.put(domainObject, task);
|
||||
fromTaskToDomain.put(task, domainObject);
|
||||
|
||||
if (position.isAppendToTop()) {
|
||||
if ( position.isAppendToTop() ) {
|
||||
topLevel.add(task);
|
||||
} else if (position.isAtTop()) {
|
||||
} else if ( position.isAtTop() ) {
|
||||
topLevel.add(position.getInsertionPosition(), task);
|
||||
} else {
|
||||
fromTaskToParent.put(task, position.getParent());
|
||||
|
|
@ -110,34 +112,39 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
fromDomainToTask.remove(domainObject);
|
||||
fromTaskToDomain.remove(toBeRemoved);
|
||||
TaskContainer parent = fromTaskToParent.get(toBeRemoved);
|
||||
if (parent != null) {
|
||||
|
||||
if ( parent != null ) {
|
||||
parent.remove(toBeRemoved);
|
||||
}
|
||||
|
||||
fromTaskToParent.remove(toBeRemoved);
|
||||
topLevel.remove(toBeRemoved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T findAssociatedDomainObject(Task task)
|
||||
throws IllegalArgumentException {
|
||||
if (task == null) {
|
||||
public T findAssociatedDomainObject(Task task) throws IllegalArgumentException {
|
||||
if ( task == null ) {
|
||||
throw new IllegalArgumentException("taskBean is null");
|
||||
}
|
||||
if (!fromTaskToDomain.containsKey(task)) {
|
||||
|
||||
if ( !fromTaskToDomain.containsKey(task) ) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
return fromTaskToDomain.get(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position findPositionFor(Task task) {
|
||||
List<TaskContainer> ancestors = ancestorsOf(task);
|
||||
if (ancestors.isEmpty()) {
|
||||
|
||||
if ( ancestors.isEmpty() ) {
|
||||
return Position.createAtTopPosition(topLevel.indexOf(task));
|
||||
}
|
||||
|
||||
TaskContainer parent = ancestors.get(0);
|
||||
return Position.createPosition(ancestors, parent.getTasks()
|
||||
.indexOf(task));
|
||||
|
||||
return Position.createPosition(ancestors, parent.getTasks().indexOf(task));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -146,18 +153,21 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
}
|
||||
|
||||
private List<TaskContainer> ancestorsOf(Task task) {
|
||||
ArrayList<TaskContainer> result = new ArrayList<TaskContainer>();
|
||||
ArrayList<TaskContainer> result = new ArrayList<>();
|
||||
TaskContainer taskContainer = fromTaskToParent.get(task);
|
||||
|
||||
while (taskContainer != null) {
|
||||
result.add(taskContainer);
|
||||
taskContainer = fromTaskToParent.get(taskContainer);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends TaskContainer> getParents(Task task) {
|
||||
Position position = findPositionFor(task);
|
||||
|
||||
return position.getAncestors();
|
||||
}
|
||||
|
||||
|
|
@ -171,39 +181,38 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
private TimeTracker timeTracker;
|
||||
private final PlannerConfiguration<T> configuration;
|
||||
|
||||
public FunctionalityExposedForExtensions(Planner planner,
|
||||
PlannerConfiguration<T> configuration,
|
||||
GanttZKDiagramGraph diagramGraph) {
|
||||
public FunctionalityExposedForExtensions(
|
||||
Planner planner, PlannerConfiguration<T> configuration, GanttZKDiagramGraph diagramGraph) {
|
||||
|
||||
this.planner = planner;
|
||||
this.configuration = configuration;
|
||||
this.adapter = configuration.getAdapter();
|
||||
this.navigator = configuration.getNavigator();
|
||||
this.diagramGraph = diagramGraph;
|
||||
|
||||
final IDetailItemModificator firstLevelModificators = configuration
|
||||
.getFirstLevelModificators();
|
||||
final IDetailItemModificator secondLevelModificators = configuration
|
||||
.getSecondLevelModificators();
|
||||
final IDetailItemModificator firstLevelModificators = configuration.getFirstLevelModificators();
|
||||
final IDetailItemModificator secondLevelModificators = configuration.getSecondLevelModificators();
|
||||
|
||||
Calendar calendarRightNow = Calendar.getInstance();
|
||||
LocalDate localDateRightNow = LocalDate.fromCalendarFields(calendarRightNow);
|
||||
LocalDate initDate = localDateRightNow.minusYears(1);
|
||||
LocalDate endDate = localDateRightNow.plusYears(5);
|
||||
|
||||
this.timeTracker = new TimeTracker(new Interval(
|
||||
TimeTrackerState.year(initDate.getYear()),
|
||||
TimeTrackerState.year(endDate.getYear())),
|
||||
planner.getZoomLevel(), firstLevelModificators,
|
||||
secondLevelModificators, planner);
|
||||
this.timeTracker = new TimeTracker(
|
||||
new Interval(TimeTrackerState.year(initDate.getYear()), TimeTrackerState.year(endDate.getYear())),
|
||||
planner.getZoomLevel(),
|
||||
firstLevelModificators,
|
||||
secondLevelModificators,
|
||||
planner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param insertionPosition
|
||||
* the position in which to register the task at top level. It
|
||||
* can be <code>null</code>
|
||||
* @param insertionPosition the position in which to register the task at top level.
|
||||
* It can be <code>null</code>
|
||||
* @param accumulatedDependencies
|
||||
* @param data
|
||||
* @param parent
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Task buildAndRegister(Position position, List<DomainDependency<T>> accumulatedDependencies, T data) {
|
||||
|
|
@ -212,15 +221,17 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
|
||||
final Task result = build(data);
|
||||
|
||||
if (!navigator.isLeaf(data)) {
|
||||
if ( !navigator.isLeaf(data) ) {
|
||||
TaskContainer container = (TaskContainer) result;
|
||||
int i = 0;
|
||||
|
||||
for (T child : navigator.getChildren(data)) {
|
||||
container.add(buildAndRegister(position.down(container, i),
|
||||
accumulatedDependencies, child));
|
||||
i++;
|
||||
}
|
||||
} else if (navigator.isMilestone(data)) {
|
||||
|
||||
} else if ( navigator.isMilestone(data) ) {
|
||||
Milestone milestone = (Milestone) result;
|
||||
milestone.setOwner(position.getParent());
|
||||
}
|
||||
|
|
@ -230,6 +241,7 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
result.setShowingAdvances(planner.showAdvancesRightNow());
|
||||
|
||||
mapper.register(position, result, data);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -245,14 +257,17 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
}
|
||||
|
||||
public void add(Position position, Collection<? extends T> domainObjects) {
|
||||
List<DomainDependency<T>> totalDependencies = new ArrayList<DomainDependency<T>>();
|
||||
List<Task> tasksCreated = new ArrayList<Task>();
|
||||
List<DomainDependency<T>> totalDependencies = new ArrayList<>();
|
||||
List<Task> tasksCreated = new ArrayList<>();
|
||||
|
||||
for (T object : domainObjects) {
|
||||
Task task = buildAndRegister(position, totalDependencies, object);
|
||||
tasksCreated.add(task);
|
||||
}
|
||||
|
||||
updateTimeTracker(tasksCreated);
|
||||
if (position.isAppendToTop() || position.isAtTop()) {
|
||||
|
||||
if ( position.isAppendToTop() || position.isAtTop() ) {
|
||||
this.diagramGraph.addTopLevel(tasksCreated);
|
||||
} else {
|
||||
this.diagramGraph.addTasks(tasksCreated);
|
||||
|
|
@ -260,10 +275,11 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
parent.addAll(position.getInsertionPosition(), tasksCreated);
|
||||
this.diagramGraph.childrenAddedTo(parent);
|
||||
}
|
||||
for (Dependency dependency : DomainDependency.toDependencies(mapper,
|
||||
totalDependencies)) {
|
||||
|
||||
for (Dependency dependency : DomainDependency.toDependencies(mapper, totalDependencies)) {
|
||||
this.diagramGraph.addWithoutEnforcingConstraints(dependency);
|
||||
}
|
||||
|
||||
this.diagramGraph.enforceAllRestrictions();
|
||||
this.planner.addTasks(position, tasksCreated);
|
||||
}
|
||||
|
|
@ -271,7 +287,8 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
private void updateTimeTracker(List<Task> tasksCreated) {
|
||||
for (Task task : tasksCreated) {
|
||||
timeTracker.trackPosition(task);
|
||||
if (task.isContainer()) {
|
||||
|
||||
if ( task.isContainer() ) {
|
||||
TaskContainer container = (TaskContainer) task;
|
||||
updateTimeTracker(container.getTasks());
|
||||
}
|
||||
|
|
@ -310,6 +327,7 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
diagramGraph.remove(task);
|
||||
task.removed();
|
||||
planner.removeTask(task);
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
|
|
@ -330,20 +348,19 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
|
||||
private DomainDependency<T> toDomainDependency(Dependency bean) {
|
||||
T source = mapper.findAssociatedDomainObject(bean.getSource());
|
||||
T destination = mapper
|
||||
.findAssociatedDomainObject(bean.getDestination());
|
||||
DomainDependency<T> dep = DomainDependency.createDependency(source,
|
||||
destination, bean.getType());
|
||||
T destination = mapper.findAssociatedDomainObject(bean.getDestination());
|
||||
DomainDependency<T> dep = DomainDependency.createDependency(source, destination, bean.getType());
|
||||
|
||||
return dep;
|
||||
}
|
||||
|
||||
public void addDependency(Dependency dependency) {
|
||||
if (!canAddDependency(dependency)) {
|
||||
if ( !canAddDependency(dependency) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
diagramGraph.add(dependency);
|
||||
getDependencyList().addDependencyComponent(
|
||||
getTaskList().asDependencyComponent(dependency));
|
||||
getDependencyList().addDependencyComponent(getTaskList().asDependencyComponent(dependency));
|
||||
adapter.addDependency(toDomainDependency(dependency));
|
||||
}
|
||||
|
||||
|
|
@ -352,8 +369,7 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
}
|
||||
|
||||
private boolean canAddDependency(Dependency dependency) {
|
||||
return diagramGraph.canAddDependency(dependency)
|
||||
&& adapter.canAddDependency(toDomainDependency(dependency));
|
||||
return diagramGraph.canAddDependency(dependency) && adapter.canAddDependency(toDomainDependency(dependency));
|
||||
}
|
||||
|
||||
private DependencyList getDependencyList() {
|
||||
|
|
@ -370,18 +386,22 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
* Substitutes the dependency for a new one with the same source and
|
||||
* destination but with the specified type. If the new dependency cannot be
|
||||
* added, the old one remains.
|
||||
*
|
||||
* @param dependency
|
||||
* @param type
|
||||
* the new type
|
||||
*
|
||||
* @return true only if the new dependency can be added.
|
||||
*/
|
||||
public boolean changeType(Dependency dependency, DependencyType type) {
|
||||
Dependency newDependency = dependency.createWithType(type);
|
||||
boolean canAddDependency = diagramGraph.canAddDependency(newDependency);
|
||||
if (canAddDependency) {
|
||||
|
||||
if ( canAddDependency ) {
|
||||
removeDependency(dependency);
|
||||
addDependency(newDependency);
|
||||
}
|
||||
|
||||
return canAddDependency;
|
||||
}
|
||||
|
||||
|
|
@ -398,19 +418,20 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
|
||||
@Override
|
||||
public void showCriticalPath() {
|
||||
CriticalPathCalculator<Task, Dependency> criticalPathCalculator = CriticalPathCalculator
|
||||
.create(configuration.isDependenciesConstraintsHavePriority());
|
||||
CriticalPathCalculator<Task, Dependency> criticalPathCalculator =
|
||||
CriticalPathCalculator.create(configuration.isDependenciesConstraintsHavePriority());
|
||||
|
||||
List<Task> criticalPath = criticalPathCalculator.calculateCriticalPath(diagramGraph);
|
||||
|
||||
List<Task> criticalPath = criticalPathCalculator
|
||||
.calculateCriticalPath(diagramGraph);
|
||||
for (Task task : diagramGraph.getTasks()) {
|
||||
task.setInCriticalPath(isInCriticalPath(criticalPath, task));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInCriticalPath(List<Task> criticalPath, Task task) {
|
||||
if (task.isContainer()) {
|
||||
List<Task> allTaskLeafs = ((TaskContainer) task).getAllTaskLeafs();
|
||||
if ( task.isContainer() ) {
|
||||
List<Task> allTaskLeafs = task.getAllTaskLeafs();
|
||||
|
||||
return CollectionUtils.containsAny(criticalPath, allTaskLeafs);
|
||||
} else {
|
||||
return criticalPath.contains(task);
|
||||
|
|
@ -419,13 +440,15 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
|
||||
@Override
|
||||
public List<T> getCriticalPath() {
|
||||
List<T> result = new ArrayList<T>();
|
||||
CriticalPathCalculator<Task, Dependency> criticalPathCalculator = CriticalPathCalculator
|
||||
.create(configuration.isDependenciesConstraintsHavePriority());
|
||||
for (Task each : criticalPathCalculator
|
||||
.calculateCriticalPath(diagramGraph)) {
|
||||
List<T> result = new ArrayList<>();
|
||||
|
||||
CriticalPathCalculator<Task, Dependency> criticalPathCalculator =
|
||||
CriticalPathCalculator.create(configuration.isDependenciesConstraintsHavePriority());
|
||||
|
||||
for (Task each : criticalPathCalculator.calculateCriticalPath(diagramGraph)) {
|
||||
result.add(mapper.findAssociatedDomainObject(each));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -488,49 +511,56 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
}
|
||||
|
||||
private HashMap<String, String> buildParameters(Component parent) {
|
||||
HashMap<String, String> parameters = new HashMap<String, String>();
|
||||
HashMap<String, String> parameters = new HashMap<>();
|
||||
|
||||
Checkbox expanded = (Checkbox) parent.getFellow("print_expanded");
|
||||
Checkbox resources = (Checkbox) parent.getFellow("print_resources");
|
||||
Checkbox labels = (Checkbox) parent.getFellow("print_labels");
|
||||
Checkbox advances = (Checkbox) parent.getFellow("print_advances");
|
||||
Checkbox reportedHours = (Checkbox) parent
|
||||
.getFellow("print_reported_hours");
|
||||
Checkbox moneyCostBar = (Checkbox) parent
|
||||
.getFellow("print_money_cost_bar");
|
||||
Checkbox reportedHours = (Checkbox) parent.getFellow("print_reported_hours");
|
||||
Checkbox moneyCostBar = (Checkbox) parent.getFellow("print_money_cost_bar");
|
||||
|
||||
parameters.put("extension", ".png");
|
||||
if (expanded.isChecked() == true) {
|
||||
|
||||
if ( expanded.isChecked() ) {
|
||||
parameters.put("expanded", "all");
|
||||
}
|
||||
if (labels.isChecked() == true) {
|
||||
|
||||
if ( labels.isChecked() ) {
|
||||
parameters.put("labels", "all");
|
||||
}
|
||||
if (advances.isChecked() == true) {
|
||||
|
||||
if ( advances.isChecked() ) {
|
||||
parameters.put("advances", "all");
|
||||
}
|
||||
if (reportedHours.isChecked() == true) {
|
||||
|
||||
if ( reportedHours.isChecked() ) {
|
||||
parameters.put("reportedHours", "all");
|
||||
}
|
||||
if (moneyCostBar.isChecked() == true) {
|
||||
|
||||
if ( moneyCostBar.isChecked() ) {
|
||||
parameters.put("moneyCostBar", "all");
|
||||
}
|
||||
if (resources.isChecked() == true) {
|
||||
|
||||
if ( resources.isChecked() ) {
|
||||
parameters.put("resources", "all");
|
||||
}
|
||||
|
||||
parameters.put("zoom", planner.getZoomLevel().getInternalName());
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void print() {
|
||||
if (!isPrintEnabled()) {
|
||||
if ( !isPrintEnabled() ) {
|
||||
throw new UnsupportedOperationException("print is not supported");
|
||||
}
|
||||
|
||||
final Window printProperties = (Window) Executions.createComponents(
|
||||
"/planner/print_configuration.zul", planner, null);
|
||||
final Window printProperties =
|
||||
(Window) Executions.createComponents("/planner/print_configuration.zul", planner, null);
|
||||
|
||||
Button printButton = (Button) printProperties.getFellow("printButton");
|
||||
|
||||
printButton.addEventListener(Events.ON_CLICK, new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
|
|
@ -538,6 +568,7 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
configuration.print(buildParameters(printProperties),planner);
|
||||
}
|
||||
});
|
||||
|
||||
printButton.setParent(printProperties);
|
||||
|
||||
try {
|
||||
|
|
@ -551,13 +582,14 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
@Override
|
||||
public List<Task> getTasksOrderedByStartDate() {
|
||||
List<Task> tasks = diagramGraph.getTasks();
|
||||
Collections.sort(tasks, new Comparator<Task>() {
|
||||
|
||||
Collections.sort(tasks, new Comparator<Task>() {
|
||||
@Override
|
||||
public int compare(Task o1, Task o2) {
|
||||
return o1.getBeginDate().compareTo(o2.getBeginDate());
|
||||
}
|
||||
});
|
||||
|
||||
return tasks;
|
||||
}
|
||||
|
||||
|
|
@ -571,7 +603,7 @@ public class FunctionalityExposedForExtensions<T> implements IContext<T> {
|
|||
|
||||
private void setExpandAll(boolean expand, List<Task> tasks) {
|
||||
for (Task task : tasks) {
|
||||
if (task instanceof TaskContainer) {
|
||||
if ( task instanceof TaskContainer ) {
|
||||
((TaskContainer) task).setExpanded(expand);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections.ComparatorUtils;
|
||||
import org.apache.commons.collections4.comparators.NullComparator;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.zkoss.ganttz.data.GanttDate;
|
||||
|
|
@ -35,15 +35,14 @@ import org.zkoss.ganttz.util.Interval;
|
|||
public class LoadTimeLine {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final Comparator<GanttDate> nullSafeComparator =
|
||||
ComparatorUtils.nullLowComparator(ComparatorUtils.naturalComparator());
|
||||
private static final Comparator<GanttDate> nullSafeComparator = new NullComparator<>(false);
|
||||
|
||||
public static Comparator<LoadTimeLine> byStartAndEndDate() {
|
||||
return new Comparator<LoadTimeLine>() {
|
||||
|
||||
@Override
|
||||
public int compare(LoadTimeLine o1, LoadTimeLine o2) {
|
||||
int result = nullSafeComparator.compare(o1.getStartPeriod(), o2.getStartPeriod());
|
||||
|
||||
if ( result == 0 ) {
|
||||
return nullSafeComparator.compare(o1.getEndPeriod(), o2.getEndPeriod());
|
||||
}
|
||||
|
|
@ -151,7 +150,7 @@ public class LoadTimeLine {
|
|||
GanttDate end = null;
|
||||
|
||||
for (LoadTimeLine loadTimeLine : timeLines) {
|
||||
if( !loadTimeLine.isEmpty() ) {
|
||||
if ( !loadTimeLine.isEmpty() ) {
|
||||
Validate.notNull(loadTimeLine.getStart());
|
||||
start = min(start, loadTimeLine.getStart());
|
||||
Validate.notNull(loadTimeLine.getEnd());
|
||||
|
|
|
|||
|
|
@ -285,9 +285,8 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
@SuppressWarnings("unchecked")
|
||||
private Separator getSeparator() {
|
||||
List<Component> children = getToolbar().getChildren();
|
||||
Separator separator = ComponentsFinder.findComponentsOfType(Separator.class, children).get(0);
|
||||
|
||||
return separator;
|
||||
return ComponentsFinder.findComponentsOfType(Separator.class, children).get(0);
|
||||
}
|
||||
|
||||
private Component getToolbar() {
|
||||
|
|
@ -364,12 +363,12 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
|
||||
// Insert additional filters if any
|
||||
Component additionalFilter = getFirstOptionalFilter();
|
||||
if( additionalFilter != null ) {
|
||||
if ( additionalFilter != null ) {
|
||||
getFellow("additionalFilterInsertionPoint1").appendChild(additionalFilter);
|
||||
}
|
||||
|
||||
additionalFilter = getSecondOptionalFilter();
|
||||
if( additionalFilter != null ) {
|
||||
if ( additionalFilter != null ) {
|
||||
getFellow("additionalFilterInsertionPoint2").appendChild(additionalFilter);
|
||||
}
|
||||
|
||||
|
|
@ -378,10 +377,10 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
listZoomLevels = (Listbox) getFellow("listZoomLevels");
|
||||
listZoomLevels.setSelectedIndex(timeTracker.getDetailLevel().ordinal());
|
||||
|
||||
if( paginationType == PaginationType.INTERNAL_PAGINATION && refreshNameFilter ) {
|
||||
if ( paginationType == PaginationType.INTERNAL_PAGINATION && refreshNameFilter ) {
|
||||
setupNameFilter();
|
||||
}
|
||||
else if( paginationType == PaginationType.NONE ) {
|
||||
else if ( paginationType == PaginationType.NONE ) {
|
||||
getFellow("filterByNameCombo").setVisible(false);
|
||||
getFellow("filterByNameLabel").setVisible(false);
|
||||
}
|
||||
|
|
@ -443,15 +442,15 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
filterByNameCombo.getChildren().clear();
|
||||
int size = groups.size();
|
||||
|
||||
if( size > numberOfGroupsByName ) {
|
||||
if ( size > numberOfGroupsByName ) {
|
||||
int position = 0;
|
||||
|
||||
while(position < size) {
|
||||
while (position < size) {
|
||||
String firstName = groups.get(position).getConceptName();
|
||||
String lastName;
|
||||
int newPosition = position + numberOfGroupsByName;
|
||||
|
||||
if( newPosition - 1 < size ) {
|
||||
if ( newPosition - 1 < size ) {
|
||||
lastName = groups.get(newPosition - 1).getConceptName();
|
||||
}
|
||||
else {
|
||||
|
|
@ -483,7 +482,7 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
* @return
|
||||
*/
|
||||
private List<LoadTimeLine> getGroupsToShow() {
|
||||
if( paginationType != PaginationType.INTERNAL_PAGINATION || filterByNamePosition == -1 ) {
|
||||
if ( paginationType != PaginationType.INTERNAL_PAGINATION || filterByNamePosition == -1 ) {
|
||||
return groups;
|
||||
}
|
||||
|
||||
|
|
@ -522,7 +521,7 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
LongOperationFeedback.execute(componentOnWhichGiveFeedback, new ILongOperation() {
|
||||
@Override
|
||||
public void doAction() {
|
||||
if( paginationType == PaginationType.INTERNAL_PAGINATION ) {
|
||||
if ( paginationType == PaginationType.INTERNAL_PAGINATION ) {
|
||||
|
||||
//if the pagination is internal, we are in charge of repainting the graph
|
||||
treeModel = createModelForTree();
|
||||
|
|
@ -563,6 +562,7 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
|
||||
public void changeChartVisibility(boolean visible) {
|
||||
visibleChart = visible;
|
||||
|
||||
chartVisibilityListeners.fireEvent(new IListenerNotification<IChartVisibilityChangedListener>() {
|
||||
@Override
|
||||
public void doNotify(IChartVisibilityChangedListener listener) {
|
||||
|
|
@ -588,7 +588,7 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
public Combobox getPaginationFilterCombobox() {
|
||||
if( paginationType == PaginationType.EXTERNAL_PAGINATION ) {
|
||||
if ( paginationType == PaginationType.EXTERNAL_PAGINATION ) {
|
||||
return (Combobox) getFellow("filterByNameCombo");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ package org.libreplan.web.common.components;
|
|||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.apache.commons.collections.comparators.BooleanComparator;
|
||||
import org.apache.commons.collections4.comparators.BooleanComparator;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.libreplan.business.INewObject;
|
||||
import org.zkoss.zk.ui.ext.AfterCompose;
|
||||
|
|
@ -45,13 +45,13 @@ import org.zkoss.zul.api.Grid;
|
|||
* in order to work properly. They notify the {@link NewDataSortableGrid} in which are
|
||||
* included when they are requested to be sorted.
|
||||
*<p>
|
||||
*
|
||||
* @author Javier Moran Rua <jmoran@igalia.com>
|
||||
*/
|
||||
|
||||
public class NewDataSortableColumn extends Column implements AfterCompose {
|
||||
|
||||
private static class NewObjectDecoratorComparator implements
|
||||
Comparator<Object> {
|
||||
private static class NewObjectDecoratorComparator implements Comparator<Object> {
|
||||
private Comparator<Object> decoratedComparator;
|
||||
|
||||
public NewObjectDecoratorComparator(Comparator<Object> c) {
|
||||
|
|
@ -61,7 +61,7 @@ public class NewDataSortableColumn extends Column implements AfterCompose {
|
|||
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
if (!doComparingObjectsSupportInterface(o1, o2)) {
|
||||
if ( !doComparingObjectsSupportInterface(o1, o2) ) {
|
||||
return decoratedComparator.compare(o1, o2);
|
||||
} else {
|
||||
return decorateBehaviour((INewObject) o1, (INewObject) o2);
|
||||
|
|
@ -73,11 +73,11 @@ public class NewDataSortableColumn extends Column implements AfterCompose {
|
|||
}
|
||||
|
||||
private int decorateBehaviour(INewObject o1, INewObject o2) {
|
||||
if (o1.isNewObject() == o2.isNewObject()) {
|
||||
if ( o1.isNewObject() == o2.isNewObject() ) {
|
||||
return decoratedComparator.compare(o1, o2);
|
||||
}
|
||||
return BooleanComparator.getTrueFirstComparator().compare(
|
||||
o1.isNewObject(), o2.isNewObject());
|
||||
|
||||
return BooleanComparator.getTrueFirstComparator().compare(o1.isNewObject(), o2.isNewObject());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,10 +94,11 @@ public class NewDataSortableColumn extends Column implements AfterCompose {
|
|||
@Override
|
||||
public boolean sort(boolean ascending) {
|
||||
Grid grid = getGrid();
|
||||
if (grid instanceof NewDataSortableGrid) {
|
||||
if ( grid instanceof NewDataSortableGrid ) {
|
||||
((NewDataSortableGrid) grid).setSortedColumn(this);
|
||||
((NewDataSortableGrid) grid).setLastSortedColumnAscending(ascending);
|
||||
}
|
||||
|
||||
return super.sort(ascending);
|
||||
}
|
||||
|
||||
|
|
@ -105,11 +106,11 @@ public class NewDataSortableColumn extends Column implements AfterCompose {
|
|||
public void afterCompose() {
|
||||
Grid g = getGrid();
|
||||
|
||||
if (g instanceof NewDataSortableGrid) {
|
||||
if ( g instanceof NewDataSortableGrid ) {
|
||||
NewDataSortableGrid castedGrid = (NewDataSortableGrid) g;
|
||||
|
||||
// The first registered column is responsible for ordering
|
||||
if (castedGrid.getSortedColumn() == null) {
|
||||
if ( castedGrid.getSortedColumn() == null ) {
|
||||
markInGridAsColumnToOrder(castedGrid);
|
||||
}
|
||||
}
|
||||
|
|
@ -118,12 +119,10 @@ public class NewDataSortableColumn extends Column implements AfterCompose {
|
|||
private void markInGridAsColumnToOrder(NewDataSortableGrid parentGrid) {
|
||||
parentGrid.setSortedColumn(this);
|
||||
|
||||
if ("ascending".equals(getSortDirection())) {
|
||||
parentGrid.setLastSortedColumnAscending(
|
||||
Boolean.TRUE.booleanValue());
|
||||
} else if ("descending".equals(getSortDirection())) {
|
||||
parentGrid.setLastSortedColumnAscending(
|
||||
Boolean.FALSE.booleanValue());
|
||||
if ( "ascending".equals(getSortDirection()) ) {
|
||||
parentGrid.setLastSortedColumnAscending(true);
|
||||
} else if ( "descending".equals(getSortDirection()) ) {
|
||||
parentGrid.setLastSortedColumnAscending(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
|
||||
private List selectedFilters = new ArrayList();
|
||||
|
||||
private String selectedFiltersText = new String("");
|
||||
private String selectedFiltersText = "";
|
||||
|
||||
public void afterCompose() {
|
||||
super.afterCompose();
|
||||
|
|
@ -104,15 +104,17 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
@Override
|
||||
public boolean service(AuRequest request, boolean everError) {
|
||||
String command = request.getCommand();
|
||||
if (command.equals("closeBandbox")) {
|
||||
if ( command.equals("closeBandbox") ) {
|
||||
pickElementFromListAndCloseBandbox();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
listbox.addEventListener(Events.ON_OK, new EventListener() {
|
||||
|
||||
listbox.addEventListener(Events.ON_OK, new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
pickElementFromListAndCloseBandbox();
|
||||
|
|
@ -125,11 +127,10 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
* Search for matching elements while typing on bandbox
|
||||
*/
|
||||
bandbox.addEventListener("onChanging", new EventListener() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
final String inputText = ((InputEvent) event).getValue();
|
||||
if ((inputText == null) || (inputText.isEmpty())) {
|
||||
if ( (inputText == null) || (inputText.isEmpty()) ) {
|
||||
clear();
|
||||
listbox.setSelectedIndex(0);
|
||||
Events.postEvent(Events.ON_CHANGE, listbox, null);
|
||||
|
|
@ -145,7 +146,7 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
@Override
|
||||
public void onEvent(Event event) {
|
||||
List<Listitem> items = listbox.getItems();
|
||||
if (!items.isEmpty()) {
|
||||
if ( !items.isEmpty() ) {
|
||||
listbox.setSelectedIndex(0);
|
||||
items.get(0).setFocus(true);
|
||||
}
|
||||
|
|
@ -154,20 +155,22 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
private void initFinder() {
|
||||
if (multipleFiltersFinder != null) {
|
||||
if (listbox != null) {
|
||||
if ( multipleFiltersFinder != null ) {
|
||||
|
||||
if ( listbox != null ) {
|
||||
initListbox();
|
||||
}
|
||||
if (bandbox != null) {
|
||||
|
||||
if ( bandbox != null ) {
|
||||
initBandbox();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void pickElementFromListAndCloseBandbox() {
|
||||
if(getSelectedItem() != null) {
|
||||
if ( getSelectedItem() != null ) {
|
||||
final Object object = getSelectedItem().getValue();
|
||||
if (multipleFiltersFinder.isValidNewFilter(selectedFilters, object)) {
|
||||
if ( multipleFiltersFinder.isValidNewFilter(selectedFilters, object) ) {
|
||||
addSelectedElement(object);
|
||||
clearListbox();
|
||||
listbox.setModel(getSubModel());
|
||||
|
|
@ -186,16 +189,16 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
|
||||
private void searchMultipleFilters(String inputText) {
|
||||
// update the filters list if some filter was deleted
|
||||
boolean someRemoved = multipleFiltersFinder.updateDeletedFilters(
|
||||
selectedFilters, inputText);
|
||||
if (someRemoved) {
|
||||
boolean someRemoved = multipleFiltersFinder.updateDeletedFilters(selectedFilters, inputText);
|
||||
|
||||
if ( someRemoved ) {
|
||||
updateselectedFiltersText();
|
||||
updateBandboxValue();
|
||||
} else {
|
||||
// find the filter set to show it in the listbox
|
||||
String newFilterText = multipleFiltersFinder
|
||||
.getNewFilterText(inputText);
|
||||
if ((newFilterText != null) && (!newFilterText.isEmpty())) {
|
||||
String newFilterText = multipleFiltersFinder.getNewFilterText(inputText);
|
||||
|
||||
if ( (newFilterText != null) && (!newFilterText.isEmpty()) ) {
|
||||
listbox.setModel(getSubModel(newFilterText));
|
||||
listbox.invalidate();
|
||||
} else {
|
||||
|
|
@ -213,7 +216,7 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
public void addSelectedElement(Object obj) {
|
||||
if (obj != null) {
|
||||
if ( obj != null ) {
|
||||
addFilter(obj);
|
||||
updateselectedFiltersText();
|
||||
updateBandboxValue();
|
||||
|
|
@ -223,10 +226,11 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
private void addFilter(Object obj) {
|
||||
FilterPair newFilter = (FilterPair) obj;
|
||||
for (FilterPair filter : (List<FilterPair>) selectedFilters) {
|
||||
if ((filter.getType().equals(newFilter.getType()))
|
||||
&& (filter.getPattern().equals(newFilter.getPattern()))) {
|
||||
throw new WrongValueException(bandbox,
|
||||
_("filter already exists"));
|
||||
|
||||
if ( (filter.getType().equals(newFilter.getType())) &&
|
||||
(filter.getPattern().equals(newFilter.getPattern())) ) {
|
||||
|
||||
throw new WrongValueException(bandbox, _("filter already exists"));
|
||||
}
|
||||
}
|
||||
selectedFilters.add(obj);
|
||||
|
|
@ -234,13 +238,12 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
|
||||
public List getSelectedElements() {
|
||||
updateBandboxValue();
|
||||
if (this.multipleFiltersFinder != null) {
|
||||
if (!multipleFiltersFinder.isValidFormatText(selectedFilters,
|
||||
bandbox.getValue())) {
|
||||
throw new WrongValueException(bandbox,
|
||||
_("format filters are not valid"));
|
||||
if ( this.multipleFiltersFinder != null ) {
|
||||
if ( !multipleFiltersFinder.isValidFormatText(selectedFilters, bandbox.getValue()) ) {
|
||||
throw new WrongValueException(bandbox, _("format filters are not valid"));
|
||||
}
|
||||
}
|
||||
|
||||
return selectedFilters;
|
||||
}
|
||||
|
||||
|
|
@ -250,6 +253,7 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
@SuppressWarnings("unchecked")
|
||||
private ListModel getSubModel() {
|
||||
List result = multipleFiltersFinder.getFirstTenFilters();
|
||||
|
||||
return new SimpleListModel(result);
|
||||
}
|
||||
|
||||
|
|
@ -260,6 +264,7 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
@SuppressWarnings("unchecked")
|
||||
private ListModel getSubModel(String inputText) {
|
||||
List result = multipleFiltersFinder.getMatching(inputText);
|
||||
|
||||
return new SimpleListModel(result);
|
||||
}
|
||||
|
||||
|
|
@ -270,13 +275,13 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
public void addHeaders() {
|
||||
clearHeaderIfNecessary();
|
||||
final String[] headers = multipleFiltersFinder.getHeaders();
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
listhead.getChildren().add(new Listheader(_(headers[i])));
|
||||
for (String header : headers) {
|
||||
listhead.getChildren().add(new Listheader(_(header)));
|
||||
}
|
||||
}
|
||||
|
||||
private void clearHeaderIfNecessary() {
|
||||
if (listhead.getChildren() != null) {
|
||||
if ( listhead.getChildren() != null ) {
|
||||
listhead.getChildren().clear();
|
||||
}
|
||||
}
|
||||
|
|
@ -295,12 +300,12 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
private Object getBean(String beanName) {
|
||||
HttpServletRequest servletRequest = (HttpServletRequest) Executions
|
||||
.getCurrent().getNativeRequest();
|
||||
ServletContext servletContext = servletRequest.getSession()
|
||||
.getServletContext();
|
||||
WebApplicationContext webApplicationContext = WebApplicationContextUtils
|
||||
.getWebApplicationContext(servletContext);
|
||||
HttpServletRequest servletRequest = (HttpServletRequest) Executions.getCurrent().getNativeRequest();
|
||||
ServletContext servletContext = servletRequest.getSession().getServletContext();
|
||||
|
||||
WebApplicationContext webApplicationContext =
|
||||
WebApplicationContextUtils.getWebApplicationContext(servletContext);
|
||||
|
||||
return webApplicationContext.getBean(beanName);
|
||||
}
|
||||
|
||||
|
|
@ -309,8 +314,7 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
public void setFinder(String classname) {
|
||||
multipleFiltersFinder = (IMultipleFiltersFinder) getBean(StringUtils
|
||||
.uncapitalize(classname));
|
||||
multipleFiltersFinder = (IMultipleFiltersFinder) getBean(StringUtils.uncapitalize(classname));
|
||||
initFinder();
|
||||
}
|
||||
|
||||
|
|
@ -324,16 +328,17 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
private void clearListbox() {
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
List<Object> list = new ArrayList<>();
|
||||
listbox.setModel(new SimpleListModel(list));
|
||||
listbox.invalidate();
|
||||
}
|
||||
|
||||
public List<Object> asList(ListModel model) {
|
||||
List<Object> result = new ArrayList<Object>();
|
||||
List<Object> result = new ArrayList<>();
|
||||
for (int i = 0; i < model.getSize(); i++) {
|
||||
result.add(model.getElementAt(i));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -358,14 +363,14 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
private void updateWidth() {
|
||||
if ((widthBandbox != null) && (!widthBandbox.isEmpty())) {
|
||||
if ( (widthBandbox != null) && (!widthBandbox.isEmpty()) ) {
|
||||
this.bandbox.setWidth(widthBandbox);
|
||||
this.listbox.setWidth(widthListbox);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateHeight() {
|
||||
if ((heightBbox != null) && (!heightBbox.isEmpty())) {
|
||||
if ( (heightBbox != null) && (!heightBbox.isEmpty()) ) {
|
||||
this.bandbox.setHeight(heightBbox);
|
||||
}
|
||||
}
|
||||
|
|
@ -377,8 +382,7 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
private void updateselectedFiltersText() {
|
||||
selectedFiltersText = "";
|
||||
for (Object obj : selectedFilters) {
|
||||
selectedFiltersText = selectedFiltersText
|
||||
.concat(multipleFiltersFinder.objectToString(obj));
|
||||
selectedFiltersText = selectedFiltersText.concat(multipleFiltersFinder.objectToString(obj));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -392,9 +396,11 @@ public class BandboxMultipleSearch extends HtmlMacroComponent {
|
|||
|
||||
public void addSelectedElements(List<FilterPair> sessionFilterPairs) {
|
||||
selectedFilters.clear();
|
||||
|
||||
for (FilterPair filterPair : sessionFilterPairs) {
|
||||
addFilter(filterPair);
|
||||
}
|
||||
|
||||
updateselectedFiltersText();
|
||||
updateBandboxValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import java.util.Collections;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections.comparators.BooleanComparator;
|
||||
import org.apache.commons.collections4.comparators.BooleanComparator;
|
||||
import org.libreplan.business.planner.limiting.entities.Gap.GapOnQueue;
|
||||
|
||||
|
||||
|
|
@ -45,12 +45,12 @@ public class GapsMergeSort {
|
|||
*/
|
||||
private static class CurrentGap implements Comparable<CurrentGap> {
|
||||
|
||||
static List<CurrentGap> convert(
|
||||
Collection<? extends Iterator<GapOnQueue>> iterators) {
|
||||
List<CurrentGap> result = new ArrayList<CurrentGap>();
|
||||
static List<CurrentGap> convert(Collection<? extends Iterator<GapOnQueue>> iterators) {
|
||||
List<CurrentGap> result = new ArrayList<>();
|
||||
for (Iterator<GapOnQueue> iterator : iterators) {
|
||||
result.add(new CurrentGap(iterator));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -65,6 +65,7 @@ public class GapsMergeSort {
|
|||
public GapOnQueue consume() {
|
||||
GapOnQueue result = getCurrent();
|
||||
current = null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -73,12 +74,14 @@ public class GapsMergeSort {
|
|||
}
|
||||
|
||||
private GapOnQueue getCurrent() {
|
||||
if (hasFinished()) {
|
||||
if ( hasFinished() ) {
|
||||
throw new IllegalStateException("already finished");
|
||||
}
|
||||
if (current != null) {
|
||||
|
||||
if ( current != null ) {
|
||||
return current;
|
||||
}
|
||||
|
||||
return current = iterator.next();
|
||||
}
|
||||
|
||||
|
|
@ -88,53 +91,61 @@ public class GapsMergeSort {
|
|||
*/
|
||||
@Override
|
||||
public int compareTo(CurrentGap other) {
|
||||
int finishComparison = BooleanComparator.getFalseFirstComparator()
|
||||
.compare(hasFinished(), other.hasFinished());
|
||||
if (finishComparison != 0) {
|
||||
int finishComparison =
|
||||
BooleanComparator.getFalseFirstComparator().compare(hasFinished(), other.hasFinished());
|
||||
|
||||
if ( finishComparison != 0 ) {
|
||||
return finishComparison;
|
||||
} else if (hasFinished()) {
|
||||
} else if ( hasFinished() ) {
|
||||
assert other.hasFinished();
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
assert !hasFinished() && !other.hasFinished();
|
||||
return getCurrent().getGap().compareTo(
|
||||
other.getCurrent().getGap());
|
||||
|
||||
return getCurrent().getGap().compareTo(other.getCurrent().getGap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<GapOnQueue> sort(
|
||||
List<List<GapOnQueue>> orderedListsOfGaps) {
|
||||
public static List<GapOnQueue> sort(List<List<GapOnQueue>> orderedListsOfGaps) {
|
||||
|
||||
List<GapOnQueue> result = new ArrayList<GapOnQueue>();
|
||||
List<GapOnQueue> result = new ArrayList<>();
|
||||
|
||||
if (orderedListsOfGaps.isEmpty()) {
|
||||
if ( orderedListsOfGaps.isEmpty() ) {
|
||||
return result;
|
||||
}
|
||||
if (orderedListsOfGaps.size() == 1) {
|
||||
|
||||
if ( orderedListsOfGaps.size() == 1 ) {
|
||||
return orderedListsOfGaps.get(0);
|
||||
}
|
||||
|
||||
List<CurrentGap> currentGaps = CurrentGap.convert(iteratorsFor(orderedListsOfGaps));
|
||||
CurrentGap min = Collections.min(currentGaps);
|
||||
|
||||
while (!currentGaps.isEmpty() && !min.hasFinished()) {
|
||||
|
||||
result.add(min.consume());
|
||||
if (min.hasFinished()) {
|
||||
|
||||
if ( min.hasFinished() ) {
|
||||
|
||||
currentGaps.remove(min);
|
||||
if (!currentGaps.isEmpty()) {
|
||||
|
||||
if ( !currentGaps.isEmpty() ) {
|
||||
min = Collections.min(currentGaps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<Iterator<GapOnQueue>> iteratorsFor(
|
||||
List<List<GapOnQueue>> orderedListsOfGaps) {
|
||||
List<Iterator<GapOnQueue>> result = new ArrayList<Iterator<GapOnQueue>>();
|
||||
private static List<Iterator<GapOnQueue>> iteratorsFor(List<List<GapOnQueue>> orderedListsOfGaps) {
|
||||
List<Iterator<GapOnQueue>> result = new ArrayList<>();
|
||||
for (List<GapOnQueue> each : orderedListsOfGaps) {
|
||||
result.add(each.iterator());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,10 +53,9 @@ public class ResourcesLoadTabCreator {
|
|||
ResourceLoadController resourceLoadControllerGlobal,
|
||||
IOrderPlanningGate orderPlanningGate,
|
||||
Component breadcrumbs) {
|
||||
return new ResourcesLoadTabCreator(mode, resourceLoadController,
|
||||
resourceLoadControllerGlobal, orderPlanningGate,
|
||||
breadcrumbs)
|
||||
.build();
|
||||
|
||||
return new ResourcesLoadTabCreator(
|
||||
mode, resourceLoadController, resourceLoadControllerGlobal, orderPlanningGate, breadcrumbs).build();
|
||||
}
|
||||
|
||||
private final Mode mode;
|
||||
|
|
@ -71,6 +70,7 @@ public class ResourcesLoadTabCreator {
|
|||
ResourceLoadController resourceLoadControllerGlobal,
|
||||
IOrderPlanningGate orderPlanningGate,
|
||||
Component breadcrumbs) {
|
||||
|
||||
this.mode = mode;
|
||||
this.resourceLoadController = resourceLoadController;
|
||||
this.resourceLoadControllerGlobal = resourceLoadControllerGlobal;
|
||||
|
|
@ -87,20 +87,16 @@ public class ResourcesLoadTabCreator {
|
|||
|
||||
private ITab createOrderResourcesLoadTab() {
|
||||
IComponentCreator componentCreator = new IComponentCreator() {
|
||||
|
||||
@Override
|
||||
public org.zkoss.zk.ui.Component create(
|
||||
org.zkoss.zk.ui.Component parent) {
|
||||
Map<String, Object> arguments = new HashMap<String, Object>();
|
||||
public org.zkoss.zk.ui.Component create(org.zkoss.zk.ui.Component parent) {
|
||||
Map<String, Object> arguments = new HashMap<>();
|
||||
arguments.put("resourceLoadController", resourceLoadController);
|
||||
return Executions.createComponents(
|
||||
"/resourceload/_resourceloadfororder.zul", parent,
|
||||
arguments);
|
||||
|
||||
return Executions.createComponents("/resourceload/_resourceloadfororder.zul", parent, arguments);
|
||||
}
|
||||
|
||||
};
|
||||
return new CreatedOnDemandTab(_("Resources Load"), "order-load",
|
||||
componentCreator) {
|
||||
return new CreatedOnDemandTab(_("Resources Load"), "order-load", componentCreator) {
|
||||
|
||||
@Override
|
||||
protected void afterShowAction() {
|
||||
|
|
@ -111,8 +107,7 @@ public class ResourcesLoadTabCreator {
|
|||
breadcrumbs.appendChild(new Label(_("Resources Load")));
|
||||
breadcrumbs.appendChild(new Image(BREADCRUMBS_SEPARATOR));
|
||||
Order currentOrder = mode.getOrder();
|
||||
resourceLoadController
|
||||
.setPlanningControllerEntryPoints(orderPlanningGate);
|
||||
resourceLoadController.setPlanningControllerEntryPoints(orderPlanningGate);
|
||||
resourceLoadController.filterBy(currentOrder);
|
||||
resourceLoadController.reload();
|
||||
breadcrumbs.appendChild(new Label(currentOrder.getName()));
|
||||
|
|
@ -123,37 +118,33 @@ public class ResourcesLoadTabCreator {
|
|||
private ITab createGlobalResourcesLoadTab() {
|
||||
|
||||
final IComponentCreator componentCreator = new IComponentCreator() {
|
||||
|
||||
@Override
|
||||
public org.zkoss.zk.ui.Component create(
|
||||
org.zkoss.zk.ui.Component parent) {
|
||||
Map<String, Object> arguments = new HashMap<String, Object>();
|
||||
arguments.put("resourceLoadController",
|
||||
resourceLoadControllerGlobal);
|
||||
return Executions.createComponents(
|
||||
"/resourceload/_resourceload.zul", parent, arguments);
|
||||
public org.zkoss.zk.ui.Component create(org.zkoss.zk.ui.Component parent) {
|
||||
Map<String, Object> arguments = new HashMap<>();
|
||||
arguments.put("resourceLoadController", resourceLoadControllerGlobal);
|
||||
|
||||
return Executions.createComponents("/resourceload/_resourceload.zul", parent, arguments);
|
||||
}
|
||||
|
||||
};
|
||||
return new CreatedOnDemandTab(_("Resources Load"), "company-load",
|
||||
componentCreator) {
|
||||
return new CreatedOnDemandTab(_("Resources Load"), "company-load", componentCreator) {
|
||||
@Override
|
||||
protected void beforeShowAction() {
|
||||
if (!SecurityUtils
|
||||
.isSuperuserOrUserInRoles(UserRole.ROLE_PLANNING)) {
|
||||
if ( !SecurityUtils.isSuperuserOrUserInRoles(UserRole.ROLE_PLANNING) ) {
|
||||
Util.sendForbiddenStatusCodeInHttpServletResponse();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterShowAction() {
|
||||
resourceLoadControllerGlobal
|
||||
.setPlanningControllerEntryPoints(orderPlanningGate);
|
||||
resourceLoadControllerGlobal.setPlanningControllerEntryPoints(orderPlanningGate);
|
||||
resourceLoadControllerGlobal.filterBy(null);
|
||||
resourceLoadControllerGlobal.reload();
|
||||
if (breadcrumbs.getChildren() != null) {
|
||||
|
||||
if ( breadcrumbs.getChildren() != null ) {
|
||||
breadcrumbs.getChildren().clear();
|
||||
}
|
||||
|
||||
breadcrumbs.appendChild(new Image(BREADCRUMBS_SEPARATOR));
|
||||
breadcrumbs.appendChild(new Label(getSchedulingLabel()));
|
||||
breadcrumbs.appendChild(new Image(BREADCRUMBS_SEPARATOR));
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public class ResourceLoadController implements Composer {
|
|||
@Autowired
|
||||
private IAdHocTransactionService transactionService;
|
||||
|
||||
private List<IToolbarCommand> commands = new ArrayList<IToolbarCommand>();
|
||||
private List<IToolbarCommand> commands = new ArrayList<>();
|
||||
|
||||
private PlanningState filterBy;
|
||||
|
||||
|
|
@ -177,25 +177,28 @@ public class ResourceLoadController implements Composer {
|
|||
private List<VisualizationModifier> visualizationModifiers = null;
|
||||
|
||||
private List<VisualizationModifier> getVisualizationModifiers() {
|
||||
if (visualizationModifiers != null) {
|
||||
if ( visualizationModifiers != null ) {
|
||||
return visualizationModifiers;
|
||||
}
|
||||
|
||||
return visualizationModifiers = buildVisualizationModifiers();
|
||||
}
|
||||
|
||||
private List<IListenerAdder> listenersToAdd = null;
|
||||
|
||||
private List<IListenerAdder> getListenersToAdd() {
|
||||
if (listenersToAdd != null) {
|
||||
if ( listenersToAdd != null ) {
|
||||
return listenersToAdd;
|
||||
}
|
||||
List<IListenerAdder> result = new ArrayList<IListenerAdder>();
|
||||
|
||||
List<IListenerAdder> result = new ArrayList<>();
|
||||
for (VisualizationModifier each : getVisualizationModifiers()) {
|
||||
if (each instanceof IListenerAdder) {
|
||||
if ( each instanceof IListenerAdder ) {
|
||||
result.add((IListenerAdder) each);
|
||||
}
|
||||
}
|
||||
result.add(new GoToScheduleListener());
|
||||
|
||||
return listenersToAdd = result;
|
||||
}
|
||||
|
||||
|
|
@ -209,10 +212,10 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
public IOnTransaction<Void> reload() {
|
||||
return new IOnTransaction<Void>() {
|
||||
|
||||
@Override
|
||||
public Void execute() {
|
||||
reloadInTransaction();
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
|
@ -222,8 +225,9 @@ public class ResourceLoadController implements Composer {
|
|||
for (VisualizationModifier each : getVisualizationModifiers()) {
|
||||
each.checkDependencies();
|
||||
}
|
||||
ResourceLoadParameters parameters = new ResourceLoadParameters(
|
||||
filterBy);
|
||||
|
||||
ResourceLoadParameters parameters = new ResourceLoadParameters(filterBy);
|
||||
|
||||
for (VisualizationModifier each : getVisualizationModifiers()) {
|
||||
each.applyToParameters(parameters);
|
||||
}
|
||||
|
|
@ -231,17 +235,19 @@ public class ResourceLoadController implements Composer {
|
|||
ResourceLoadDisplayData dataToShow = resourceLoadModel.calculateDataToDisplay(parameters);
|
||||
|
||||
timeTracker = buildTimeTracker(dataToShow);
|
||||
if (resourcesLoadPanel == null) {
|
||||
|
||||
if ( resourcesLoadPanel == null ) {
|
||||
resourcesLoadPanel = buildPanel(dataToShow);
|
||||
listeners.addListeners(resourcesLoadPanel, getListenersToAdd());
|
||||
parent.getChildren().clear();
|
||||
parent.appendChild(resourcesLoadPanel);
|
||||
|
||||
for (VisualizationModifier each : getVisualizationModifiers()) {
|
||||
each.setup(resourcesLoadPanel);
|
||||
}
|
||||
|
||||
} else {
|
||||
resourcesLoadPanel.init(dataToShow.getLoadTimeLines(),
|
||||
timeTracker);
|
||||
resourcesLoadPanel.init(dataToShow.getLoadTimeLines(), timeTracker);
|
||||
listeners.addListeners(resourcesLoadPanel, getListenersToAdd());
|
||||
}
|
||||
|
||||
|
|
@ -255,27 +261,33 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
private TimeTracker buildTimeTracker(ResourceLoadDisplayData dataToShow) {
|
||||
ZoomLevel zoomLevel = getZoomLevel(dataToShow);
|
||||
TimeTracker result = new TimeTracker(dataToShow.getViewInterval(),
|
||||
zoomLevel, SeveralModificators.create(),
|
||||
|
||||
TimeTracker result = new TimeTracker(
|
||||
dataToShow.getViewInterval(),
|
||||
zoomLevel,
|
||||
SeveralModificators.create(),
|
||||
SeveralModificators.create(createBankHolidaysMarker()),
|
||||
parent);
|
||||
|
||||
setupZoomLevelListener(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private ZoomLevel getZoomLevel(ResourceLoadDisplayData dataToShow) {
|
||||
if (filterBy != null) {
|
||||
if ( filterBy != null ) {
|
||||
Order order = filterBy.getOrder();
|
||||
ZoomLevel sessionZoom = FilterUtils.readZoomLevel(order);
|
||||
if (sessionZoom != null) {
|
||||
if ( sessionZoom != null ) {
|
||||
return sessionZoom;
|
||||
}
|
||||
}
|
||||
|
||||
ZoomLevel sessionZoom = FilterUtils.readZoomLevelResourcesLoad();
|
||||
if (sessionZoom != null) {
|
||||
if ( sessionZoom != null ) {
|
||||
return sessionZoom;
|
||||
}
|
||||
|
||||
return dataToShow.getInitialZoomLevel();
|
||||
}
|
||||
|
||||
|
|
@ -285,11 +297,10 @@ public class ResourceLoadController implements Composer {
|
|||
}
|
||||
|
||||
private IZoomLevelChangedListener getSessionZoomLevelListener() {
|
||||
IZoomLevelChangedListener zoomListener = new IZoomLevelChangedListener() {
|
||||
|
||||
return new IZoomLevelChangedListener() {
|
||||
@Override
|
||||
public void zoomLevelChanged(ZoomLevel detailLevel) {
|
||||
if (filterBy != null) {
|
||||
if ( filterBy != null ) {
|
||||
Order order = filterBy.getOrder();
|
||||
FilterUtils.writeZoomLevel(order, detailLevel);
|
||||
} else {
|
||||
|
|
@ -297,12 +308,11 @@ public class ResourceLoadController implements Composer {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
return zoomListener;
|
||||
}
|
||||
|
||||
private ResourcesLoadPanel buildPanel(ResourceLoadDisplayData dataToShow) {
|
||||
return new ResourcesLoadPanel(dataToShow.getLoadTimeLines(),
|
||||
return new ResourcesLoadPanel(
|
||||
dataToShow.getLoadTimeLines(),
|
||||
timeTracker, parent,
|
||||
resourceLoadModel.isExpandResourceLoadViewCharts(),
|
||||
PaginationType.EXTERNAL_PAGINATION);
|
||||
|
|
@ -310,66 +320,60 @@ public class ResourceLoadController implements Composer {
|
|||
}
|
||||
|
||||
private List<VisualizationModifier> buildVisualizationModifiers() {
|
||||
List<VisualizationModifier> result = new ArrayList<VisualizationModifier>();
|
||||
FilterTypeChanger filterTypeChanger = new FilterTypeChanger(onChange,
|
||||
filterBy);
|
||||
List<VisualizationModifier> result = new ArrayList<>();
|
||||
FilterTypeChanger filterTypeChanger = new FilterTypeChanger(onChange, filterBy);
|
||||
result.add(filterTypeChanger);
|
||||
|
||||
// Only by dates and bandbox filter on global resources load
|
||||
if (filterBy == null) {
|
||||
if ( filterBy == null ) {
|
||||
LocalDate startDate = FilterUtils.readResourceLoadsStartDate();
|
||||
LocalDate endDate = FilterUtils.readResourceLoadsEndDate();
|
||||
|
||||
User user = resourceLoadModel.getUser();
|
||||
|
||||
// Calculate filter based on user preferences
|
||||
if (user != null) {
|
||||
if (startDate == null
|
||||
&& !FilterUtils.hasResourceLoadsStartDateChanged()) {
|
||||
if (user.getResourcesLoadFilterPeriodSince() != null) {
|
||||
startDate = new LocalDate().minusMonths(user
|
||||
.getResourcesLoadFilterPeriodSince());
|
||||
if ( user != null ) {
|
||||
if ( startDate == null && !FilterUtils.hasResourceLoadsStartDateChanged() ) {
|
||||
if ( user.getResourcesLoadFilterPeriodSince() != null ) {
|
||||
startDate = new LocalDate().minusMonths(user.getResourcesLoadFilterPeriodSince());
|
||||
} else {
|
||||
// Default filter start
|
||||
startDate = new LocalDate().minusDays(1);
|
||||
}
|
||||
}
|
||||
if ((endDate == null)
|
||||
&& !FilterUtils.hasResourceLoadsEndDateChanged()
|
||||
&& (user.getResourcesLoadFilterPeriodTo() != null)) {
|
||||
endDate = new LocalDate().plusMonths(user
|
||||
.getResourcesLoadFilterPeriodTo());
|
||||
if ( (endDate == null) &&
|
||||
!FilterUtils.hasResourceLoadsEndDateChanged() &&
|
||||
(user.getResourcesLoadFilterPeriodTo() != null) ) {
|
||||
|
||||
endDate = new LocalDate().plusMonths(user.getResourcesLoadFilterPeriodTo());
|
||||
}
|
||||
}
|
||||
|
||||
result.add(new ByDatesFilter(onChange, filterBy, startDate, endDate));
|
||||
|
||||
List<FilterPair> filterPairs = (List<FilterPair>) FilterUtils
|
||||
.readResourceLoadsBandbox();
|
||||
if ((filterPairs == null || filterPairs.isEmpty())
|
||||
&& user.getResourcesLoadFilterCriterion() != null) {
|
||||
filterPairs = new ArrayList<FilterPair>();
|
||||
List<FilterPair> filterPairs = FilterUtils.readResourceLoadsBandbox();
|
||||
if ( (filterPairs == null || filterPairs.isEmpty()) && user.getResourcesLoadFilterCriterion() != null ) {
|
||||
filterPairs = new ArrayList<>();
|
||||
filterPairs.add(new FilterPair(
|
||||
ResourceAllocationFilterEnum.Criterion, user
|
||||
.getResourcesLoadFilterCriterion()
|
||||
.getFinderPattern(), user
|
||||
.getResourcesLoadFilterCriterion()));
|
||||
ResourceAllocationFilterEnum.Criterion,
|
||||
user.getResourcesLoadFilterCriterion().getFinderPattern(),
|
||||
user.getResourcesLoadFilterCriterion()));
|
||||
}
|
||||
|
||||
WorkersOrCriteriaBandbox bandbox = new WorkersOrCriteriaBandbox(
|
||||
onChange, filterBy, filterTypeChanger, resourcesSearcher, filterPairs);
|
||||
WorkersOrCriteriaBandbox bandbox =
|
||||
new WorkersOrCriteriaBandbox(onChange, filterBy, filterTypeChanger, resourcesSearcher, filterPairs);
|
||||
|
||||
result.add(bandbox);
|
||||
result.add(new ByNamePaginator(onChange, filterBy, filterTypeChanger,
|
||||
bandbox));
|
||||
result.add(new ByNamePaginator(onChange, filterBy, filterTypeChanger, bandbox));
|
||||
}
|
||||
result.add(new LoadChart(onChange, filterBy));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public interface IListenerAdder {
|
||||
|
||||
public Object addAndReturnListener(ResourcesLoadPanel panel);
|
||||
Object addAndReturnListener(ResourcesLoadPanel panel);
|
||||
}
|
||||
|
||||
private class GoToScheduleListener implements IListenerAdder {
|
||||
|
|
@ -377,13 +381,14 @@ public class ResourceLoadController implements Composer {
|
|||
@Override
|
||||
public Object addAndReturnListener(ResourcesLoadPanel panel) {
|
||||
ISeeScheduledOfListener listener = new ISeeScheduledOfListener() {
|
||||
|
||||
@Override
|
||||
public void seeScheduleOf(LoadTimeLine taskLine) {
|
||||
onSeeScheduleOf(taskLine);
|
||||
}
|
||||
};
|
||||
|
||||
panel.addSeeScheduledOfListener(listener);
|
||||
|
||||
return listener;
|
||||
}
|
||||
|
||||
|
|
@ -394,26 +399,25 @@ public class ResourceLoadController implements Composer {
|
|||
TaskElement task = (TaskElement) taskLine.getRole().getEntity();
|
||||
Order order = resourceLoadModel.getOrderByTask(task);
|
||||
|
||||
if (resourceLoadModel.userCanRead(order,
|
||||
SecurityUtils.getSessionUserLoginName())) {
|
||||
if (order.isScheduled()) {
|
||||
planningControllerEntryPoints.goToTaskResourceAllocation(order,
|
||||
task);
|
||||
if ( resourceLoadModel.userCanRead(order, SecurityUtils.getSessionUserLoginName()) ) {
|
||||
if ( order.isScheduled() ) {
|
||||
planningControllerEntryPoints.goToTaskResourceAllocation(order, task);
|
||||
} else {
|
||||
try {
|
||||
Messagebox.show(_("The project has no scheduled elements"),
|
||||
_("Information"), Messagebox.OK,
|
||||
Messagebox.INFORMATION);
|
||||
Messagebox.show(
|
||||
_("The project has no scheduled elements"), _("Information"),
|
||||
Messagebox.OK, Messagebox.INFORMATION);
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Messagebox
|
||||
.show(_("You don't have read access to this project"),
|
||||
_("Information"), Messagebox.OK,
|
||||
Messagebox.INFORMATION);
|
||||
Messagebox.show(
|
||||
_("You don't have read access to this project"), _("Information"),
|
||||
Messagebox.OK, Messagebox.INFORMATION);
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
@ -456,8 +460,7 @@ public class ResourceLoadController implements Composer {
|
|||
}
|
||||
}
|
||||
|
||||
private static class FilterTypeChanger extends VisualizationModifier
|
||||
implements IListenerAdder {
|
||||
private static class FilterTypeChanger extends VisualizationModifier implements IListenerAdder {
|
||||
|
||||
private boolean filterByResources = true;
|
||||
|
||||
|
|
@ -477,16 +480,17 @@ public class ResourceLoadController implements Composer {
|
|||
@Override
|
||||
public Object addAndReturnListener(ResourcesLoadPanel panel) {
|
||||
IFilterChangedListener listener = new IFilterChangedListener() {
|
||||
|
||||
@Override
|
||||
public void filterChanged(boolean newValue) {
|
||||
if (filterByResources != newValue) {
|
||||
if ( filterByResources != newValue ) {
|
||||
filterByResources = newValue;
|
||||
notifyChange();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
panel.addFilterListener(listener);
|
||||
|
||||
return listener;
|
||||
}
|
||||
}
|
||||
|
|
@ -501,32 +505,33 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
private final Datebox endBox = new Datebox();
|
||||
|
||||
private ByDatesFilter(Runnable onChange, PlanningState filterBy,
|
||||
LocalDate startDate, LocalDate endDate) {
|
||||
private ByDatesFilter(Runnable onChange, PlanningState filterBy, LocalDate startDate, LocalDate endDate) {
|
||||
super(onChange, filterBy);
|
||||
startDateValue = (isAppliedToOrder() || (startDate == null)) ? null
|
||||
: startDate
|
||||
.toDateTimeAtStartOfDay().toLocalDate();
|
||||
endDateValue = (endDate == null) ? null : endDate
|
||||
.toDateMidnight().toLocalDate();
|
||||
|
||||
startDateValue = (isAppliedToOrder() || (startDate == null)) ? null :
|
||||
startDate.toDateTimeAtStartOfDay().toLocalDate();
|
||||
|
||||
endDateValue = (endDate == null) ? null : endDate.toDateMidnight().toLocalDate();
|
||||
}
|
||||
|
||||
@Override
|
||||
void setup(ResourcesLoadPanel panel) {
|
||||
if (isAppliedToOrder()) {
|
||||
if ( isAppliedToOrder() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
panel.setFirstOptionalFilter(buildTimeFilter());
|
||||
}
|
||||
|
||||
private Hbox buildTimeFilter() {
|
||||
startBox.setValue(asDate(startDateValue));
|
||||
startBox.setWidth("100px");
|
||||
|
||||
startBox.addEventListener(Events.ON_CHANGE, new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
LocalDate newStart = toLocal(startBox.getValue());
|
||||
if (!ObjectUtils.equals(startDateValue, newStart)) {
|
||||
if ( !ObjectUtils.equals(startDateValue, newStart) ) {
|
||||
startDateValue = newStart;
|
||||
FilterUtils.writeResourceLoadsStartDate(startDateValue);
|
||||
notifyChange();
|
||||
|
|
@ -536,11 +541,12 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
endBox.setValue(asDate(endDateValue));
|
||||
endBox.setWidth("100px");
|
||||
|
||||
endBox.addEventListener(Events.ON_CHANGE, new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
LocalDate newEnd = toLocal(endBox.getValue());
|
||||
if (!ObjectUtils.equals(endBox, newEnd)) {
|
||||
if ( !ObjectUtils.equals(endBox, newEnd) ) {
|
||||
endDateValue = newEnd;
|
||||
FilterUtils.writeResourceLoadsEndDate(endDateValue);
|
||||
notifyChange();
|
||||
|
|
@ -554,6 +560,7 @@ public class ResourceLoadController implements Composer {
|
|||
hbox.appendChild(new Label(_("To") + ":"));
|
||||
hbox.appendChild(endBox);
|
||||
hbox.setAlign("center");
|
||||
|
||||
return hbox;
|
||||
}
|
||||
|
||||
|
|
@ -565,16 +572,15 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
}
|
||||
|
||||
private static abstract class DependingOnFiltering extends
|
||||
VisualizationModifier {
|
||||
private static abstract class DependingOnFiltering extends VisualizationModifier {
|
||||
|
||||
private final FilterTypeChanger filterType;
|
||||
|
||||
private boolean filteringByResource;
|
||||
|
||||
DependingOnFiltering(Runnable onChange, PlanningState filterBy,
|
||||
FilterTypeChanger filterType) {
|
||||
DependingOnFiltering(Runnable onChange, PlanningState filterBy, FilterTypeChanger filterType) {
|
||||
super(onChange, filterBy);
|
||||
|
||||
this.filterType = filterType;
|
||||
this.filteringByResource = filterType.isFilterByResources();
|
||||
}
|
||||
|
|
@ -585,7 +591,7 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
@Override
|
||||
void checkDependencies() {
|
||||
if (this.filteringByResource != filterType.isFilterByResources()) {
|
||||
if ( this.filteringByResource != filterType.isFilterByResources() ) {
|
||||
this.filteringByResource = filterType.isFilterByResources();
|
||||
filterTypeChanged();
|
||||
}
|
||||
|
|
@ -606,15 +612,17 @@ public class ResourceLoadController implements Composer {
|
|||
private Label label = new Label();
|
||||
|
||||
private WorkersOrCriteriaBandbox(Runnable onChange,
|
||||
PlanningState filterBy, FilterTypeChanger filterType,
|
||||
PlanningState filterBy,
|
||||
FilterTypeChanger filterType,
|
||||
IResourcesSearcher resourcesSearcher,
|
||||
List<FilterPair> selectedFilters) {
|
||||
|
||||
super(onChange, filterBy, filterType);
|
||||
this.resourcesSearcher = resourcesSearcher;
|
||||
|
||||
initBandbox();
|
||||
|
||||
if ((selectedFilters != null) && !selectedFilters.isEmpty()) {
|
||||
if ( (selectedFilters != null) && !selectedFilters.isEmpty() ) {
|
||||
for (FilterPair filterPair : selectedFilters) {
|
||||
bandBox.addSelectedElement(filterPair);
|
||||
}
|
||||
|
|
@ -624,9 +632,10 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
@Override
|
||||
void setup(ResourcesLoadPanel panel) {
|
||||
if (isAppliedToOrder()) {
|
||||
if ( isAppliedToOrder() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
panel.setSecondOptionalFilter(buildBandboxFilterer());
|
||||
}
|
||||
|
||||
|
|
@ -641,8 +650,7 @@ public class ResourceLoadController implements Composer {
|
|||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
entitiesSelected = getSelected();
|
||||
FilterUtils.writeResourceLoadsParameters(bandBox
|
||||
.getSelectedElements());
|
||||
FilterUtils.writeResourceLoadsParameters(bandBox.getSelectedElements());
|
||||
notifyChange();
|
||||
}
|
||||
});
|
||||
|
|
@ -659,11 +667,12 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
private Label getLabel() {
|
||||
updateLabelValue();
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
private void updateLabelValue() {
|
||||
if (isFilteringByResource()) {
|
||||
if ( isFilteringByResource() ) {
|
||||
label.setValue(_("Resources or criteria") + ":");
|
||||
} else {
|
||||
label.setValue(_("Criteria") + ":");
|
||||
|
|
@ -671,7 +680,7 @@ public class ResourceLoadController implements Composer {
|
|||
}
|
||||
|
||||
private String getFinderToUse() {
|
||||
if (isFilteringByResource()) {
|
||||
if ( isFilteringByResource() ) {
|
||||
return "resourceMultipleFiltersFinderByResourceAndCriterion";
|
||||
} else {
|
||||
return "criterionMultipleFiltersFinder";
|
||||
|
|
@ -680,9 +689,10 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
@Override
|
||||
protected void filterTypeChanged() {
|
||||
if (isAppliedToOrder()) {
|
||||
if ( isAppliedToOrder() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
entitiesSelected = null;
|
||||
bandBox.setFinder(getFinderToUse());
|
||||
updateLabelValue();
|
||||
|
|
@ -690,32 +700,30 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
@Override
|
||||
void applyToParameters(ResourceLoadParameters parameters) {
|
||||
if (!hasEntitiesSelected()) {
|
||||
if ( !hasEntitiesSelected() ) {
|
||||
parameters.clearResourcesToShow();
|
||||
parameters.clearCriteriaToShow();
|
||||
} else if (isFilteringByResource()) {
|
||||
} else if ( isFilteringByResource() ) {
|
||||
parameters.setResourcesToShow(calculateResourcesToShow());
|
||||
} else {
|
||||
parameters.setCriteriaToShow(as(Criterion.class,
|
||||
entitiesSelected));
|
||||
parameters.setCriteriaToShow(as(Criterion.class, entitiesSelected));
|
||||
}
|
||||
}
|
||||
|
||||
private List<Resource> calculateResourcesToShow() {
|
||||
List<Resource> resources = new ArrayList<Resource>();
|
||||
List<Criterion> criteria = new ArrayList<Criterion>();
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
List<Criterion> criteria = new ArrayList<>();
|
||||
|
||||
for (Object each : entitiesSelected) {
|
||||
if (each instanceof Resource) {
|
||||
if ( each instanceof Resource ) {
|
||||
resources.add((Resource) each);
|
||||
} else {
|
||||
criteria.add((Criterion) each);
|
||||
}
|
||||
}
|
||||
|
||||
if (!criteria.isEmpty()) {
|
||||
resources.addAll(resourcesSearcher.searchBoth()
|
||||
.byCriteria(criteria).execute());
|
||||
if ( !criteria.isEmpty()) {
|
||||
resources.addAll(resourcesSearcher.searchBoth().byCriteria(criteria).execute());
|
||||
}
|
||||
|
||||
return resources;
|
||||
|
|
@ -726,19 +734,19 @@ public class ResourceLoadController implements Composer {
|
|||
}
|
||||
|
||||
private List<Object> getSelected() {
|
||||
List<Object> result = new ArrayList<Object>();
|
||||
List<Object> result = new ArrayList<>();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<FilterPair> filterPairList = bandBox.getSelectedElements();
|
||||
for (FilterPair filterPair : filterPairList) {
|
||||
result.add(filterPair.getValue());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ByNamePaginator extends DependingOnFiltering
|
||||
implements IListenerAdder {
|
||||
private static class ByNamePaginator extends DependingOnFiltering implements IListenerAdder {
|
||||
|
||||
private static final int ALL = -1;
|
||||
|
||||
|
|
@ -748,9 +756,11 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
private List<? extends BaseEntity> allEntitiesShown = null;
|
||||
|
||||
public ByNamePaginator(Runnable onChange, PlanningState filterBy,
|
||||
public ByNamePaginator(Runnable onChange,
|
||||
PlanningState filterBy,
|
||||
FilterTypeChanger filterTypeChanger,
|
||||
WorkersOrCriteriaBandbox bandbox) {
|
||||
|
||||
super(onChange, filterBy, filterTypeChanger);
|
||||
this.bandbox = bandbox;
|
||||
this.currentPosition = initialPage();
|
||||
|
|
@ -765,20 +775,22 @@ public class ResourceLoadController implements Composer {
|
|||
IPaginationFilterChangedListener listener = new IPaginationFilterChangedListener() {
|
||||
@Override
|
||||
public void filterChanged(int newPosition) {
|
||||
if (currentPosition != newPosition) {
|
||||
if ( currentPosition != newPosition ) {
|
||||
currentPosition = newPosition;
|
||||
notifyChange();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
panel.addPaginationFilterListener(listener);
|
||||
|
||||
return listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
void checkDependencies() {
|
||||
super.checkDependencies();
|
||||
if (bandbox.hasEntitiesSelected()) {
|
||||
if ( bandbox.hasEntitiesSelected() ) {
|
||||
this.currentPosition = ALL;
|
||||
}
|
||||
}
|
||||
|
|
@ -796,43 +808,47 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
@Override
|
||||
void updateUI(ResourcesLoadPanel panel, ResourceLoadDisplayData generatedData) {
|
||||
|
||||
panel.setInternalPaginationDisabled(bandbox.hasEntitiesSelected());
|
||||
Paginator<? extends BaseEntity> paginator = generatedData
|
||||
.getPaginator();
|
||||
Paginator<? extends BaseEntity> paginator = generatedData.getPaginator();
|
||||
List<? extends BaseEntity> newAllEntities = paginator.getAll();
|
||||
if (this.allEntitiesShown == null
|
||||
|| !equivalent(this.allEntitiesShown, newAllEntities)) {
|
||||
|
||||
if ( this.allEntitiesShown == null || !equivalent(this.allEntitiesShown, newAllEntities) ) {
|
||||
this.currentPosition = initialPage();
|
||||
this.allEntitiesShown = newAllEntities;
|
||||
updatePages(panel.getPaginationFilterCombobox(),
|
||||
pagesByName(this.allEntitiesShown,
|
||||
paginator.getPageSize()));
|
||||
|
||||
updatePages(
|
||||
panel.getPaginationFilterCombobox(),
|
||||
pagesByName(this.allEntitiesShown, paginator.getPageSize()));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean equivalent(List<? extends BaseEntity> a,
|
||||
List<? extends BaseEntity> b) {
|
||||
if (a == null || b == null) {
|
||||
private boolean equivalent(List<? extends BaseEntity> a, List<? extends BaseEntity> b) {
|
||||
if ( a == null || b == null ) {
|
||||
return false;
|
||||
}
|
||||
if (a.size() != b.size()) {
|
||||
|
||||
if ( a.size() != b.size() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.size(); i++) {
|
||||
BaseEntity aElement = a.get(i);
|
||||
BaseEntity bElement = b.get(i);
|
||||
if (!ObjectUtils.equals(aElement.getId(), bElement.getId())) {
|
||||
|
||||
if ( !ObjectUtils.equals(aElement.getId(), bElement.getId()) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updatePages(Combobox filterByNameCombo,
|
||||
List<Comboitem> pages) {
|
||||
if (filterByNameCombo == null) {
|
||||
private void updatePages(Combobox filterByNameCombo, List<Comboitem> pages) {
|
||||
if ( filterByNameCombo == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
filterByNameCombo.getChildren().clear();
|
||||
|
||||
Comboitem lastItem = new Comboitem();
|
||||
|
|
@ -845,10 +861,9 @@ public class ResourceLoadController implements Composer {
|
|||
filterByNameCombo.appendChild(each);
|
||||
}
|
||||
|
||||
if (currentPosition >= 0 && currentPosition < pages.size()) {
|
||||
filterByNameCombo
|
||||
.setSelectedItemApi(pages.get(currentPosition));
|
||||
} else if (currentPosition == ALL) {
|
||||
if ( currentPosition >= 0 && currentPosition < pages.size() ) {
|
||||
filterByNameCombo.setSelectedItemApi(pages.get(currentPosition));
|
||||
} else if ( currentPosition == ALL ) {
|
||||
filterByNameCombo.setSelectedItemApi(lastItem);
|
||||
} else {
|
||||
filterByNameCombo.setSelectedIndex(0);
|
||||
|
|
@ -856,57 +871,53 @@ public class ResourceLoadController implements Composer {
|
|||
}
|
||||
|
||||
private List<Comboitem> pagesByName(List<?> list, int pageSize) {
|
||||
if (list.isEmpty()) {
|
||||
return new ArrayList<Comboitem>();
|
||||
if ( list.isEmpty() ) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Object first = list.get(0);
|
||||
if (first instanceof Resource) {
|
||||
return pagesByName(as(Resource.class, list), pageSize,
|
||||
new INameExtractor<Resource>() {
|
||||
|
||||
Object first = list.get(0);
|
||||
if ( first instanceof Resource ) {
|
||||
return pagesByName(as(Resource.class, list), pageSize, new INameExtractor<Resource>() {
|
||||
@Override
|
||||
public String getNameOf(Resource resource) {
|
||||
return resource.getName();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return pagesByName(as(Criterion.class, list), pageSize,
|
||||
new INameExtractor<Criterion>() {
|
||||
|
||||
} else {
|
||||
return pagesByName(as(Criterion.class, list), pageSize, new INameExtractor<Criterion>() {
|
||||
@Override
|
||||
public String getNameOf(Criterion criterion) {
|
||||
return criterion.getType().getName() + ": "
|
||||
+ criterion.getName();
|
||||
return criterion.getType().getName() + ": " + criterion.getName();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
interface INameExtractor<T> {
|
||||
public String getNameOf(T value);
|
||||
String getNameOf(T value);
|
||||
}
|
||||
|
||||
private <T> List<Comboitem> pagesByName(List<T> elements,
|
||||
int pageSize,
|
||||
INameExtractor<T> nameExtractor) {
|
||||
List<Comboitem> result = new ArrayList<Comboitem>();
|
||||
private <T> List<Comboitem> pagesByName(List<T> elements, int pageSize, INameExtractor<T> nameExtractor) {
|
||||
List<Comboitem> result = new ArrayList<>();
|
||||
|
||||
for (int startPos = 0; startPos < elements.size(); startPos += pageSize) {
|
||||
int endPos = Math.min(startPos + pageSize - 1,
|
||||
elements.size() - 1);
|
||||
int endPos = Math.min(startPos + pageSize - 1, elements.size() - 1);
|
||||
String first = nameExtractor.getNameOf(elements.get(startPos));
|
||||
String end = nameExtractor.getNameOf(elements.get(endPos));
|
||||
Comboitem item = buildPageCombo(startPos, first, end);
|
||||
result.add(item);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Comboitem buildPageCombo(int startPosition, String first,
|
||||
String end) {
|
||||
private Comboitem buildPageCombo(int startPosition, String first, String end) {
|
||||
Comboitem result = new Comboitem();
|
||||
result.setLabel(first.substring(0, 1) + " - " + end.substring(0, 1));
|
||||
result.setDescription(first + " - " + end);
|
||||
result.setValue(startPosition);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -917,6 +928,7 @@ public class ResourceLoadController implements Composer {
|
|||
for (Object each : entities) {
|
||||
result.add(klass.cast(each));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -933,30 +945,28 @@ public class ResourceLoadController implements Composer {
|
|||
}
|
||||
|
||||
void setup(ResourcesLoadPanel panel) {
|
||||
panel.setLoadChart(buildChart(panel, emitter));
|
||||
panel.setLoadChart(buildChart(emitter));
|
||||
}
|
||||
|
||||
public Object addAndReturnListener(ResourcesLoadPanel panel) {
|
||||
IChartVisibilityChangedListener visibilityChangedListener = fillOnChartVisibilityChange();
|
||||
panel.addChartVisibilityListener(visibilityChangedListener);
|
||||
|
||||
return visibilityChangedListener;
|
||||
}
|
||||
|
||||
private IChartVisibilityChangedListener fillOnChartVisibilityChange() {
|
||||
IChartVisibilityChangedListener result = new IChartVisibilityChangedListener() {
|
||||
|
||||
return new IChartVisibilityChangedListener() {
|
||||
@Override
|
||||
public void chartVisibilityChanged(final boolean visible) {
|
||||
if (visible && loadChart != null) {
|
||||
if ( visible && loadChart != null ) {
|
||||
loadChart.fillChart();
|
||||
}
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
private Tabbox buildChart(ResourcesLoadPanel resourcesLoadPanel,
|
||||
Emitter<Timeplot> timePlot) {
|
||||
private Tabbox buildChart(Emitter<Timeplot> timePlot) {
|
||||
Tabbox chartComponent = new Tabbox();
|
||||
chartComponent.setOrient("vertical");
|
||||
chartComponent.setHeight("200px");
|
||||
|
|
@ -969,61 +979,55 @@ public class ResourceLoadController implements Composer {
|
|||
Tabpanels chartTabpanels = new Tabpanels();
|
||||
Tabpanel loadChartPannel = new Tabpanel();
|
||||
// avoid adding Timeplot since it has some pending issues
|
||||
CompanyPlanningModel.appendLoadChartAndLegend(loadChartPannel,
|
||||
timePlot);
|
||||
CompanyPlanningModel.appendLoadChartAndLegend(loadChartPannel, timePlot);
|
||||
chartTabpanels.appendChild(loadChartPannel);
|
||||
chartComponent.appendChild(chartTabpanels);
|
||||
|
||||
return chartComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
void updateUI(ResourcesLoadPanel panel,
|
||||
ResourceLoadDisplayData generatedData) {
|
||||
void updateUI(ResourcesLoadPanel panel, ResourceLoadDisplayData generatedData) {
|
||||
TimeTracker timeTracker = panel.getTimeTracker();
|
||||
zoomLevelListener = fillOnZoomChange(panel);
|
||||
timeTracker.addZoomListener(zoomLevelListener);
|
||||
|
||||
Timeplot newLoadChart = buildLoadChart(panel, generatedData,
|
||||
timeTracker);
|
||||
Timeplot newLoadChart = buildLoadChart(panel, generatedData, timeTracker);
|
||||
emitter.emit(newLoadChart);
|
||||
}
|
||||
|
||||
private Timeplot buildLoadChart(ResourcesLoadPanel resourcesLoadPanel,
|
||||
ResourceLoadDisplayData generatedData, TimeTracker timeTracker) {
|
||||
private Timeplot buildLoadChart(
|
||||
ResourcesLoadPanel resourcesLoadPanel, ResourceLoadDisplayData generatedData, TimeTracker timeTracker) {
|
||||
|
||||
Timeplot chartLoadTimeplot = createEmptyTimeplot();
|
||||
|
||||
ResourceLoadChartFiller chartFiller =
|
||||
new ResourceLoadChartFiller(generatedData);
|
||||
loadChart = new Chart(chartLoadTimeplot,
|
||||
chartFiller, timeTracker);
|
||||
ResourceLoadChartFiller chartFiller = new ResourceLoadChartFiller(generatedData);
|
||||
loadChart = new Chart(chartLoadTimeplot, chartFiller, timeTracker);
|
||||
loadChart.setZoomLevel(timeTracker.getDetailLevel());
|
||||
chartFiller.initializeResources();
|
||||
if (resourcesLoadPanel.isVisibleChart()) {
|
||||
if ( resourcesLoadPanel.isVisibleChart() ) {
|
||||
loadChart.fillChart();
|
||||
}
|
||||
|
||||
return chartLoadTimeplot;
|
||||
}
|
||||
|
||||
private IZoomLevelChangedListener fillOnZoomChange(
|
||||
final ResourcesLoadPanel resourcesLoadPanel) {
|
||||
|
||||
IZoomLevelChangedListener zoomListener = new IZoomLevelChangedListener() {
|
||||
|
||||
private IZoomLevelChangedListener fillOnZoomChange(final ResourcesLoadPanel resourcesLoadPanel) {
|
||||
return new IZoomLevelChangedListener() {
|
||||
@Override
|
||||
public void zoomLevelChanged(ZoomLevel detailLevel) {
|
||||
if (loadChart == null) {
|
||||
if ( loadChart == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
loadChart.setZoomLevel(detailLevel);
|
||||
|
||||
if (resourcesLoadPanel.isVisibleChart()) {
|
||||
if ( resourcesLoadPanel.isVisibleChart() ) {
|
||||
loadChart.fillChart();
|
||||
}
|
||||
adjustZoomPositionScroll(resourcesLoadPanel);
|
||||
}
|
||||
};
|
||||
|
||||
return zoomListener;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1034,6 +1038,7 @@ public class ResourceLoadController implements Composer {
|
|||
private Timeplot createEmptyTimeplot() {
|
||||
Timeplot timeplot = new Timeplot();
|
||||
timeplot.appendChild(new Plotinfo());
|
||||
|
||||
return timeplot;
|
||||
}
|
||||
|
||||
|
|
@ -1054,10 +1059,9 @@ public class ResourceLoadController implements Composer {
|
|||
|
||||
@Override
|
||||
protected ILoadChartData getDataOn(Interval interval) {
|
||||
List<DayAssignment> assignments = generatedData
|
||||
.getDayAssignmentsConsidered();
|
||||
return new ResourceLoadChartData(assignments,
|
||||
resources, interval.getStart(), interval.getFinish());
|
||||
List<DayAssignment> assignments = generatedData.getDayAssignmentsConsidered();
|
||||
|
||||
return new ResourceLoadChartData(assignments, resources, interval.getStart(), interval.getFinish());
|
||||
}
|
||||
|
||||
private void initializeResources() {
|
||||
|
|
@ -1068,10 +1072,9 @@ public class ResourceLoadController implements Composer {
|
|||
}
|
||||
|
||||
private static class ListenerTracker {
|
||||
private final List<Object> trackedListeners = new ArrayList<Object>();
|
||||
private final List<Object> trackedListeners = new ArrayList<>();
|
||||
|
||||
public void addListeners(ResourcesLoadPanel panel,
|
||||
Iterable<IListenerAdder> listeners) {
|
||||
public void addListeners(ResourcesLoadPanel panel, Iterable<IListenerAdder> listeners) {
|
||||
for (IListenerAdder each : listeners) {
|
||||
Object listener = each.addAndReturnListener(panel);
|
||||
trackedListeners.add(listener);
|
||||
|
|
@ -1080,13 +1083,12 @@ public class ResourceLoadController implements Composer {
|
|||
}
|
||||
|
||||
private void addCommands(ResourcesLoadPanel resourcesLoadPanel) {
|
||||
resourcesLoadPanel.add(commands.toArray(new IToolbarCommand[commands
|
||||
.size()]));
|
||||
resourcesLoadPanel.add(commands.toArray(new IToolbarCommand[commands.size()]));
|
||||
}
|
||||
|
||||
private BankHolidaysMarker createBankHolidaysMarker() {
|
||||
BaseCalendar defaultCalendar = configurationDAO.getConfiguration()
|
||||
.getDefaultCalendar();
|
||||
BaseCalendar defaultCalendar = configurationDAO.getConfiguration().getDefaultCalendar();
|
||||
|
||||
return BankHolidaysMarker.create(defaultCalendar);
|
||||
}
|
||||
|
||||
|
|
@ -1095,19 +1097,15 @@ public class ResourceLoadController implements Composer {
|
|||
}
|
||||
|
||||
PlanningState createPlanningState(final Order order) {
|
||||
return transactionService
|
||||
.runOnReadOnlyTransaction(new IOnTransaction<PlanningState>() {
|
||||
|
||||
return transactionService.runOnReadOnlyTransaction(new IOnTransaction<PlanningState>() {
|
||||
@Override
|
||||
public PlanningState execute() {
|
||||
return planningStateCreator.retrieveOrCreate(
|
||||
parent.getDesktop(), order);
|
||||
return planningStateCreator.retrieveOrCreate(parent.getDesktop(), order);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setPlanningControllerEntryPoints(
|
||||
IOrderPlanningGate planningControllerEntryPoints) {
|
||||
public void setPlanningControllerEntryPoints(IOrderPlanningGate planningControllerEntryPoints) {
|
||||
this.planningControllerEntryPoints = planningControllerEntryPoints;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
10
pom.xml
10
pom.xml
|
|
@ -388,14 +388,14 @@
|
|||
<classifier>jdk15</classifier>
|
||||
</dependency>
|
||||
|
||||
<!-- Commons collections -->
|
||||
<!-- Commons Collections -->
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>3.2</version>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Commons lang -->
|
||||
<!-- Commons Lang -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue