private static void expandNodeIfNotTooWide(Tree tree, PackageDependenciesNode node) { int count = node.getChildCount(); if (count > 5) return; // another level of nesting if (count == 1 && node.getChildAt(0).getChildCount() > 5) { return; } tree.expandPath(new TreePath(node.getPath())); }
private static void expandFirstLevel(Tree tree) { PackageDependenciesNode root = (PackageDependenciesNode) tree.getModel().getRoot(); int count = root.getChildCount(); if (count < 10) { for (int i = 0; i < count; i++) { PackageDependenciesNode child = (PackageDependenciesNode) root.getChildAt(i); expandNodeIfNotTooWide(tree, child); } } }