scopes: restore tree selection under reloaded root if any (IDEA-73285 )

This commit is contained in:
anna
2011-08-19 21:12:32 +02:00
parent d52dc6f56c
commit 43146fa7bc
@@ -402,6 +402,7 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
final DefaultTreeModel treeModel = (DefaultTreeModel)myTree.getModel();
if (rootToReload != null && rootToReload != treeModel.getRoot()) {
final List<TreePath> treePaths = TreeUtil.collectExpandedPaths(myTree, new TreePath(rootToReload.getPath()));
final List<TreePath> selectionPaths = TreeUtil.collectSelectedPaths(myTree, new TreePath(rootToReload.getPath()));
treeModel.reload(rootToReload);
final TreePath path = new TreePath(rootToReload.getPath());
final boolean wasCollapsed = myTree.isCollapsed(path);
@@ -412,6 +413,9 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
for (TreePath treePath : treePaths) {
myTree.expandPath(treePath);
}
for (TreePath selectionPath : selectionPaths) {
TreeUtil.selectPath(myTree, selectionPath);
}
}
TreeUtil.sort(rootToReload, getNodeComparator());
}