[Bug #952] Show list of resources in 'Resource load view' in order
FEA: ItEr73S04BugFixing
This commit is contained in:
parent
aabff9ac3b
commit
7bb18e5ea4
2 changed files with 38 additions and 2 deletions
|
|
@ -30,7 +30,7 @@ import org.apache.commons.lang.Validate;
|
|||
import org.joda.time.LocalDate;
|
||||
import org.zkoss.ganttz.util.Interval;
|
||||
|
||||
public class LoadTimeLine {
|
||||
public class LoadTimeLine implements Comparable<LoadTimeLine>{
|
||||
|
||||
private final String conceptName;
|
||||
private final List<LoadPeriod> loadPeriods;
|
||||
|
|
@ -196,4 +196,13 @@ public class LoadTimeLine {
|
|||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
public String toString() {
|
||||
return conceptName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(LoadTimeLine o) {
|
||||
return conceptName.compareTo(o.getConceptName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -23,7 +23,10 @@ package org.zkoss.ganttz.resourceload;
|
|||
|
||||
import static org.zkoss.ganttz.i18n.I18nHelper._;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
|
|
@ -294,9 +297,33 @@ public class ResourcesLoadPanel extends HtmlMacroComponent {
|
|||
result.addToRoot(loadTimeLine);
|
||||
result = addNodes(result, loadTimeLine);
|
||||
}
|
||||
return sortModelTree(result);
|
||||
}
|
||||
|
||||
private MutableTreeModel<LoadTimeLine> sortModelTree(MutableTreeModel<LoadTimeLine> modelForTree) {
|
||||
LoadTimeLine root = modelForTree.getRoot();
|
||||
MutableTreeModel<LoadTimeLine> result = MutableTreeModel.create(LoadTimeLine.class, root);
|
||||
sortModelTree(result, modelForTree, root);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void sortModelTree(MutableTreeModel<LoadTimeLine> result,
|
||||
MutableTreeModel<LoadTimeLine> source, LoadTimeLine parent) {
|
||||
List<LoadTimeLine> children = getChildrenInOrderFor(source, parent);
|
||||
result.add(parent, children);
|
||||
for (LoadTimeLine each: children) {
|
||||
sortModelTree(result, source, each);
|
||||
}
|
||||
}
|
||||
|
||||
private List<LoadTimeLine> getChildrenInOrderFor(
|
||||
MutableTreeModel<LoadTimeLine> modelForTree, LoadTimeLine parent) {
|
||||
SortedSet<LoadTimeLine> result = new TreeSet<LoadTimeLine>();
|
||||
for (int i = 0; i < modelForTree.getChildCount(parent); i++) {
|
||||
result.add(modelForTree.getChild(parent, i));
|
||||
}
|
||||
return new ArrayList<LoadTimeLine>(result);
|
||||
}
|
||||
|
||||
private MutableTreeModel<LoadTimeLine> addNodes(
|
||||
MutableTreeModel<LoadTimeLine> tree, LoadTimeLine parent) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue