ItEr50S11CUFiltradoNaPlanificacionItEr49S15: Added flatten/unflatten tree behaviour to order planning view.
This commit is contained in:
parent
2563ba73c6
commit
dd8c64cc59
12 changed files with 139 additions and 39 deletions
|
|
@ -36,6 +36,8 @@ public abstract class FilterAndParentExpandedPredicates implements IPredicate {
|
|||
|
||||
private final IContext<?> context;
|
||||
|
||||
private boolean filterContainers = false;
|
||||
|
||||
public FilterAndParentExpandedPredicates(IContext<?> context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
|
@ -46,8 +48,28 @@ public abstract class FilterAndParentExpandedPredicates implements IPredicate {
|
|||
}
|
||||
|
||||
private boolean accepts(Task task) {
|
||||
return accpetsFilterPredicate(task)
|
||||
&& getParentExpandedPredicate().accepts(task);
|
||||
boolean result = true;
|
||||
if (filterContainers) {
|
||||
result &= acceptsContainers(task);
|
||||
} else {
|
||||
result &= getParentExpandedPredicate().accepts(task);
|
||||
}
|
||||
|
||||
return result && accpetsFilterPredicate(task);
|
||||
}
|
||||
|
||||
public boolean acceptsContainers(Task task) {
|
||||
if (filterContainers) {
|
||||
if (task.isContainer()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean accpetsFilterPredicateAndContainers(Task task) {
|
||||
return acceptsContainers(task) && accpetsFilterPredicate(task);
|
||||
}
|
||||
|
||||
public abstract boolean accpetsFilterPredicate(Task task);
|
||||
|
|
@ -77,4 +99,12 @@ public abstract class FilterAndParentExpandedPredicates implements IPredicate {
|
|||
};
|
||||
}
|
||||
|
||||
public void setFilterContainers(boolean filterContainers) {
|
||||
this.filterContainers = filterContainers;
|
||||
}
|
||||
|
||||
public boolean isFilterContainers() {
|
||||
return filterContainers;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -336,9 +336,13 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
|
||||
private void fillModel(Task parent, Integer insertionPosition,
|
||||
Collection<? extends Task> children, final boolean firstTime) {
|
||||
if (predicate.isFilterContainers()) {
|
||||
parent = this.tasksTreeModel.getRoot();
|
||||
}
|
||||
|
||||
if (firstTime) {
|
||||
for (Task node : children) {
|
||||
if (predicate.accpetsFilterPredicate(node)) {
|
||||
if (predicate.accpetsFilterPredicateAndContainers(node)) {
|
||||
if (!visibleTasks.contains(node)) {
|
||||
this.tasksTreeModel.add(parent, node);
|
||||
visibleTasks.add(node);
|
||||
|
|
@ -358,7 +362,7 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
} else {
|
||||
for (Task node : children) {
|
||||
if (node.isContainer()) {
|
||||
if (predicate.accpetsFilterPredicate(node)) {
|
||||
if (predicate.accpetsFilterPredicateAndContainers(node)) {
|
||||
if (!visibleTasks.contains(node)) {
|
||||
this.deferredFiller.addParentOfPendingToAdd(node);
|
||||
}
|
||||
|
|
@ -368,9 +372,8 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
// the node must be added after, so the multistepTreeFiller is
|
||||
// ready
|
||||
for (Task node : children) {
|
||||
if (predicate.accpetsFilterPredicate(node)) {
|
||||
if (predicate.accpetsFilterPredicateAndContainers(node)) {
|
||||
if (!visibleTasks.contains(node)) {
|
||||
// this.tasksTreeModel.add(parent, node);
|
||||
this.tasksTreeModel.add(parent, insertionPosition,
|
||||
Arrays.asList(node));
|
||||
visibleTasks.add(node);
|
||||
|
|
@ -453,7 +456,11 @@ public class LeftTasksTree extends HtmlMacroComponent {
|
|||
|
||||
public void setPredicate(FilterAndParentExpandedPredicates predicate) {
|
||||
this.predicate = predicate;
|
||||
fillModel(tasks, false);
|
||||
|
||||
visibleTasks.clear();
|
||||
tasksTreeModel = MutableTreeModel.create(Task.class);
|
||||
fillModel(tasks, true);
|
||||
tasksTree.setModel(tasksTreeModel);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -291,6 +291,10 @@ public class Planner extends HtmlMacroComponent {
|
|||
Button expandAllButton = (Button) getFellow("expandAll");
|
||||
expandAllButton.setVisible(false);
|
||||
}
|
||||
if (!configuration.isFlattenTreeEnabled()) {
|
||||
Button flattenTree = (Button) getFellow("flattenTree");
|
||||
flattenTree.setVisible(false);
|
||||
}
|
||||
listZoomLevels.setSelectedIndex(getZoomLevel().ordinal());
|
||||
}
|
||||
|
||||
|
|
@ -341,25 +345,20 @@ public class Planner extends HtmlMacroComponent {
|
|||
|
||||
private void setupComponents() {
|
||||
insertGlobalCommands();
|
||||
this.leftPane = new LeftPane(disabilityConfiguration, this.diagramGraph
|
||||
.getTopLevelTasks(),
|
||||
new FilterAndParentExpandedPredicates(context) {
|
||||
|
||||
@Override
|
||||
public boolean accpetsFilterPredicate(Task task) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
predicate = new FilterAndParentExpandedPredicates(context) {
|
||||
|
||||
@Override
|
||||
public boolean accpetsFilterPredicate(Task task) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
this.leftPane = new LeftPane(disabilityConfiguration, this.diagramGraph
|
||||
.getTopLevelTasks(), predicate);
|
||||
this.ganttPanel = new GanttPanel(this.context,
|
||||
commandsOnTasksContextualized, doubleClickCommand,
|
||||
disabilityConfiguration,
|
||||
new FilterAndParentExpandedPredicates(
|
||||
context) {
|
||||
@Override
|
||||
public boolean accpetsFilterPredicate(Task task) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
disabilityConfiguration, predicate);
|
||||
|
||||
Button button = (Button) getFellow("btnPrint");
|
||||
button.setDisabled(!context.isPrintEnabled());
|
||||
}
|
||||
|
|
@ -432,6 +431,8 @@ public class Planner extends HtmlMacroComponent {
|
|||
|
||||
private boolean containersExpandedByDefault = false;
|
||||
|
||||
private FilterAndParentExpandedPredicates predicate;
|
||||
|
||||
public void showCriticalPath() {
|
||||
Button showCriticalPathButton = (Button) getFellow("showCriticalPath");
|
||||
if (disabilityConfiguration.isCriticalPathEnabled()) {
|
||||
|
|
@ -534,6 +535,7 @@ public class Planner extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
public void setTaskListPredicate(FilterAndParentExpandedPredicates predicate) {
|
||||
this.predicate = predicate;
|
||||
leftPane.setPredicate(predicate);
|
||||
getTaskList().setPredicate(predicate);
|
||||
getDependencyList().redrawDependencies();
|
||||
|
|
@ -546,4 +548,23 @@ public class Planner extends HtmlMacroComponent {
|
|||
Clients.evalJavaScript("zkTasklist.showResourceTooltips();");
|
||||
}
|
||||
}
|
||||
|
||||
public void flattenTree() {
|
||||
Button flattenTreeButton = (Button) getFellow("flattenTree");
|
||||
if (disabilityConfiguration.isFlattenTreeEnabled()) {
|
||||
if (flattenTreeButton.getSclass().equals("planner-command")) {
|
||||
predicate.setFilterContainers(true);
|
||||
flattenTreeButton.setSclass("planner-command clicked");
|
||||
} else {
|
||||
predicate.setFilterContainers(false);
|
||||
flattenTreeButton.setSclass("planner-command");
|
||||
}
|
||||
setTaskListPredicate(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
public FilterAndParentExpandedPredicates getPredicate() {
|
||||
return predicate;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,6 +231,14 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
|
||||
private List<TaskComponent> createAndPublishComponentsIfNeeded(
|
||||
Collection<? extends Task> newTasks) {
|
||||
if (predicate.isFilterContainers()) {
|
||||
List<Task> taskLeafs = new ArrayList<Task>();
|
||||
for (Task task : newTasks) {
|
||||
taskLeafs.addAll(task.getAllTaskLeafs());
|
||||
}
|
||||
newTasks = taskLeafs;
|
||||
}
|
||||
|
||||
List<TaskComponent> result = new ArrayList<TaskComponent>();
|
||||
for (Task task : newTasks) {
|
||||
TaskComponent taskComponent = taskComponentByTask.get(task);
|
||||
|
|
|
|||
|
|
@ -37,4 +37,6 @@ public interface IDisabilityConfiguration {
|
|||
|
||||
public boolean isExpandAllEnabled();
|
||||
|
||||
public boolean isFlattenTreeEnabled();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ public class PlannerConfiguration<T> implements IDisabilityConfiguration {
|
|||
|
||||
private boolean expandAllEnabled = true;
|
||||
|
||||
private boolean flattenTreeEnabled = true;
|
||||
|
||||
// private String identifier = null;
|
||||
|
||||
private IDetailItemModificator firstLevelModificators = SeveralModificators
|
||||
|
|
@ -287,6 +289,15 @@ public class PlannerConfiguration<T> implements IDisabilityConfiguration {
|
|||
return expandAllEnabled;
|
||||
}
|
||||
|
||||
public void setFlattenTreeEnabled(boolean flattenTreeEnabled) {
|
||||
this.flattenTreeEnabled = flattenTreeEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlattenTreeEnabled() {
|
||||
return flattenTreeEnabled;
|
||||
}
|
||||
|
||||
public IDetailItemModificator getSecondLevelModificators() {
|
||||
return secondLevelModificators;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.beans.PropertyChangeListener;
|
|||
import java.beans.PropertyChangeSupport;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -321,4 +322,8 @@ public abstract class Task implements ITaskFundamentalProperties {
|
|||
return fundamentalProperties.getName();
|
||||
}
|
||||
|
||||
public List<Task> getAllTaskLeafs() {
|
||||
return Arrays.asList(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,4 +210,13 @@ public class TaskContainer extends Task {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Task> getAllTaskLeafs() {
|
||||
List<Task> result = new ArrayList<Task>();
|
||||
for (Task task : tasks) {
|
||||
result.addAll(task.getAllTaskLeafs());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -36,6 +36,10 @@ planner = self;
|
|||
image="/common/img/ico_expand.png"
|
||||
tooltiptext="${i18n:_('Expand/Collapse all')}"
|
||||
sclass="planner-command" />
|
||||
<button id="flattenTree" onClick="planner.flattenTree();"
|
||||
image="/common/img/ico_flatten.png"
|
||||
tooltiptext="${i18n:_('Flatten/Unflatten tree')}"
|
||||
sclass="planner-command" />
|
||||
<separator />
|
||||
|
||||
<!-- Filtering -->
|
||||
|
|
|
|||
|
|
@ -481,6 +481,7 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
configuration.setResizingTasksEnabled(false);
|
||||
configuration.setCriticalPathEnabled(false);
|
||||
configuration.setExpandAllEnabled(false);
|
||||
configuration.setFlattenTreeEnabled(false);
|
||||
}
|
||||
|
||||
private void addAdditionalCommands(
|
||||
|
|
|
|||
|
|
@ -214,23 +214,25 @@ public class OrderPlanningController implements Composer {
|
|||
model.forceLoadLabelsAndCriterionRequirements();
|
||||
|
||||
final IContext<?> context = planner.getContext();
|
||||
planner
|
||||
.setTaskListPredicate(new FilterAndParentExpandedPredicates(
|
||||
context) {
|
||||
@Override
|
||||
public boolean accpetsFilterPredicate(Task task) {
|
||||
if (predicate == null) {
|
||||
return true;
|
||||
}
|
||||
TaskElement taskElement = (TaskElement) context
|
||||
.getMapper()
|
||||
.findAssociatedDomainObject(task);
|
||||
return taskElement.isMilestone()
|
||||
|| predicate.accepts(taskElement
|
||||
.getOrderElement());
|
||||
}
|
||||
FilterAndParentExpandedPredicates newPredicate = new FilterAndParentExpandedPredicates(
|
||||
context) {
|
||||
@Override
|
||||
public boolean accpetsFilterPredicate(Task task) {
|
||||
if (predicate == null) {
|
||||
return true;
|
||||
}
|
||||
TaskElement taskElement = (TaskElement) context
|
||||
.getMapper()
|
||||
.findAssociatedDomainObject(task);
|
||||
return taskElement.isMilestone()
|
||||
|| predicate.accepts(taskElement
|
||||
.getOrderElement());
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
newPredicate.setFilterContainers(planner.getPredicate()
|
||||
.isFilterContainers());
|
||||
planner.setTaskListPredicate(newPredicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
BIN
navalplanner-webapp/src/main/webapp/common/img/ico_flatten.png
Normal file
BIN
navalplanner-webapp/src/main/webapp/common/img/ico_flatten.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 484 B |
Loading…
Add table
Reference in a new issue