expand all in tag tree context menu

This commit is contained in:
Honfika
2014-03-08 15:26:09 +01:00
parent c981758098
commit 50bc6f3c1f
10 changed files with 62 additions and 58 deletions
@@ -448,4 +448,22 @@ public class View {
TreePath tp = new TreePath(path.toArray(new Object[path.size()]));
tree.expandPath(tp);
}
public static void expandTreeNodesRecursive(JTree tree, TreePath parent, boolean expand) {
TreeModel model = tree.getModel();
Object node = parent.getLastPathComponent();
int childCount = model.getChildCount(node);
for (int j = 0; j < childCount; j++) {
Object child = model.getChild(node, j);
TreePath path = parent.pathByAddingChild(child);
expandTreeNodesRecursive(tree, path, expand);
}
if (expand) {
tree.expandPath(parent);
} else {
tree.collapsePath(parent);
}
}
}