diff: select all root nodes by default

better fix for e770f02
This commit is contained in:
Aleksey Pivovarov
2014-12-03 16:12:33 +03:00
parent a61e32a71b
commit 0044e6fc55
@@ -430,7 +430,17 @@ public abstract class ChangesTreeList<T> extends JPanel implements TypeSafeDataP
myList.setSelectedIndex(listSelection);
myList.ensureIndexIsVisible(listSelection);
if (scrollRow >= 0) {
if (scrollRow == -1) {
TreeNode root = (TreeNode)model.getRoot();
int childrenCount = root.getChildCount();
TreePath[] selected = new TreePath[childrenCount];
for (int i = 0; i < childrenCount; i++) {
TreeNode child = root.getChildAt(i);
// reverse order, because the last one will become "current" node. And we want it to be the first one.
selected[childrenCount - i - 1] = new TreePath(model.getPathToRoot(child));
}
myTree.setSelectionPaths(selected);
} else {
myTree.setSelectionRow(scrollRow);
}
TreeUtil.showRowCentered(myTree, scrollRow, false);