Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
272,700
void () { TreeVisitor[] array = { convertArrayToVisitor("3", "33", "333", "[3333]"), convertArrayToVisitor("2", "22", "[222]"), convertArrayToVisitor("1", "[11]"), path -> TreeVisitor.Action.INTERRUPT, null, }; testMultiSelect(array, 1, """ -[Root] -1 +11 +12 +13 -2 +21 -22 +221 +222 +223 +23 -3 +31 +32 -33 +331 +332 -333 3331 3332 3333 """); }
testMultiSelectNothingExceptRoot
272,701
void () { TreeVisitor[] array = {null, null, null}; testMultiSelect(array, 0, "+Root\n"); }
testMultiSelectNothing
272,702
void (TreeVisitor @NotNull [] array, int count, @NotNull String expected) { testMultiSelect(array, count, expected, TreeTest::done); }
testMultiSelect
272,703
void (TreeVisitor @NotNull [] array, int count, @NotNull String expected, @NotNull Consumer<? super TreeTest> then) { TreeTest.test(TreeUtilVisitTest::rootDeep, test -> TreeUtil.promiseSelect(test.getTree(), Stream.of(array)).onProcessed(paths -> { test.invokeSafely(() -> { if (count == 0) { Assert.assertNull(paths); } else { Assert.assertNotNull(paths); Assert.assertEquals(count, paths.size()); } test.assertTree(expected, true, () -> then.accept(test)); }); })); }
testMultiSelect
272,704
void () { testCollectExpandedPaths(Set.of("Root", "1", "2", "22", "3", "33", "333"), test -> TreeUtil.collectExpandedPaths(test.getTree())); }
testCollectExpandedPaths
272,705
void () { testCollectExpandedPaths(Collections.emptySet(),test -> { TreePath root = test.getTree().getPathForRow(2); // 11 return TreeUtil.collectExpandedPaths(test.getTree(), root); }); }
testCollectExpandedPathsUnderCollapsed11
272,706
void () { testCollectExpandedPaths(Set.of("1", "2", "22", "3", "33", "333"), test -> { TreePath root = test.getTree().getPathForRow(0); // Root test.getTree().setRootVisible(false); return TreeUtil.collectExpandedPaths(test.getTree(), root); }); }
testCollectExpandedPathsWithInvisibleRootUnderInvisibleRoot
272,707
void () { testCollectExpandedPaths(Set.of("1", "2", "22", "3", "33", "333"), test -> { test.getTree().setRootVisible(false); return TreeUtil.collectExpandedPaths(test.getTree()); }); }
testCollectExpandedPathsWithInvisibleRoot
272,708
void () { testCollectExpandedPaths(Set.of("33", "333"), test -> { test.getTree().setRootVisible(false); TreePath root = test.getTree().getPathForRow(14); // 33 return TreeUtil.collectExpandedPaths(test.getTree(), root); }); }
testCollectExpandedPathsWithInvisibleRootUnder33
272,709
void () { testCollectExpandedPaths(Set.of("333"), test -> { test.getTree().setRootVisible(false); TreePath root = test.getTree().getPathForRow(17); // 333 return TreeUtil.collectExpandedPaths(test.getTree(), root); }); }
testCollectExpandedPathsWithInvisibleRootUnder333
272,710
void (@NotNull Set<String> expected, @NotNull Function<? super TreeTest, ? extends List<TreePath>> getter) { testCollectSelection(test -> { List<TreePath> paths = getter.apply(test); Assert.assertEquals(expected.size(), paths.size()); paths.forEach(path -> Assert.assertTrue(expected.contains(TreeUtil.getLastUserObject(String.class, path)))); test.done(); }); }
testCollectExpandedPaths
272,711
void () { testCollectExpandedUserObjects(Set.of("Root", "1", "2", "22", "3", "33", "333"), test -> TreeUtil.collectExpandedUserObjects(test.getTree())); }
testCollectExpandedUserObjects
272,712
void () { testCollectExpandedUserObjects(Set.of("Root", "1", "2", "22", "3"), test -> { test.getTree().collapseRow(15); // 33 return TreeUtil.collectExpandedUserObjects(test.getTree()); }); }
testCollectExpandedUserObjectsWithCollapsedPath
272,713
void () { testCollectExpandedUserObjects(new HashSet<>(), test -> { test.getTree().collapseRow(15); // 33 TreePath root = test.getTree().getPathForRow(15); // 33 return TreeUtil.collectExpandedUserObjects(test.getTree(), root); }); }
testCollectExpandedUserObjectsWithCollapsedPath33Under33
272,714
void () { testCollectExpandedUserObjects(Set.of("33"), test -> { test.getTree().collapseRow(18); // 333 TreePath root = test.getTree().getPathForRow(15); // 33 return TreeUtil.collectExpandedUserObjects(test.getTree(), root); }); }
testCollectExpandedUserObjectsWithCollapsedPath333Under33
272,715
void (@NotNull Set<String> expected, @NotNull Function<? super TreeTest, ? extends List<Object>> getter) { testCollectSelection(test -> { List<Object> objects = getter.apply(test); Assert.assertEquals(expected.size(), objects.size()); objects.forEach(object -> Assert.assertTrue(expected.contains((String)object))); test.done(); }); }
testCollectExpandedUserObjects
272,716
void () { testCollectSelectedPaths(Set.of("11", "222", "33", "3331", "3332", "3333", "Root"), test -> TreeUtil.collectSelectedPaths(test.getTree())); }
testCollectSelectedPaths
272,717
void () { testCollectSelectedPaths(Set.of("11", "222", "33", "3331", "3332", "3333"), test -> { test.getTree().setRootVisible(false); return TreeUtil.collectSelectedPaths(test.getTree()); }); }
testCollectSelectedPathsWithInvisibleRoot
272,718
void () { testCollectSelectedPaths(Set.of("33", "3331", "3332", "3333"), test -> { test.getTree().setRootVisible(false); TreePath root = test.getTree().getPathForRow(14); // 33 return TreeUtil.collectSelectedPaths(test.getTree(), root); }); }
testCollectSelectedPathsWithInvisibleRootUnder33
272,719
void () { testCollectSelectedPaths(Set.of("3331", "3332", "3333"), test -> { test.getTree().setRootVisible(false); TreePath root = test.getTree().getPathForRow(17); // 333 return TreeUtil.collectSelectedPaths(test.getTree(), root); }); }
testCollectSelectedPathsWithInvisibleRootUnder333
272,720
void (@NotNull Set<String> expected, @NotNull Function<? super TreeTest, ? extends List<TreePath>> getter) { testCollectSelection(test -> { List<TreePath> paths = getter.apply(test); Assert.assertEquals(expected.size(), paths.size()); paths.forEach(path -> Assert.assertTrue(expected.contains(TreeUtil.getLastUserObject(String.class, path)))); test.done(); }); }
testCollectSelectedPaths
272,721
void () { testCollectSelectedUserObjects(Set.of("11", "222", "33", "3331", "3332", "3333", "Root"), test -> TreeUtil.collectSelectedUserObjects(test.getTree())); }
testCollectSelectedUserObjects
272,722
void () { testCollectSelectedUserObjects(Set.of("11", "222", "33", "Root"), test -> { test.getTree().collapseRow(15); // 33 return TreeUtil.collectSelectedUserObjects(test.getTree()); }); }
testCollectSelectedUserObjectsWithCollapsedPath
272,723
void () { testCollectSelectedUserObjects(Set.of("33"), test -> { test.getTree().collapseRow(15); // 33 TreePath root = test.getTree().getPathForRow(15); // 33 return TreeUtil.collectSelectedUserObjects(test.getTree(), root); }); }
testCollectSelectedUserObjectsWithCollapsedPathUnder33
272,724
void () { // collapsed parent node becomes selected if it contains selected children testCollectSelectedUserObjects(Set.of("333"), test -> { test.getTree().collapseRow(18); // 333 TreePath root = test.getTree().getPathForRow(18); // 333 return TreeUtil.collectSelectedUserObjects(test.getTree(), root); }); }
testCollectSelectedUserObjectsWithCollapsedPathUnder333
272,725
void (@NotNull Set<String> expected, @NotNull Function<? super TreeTest, ? extends List<Object>> getter) { testCollectSelection(test -> { List<Object> objects = getter.apply(test); Assert.assertEquals(expected.size(), objects.size()); objects.forEach(object -> Assert.assertTrue(expected.contains((String)object))); test.done(); }); }
testCollectSelectedUserObjects
272,726
void (@NotNull Consumer<? super TreeTest> consumer) { TreeVisitor[] array = { convertArrayToVisitor("1", "11"), convertArrayToVisitor("2", "22", "222"), convertArrayToVisitor("3", "33"), convertArrayToVisitor("3", "33", "333", "3331"), convertArrayToVisitor("3", "33", "333", "3332"), convertArrayToVisitor("3", "33", "333", "3333"), path -> TreeVisitor.Action.INTERRUPT, }; testMultiSelect(array, array.length, """ -[Root] -1 +[11] +12 +13 -2 +21 -22 +221 +[222] +223 +23 -3 +31 +32 -[33] +331 +332 -333 [3331] [3332] [3333] """, consumer); }
testCollectSelection
272,727
void () { TreeTest.test(() -> node(Boolean.TRUE, node(101), node(1.1f)), test -> test.assertTree("+true\n", () -> TreeUtil.expandAll(test.getTree(), () -> test.assertTree("-true\n 101\n 1.1\n", () -> { TreeUtil.visitVisibleRows(test.getTree(), path -> path, path -> test.getTree().addSelectionPath(path)); test.assertTree("-[true]\n [101]\n [1.1]\n", true, () -> { Assert.assertEquals(3, TreeUtil.collectSelectedObjectsOfType(test.getTree(), Object.class).size()); Assert.assertEquals(2, TreeUtil.collectSelectedObjectsOfType(test.getTree(), Number.class).size()); Assert.assertEquals(1, TreeUtil.collectSelectedObjectsOfType(test.getTree(), Boolean.class).size()); Assert.assertEquals(1, TreeUtil.collectSelectedObjectsOfType(test.getTree(), Integer.class).size()); Assert.assertEquals(1, TreeUtil.collectSelectedObjectsOfType(test.getTree(), Float.class).size()); Assert.assertEquals(0, TreeUtil.collectSelectedObjectsOfType(test.getTree(), String.class).size()); test.done(); }); })))); }
testCollectSelectedObjectsOfType
272,728
void () { testSelectFirst(() -> null, true, ""); }
testSelectFirstEmpty
272,729
void () { testSelectFirst(TreeUtilVisitTest::rootDeep, true, "+[Root]\n"); }
testSelectFirstWithRoot
272,730
void () { testSelectFirst(TreeUtilVisitTest::rootDeep, false, """ +[1] +2 +3 """); }
testSelectFirstWithoutRoot
272,731
void (@NotNull Supplier<TreeNode> root, boolean visible, @NotNull String expected) { TreeTest.test(root, test -> { test.getTree().setRootVisible(visible); TreeUtil.promiseSelectFirst(test.getTree()).onProcessed(path -> test.invokeSafely(() -> { if (expected.isEmpty()) { Assert.assertNull(path); } else { Assert.assertNotNull(path); Assert.assertTrue(test.getTree().isVisible(path)); } test.assertTree(expected, true, test::done); })); }); }
testSelectFirst
272,732
void () { testSelectFirstLeaf(() -> null, true, ""); }
testSelectFirstLeafEmpty
272,733
void () { testSelectFirstLeaf(() -> node("root"), false, ""); }
testSelectFirstLeafInvisibleRoot
272,734
void () { testSelectFirstLeaf(() -> node("root", node("middle", node("leaf"))), false, " -middle\n [leaf]\n"); }
testSelectFirstLeafWhenNoMoreLeafs
272,735
void () { testSelectFirstLeaf(TreeUtilVisitTest::rootDeep, true, """ -Root -1 -11 -111 [1111] 1112 1113 +112 +113 +12 +13 +2 +3 """); }
testSelectFirstLeafWithRoot
272,736
void () { testSelectFirstLeaf(TreeUtilVisitTest::rootDeep, false, """ -1 -11 -111 [1111] 1112 1113 +112 +113 +12 +13 +2 +3 """); }
testSelectFirstLeafWithoutRoot
272,737
void (@NotNull Supplier<TreeNode> root, boolean visible, @NotNull String expected) { TreeTest.test(root, test -> { test.getTree().setRootVisible(visible); TreeUtil.promiseSelectFirstLeaf(test.getTree()).onProcessed(path -> test.invokeSafely(() -> { if (expected.isEmpty()) { Assert.assertNull(path); } else { Assert.assertNotNull(path); Assert.assertTrue(test.getTree().isVisible(path)); } test.assertTree(expected, true, test::done); })); }); }
testSelectFirstLeaf
272,738
void () { testMakeVisibleNonExistent(""" -Root +1 +2 -3 +31 +32 +33 """, convertArrayToVisitor("3", "NonExistent")); }
testMakeVisibleNonExistent
272,739
void () { testMakeVisibleNonExistent("+Root\n", createRootVisitor("tOOr")); }
testMakeVisibleNonExistentRoot
272,740
void (String expected, TreeVisitor visitor) { testNonExistent(expected, test -> TreeUtil.promiseMakeVisible(test.getTree(), visitor)); }
testMakeVisibleNonExistent
272,741
void () { testExpandNonExistent(""" -Root +1 +2 -3 +31 +32 +33 """, convertArrayToVisitor("3", "NonExistent")); }
testExpandNonExistent
272,742
void () { testExpandNonExistent("+Root\n", createRootVisitor("t00r")); }
testExpandNonExistentRoot
272,743
void (String expected, TreeVisitor visitor) { testNonExistent(expected, test -> TreeUtil.promiseExpand(test.getTree(), visitor)); }
testExpandNonExistent
272,744
void (String expected, Function<? super TreeTest, ? extends Promise<TreePath>> function) { TreeTest.test(TreeUtilVisitTest::rootDeep, test -> function.apply(test) .onSuccess(path -> test.invokeSafely(() -> Assert.fail("found unexpected path: " + path))) .onError(error -> test.invokeSafely(() -> { Assert.assertTrue(error instanceof CancellationException); test.assertTree(expected, test::done); }))); }
testNonExistent
272,745
TreeVisitor (@NotNull String name) { return new TreeVisitor.ByTreePath<>(new TreePath(name), Object::toString); }
createRootVisitor
272,746
TreeVisitor (String @NotNull ... array) { return new TreeVisitor.ByTreePath<>(true, convertArrayToTreePath(array), Object::toString); }
convertArrayToVisitor
272,747
String (TreePath path) { return path == null ? null : path.getLastPathComponent().toString(); }
value
272,748
TreeNode () { return node("Root", node("RootColor", node("RootColorRed"), node("RootColorGreen"), node("RootColorBlue")), node("RootDigit", node("RootDigitOne"), node("RootDigitTwo"), node("RootDigitThree"), node("RootDigitFour"), node("RootDigitFive"), node("RootDigitSix"), node("RootDigitSeven"), node("RootDigitEight"), node("RootDigitNine")), node("RootGreek", node("RootGreekAlpha"), node("RootGreekBeta"), node("RootGreekGamma"), node("RootGreekDelta"), node("RootGreekEpsilon"))); }
root
272,749
TreeNode () { return node("Root", node("1", node("11", node("111", "1111", "1112", "1113"), node("112", "1121", "1122", "1123"), node("113", "1131", "1132", "1133")), node("12", node("121", "1211", "1212", "1213"), node("122", "1221", "1222", "1223"), node("123", "1231", "1232", "1233")), node("13", node("131", "1311", "1312", "1313"), node("132", "1321", "1322", "1323"), node("133", "1331", "1332", "1333"))), node("2", node("21", node("211", "2111", "2112", "2113"), node("212", "2121", "2122", "2123"), node("213", "2131", "2132", "2133")), node("22", node("221", "2211", "2212", "2213"), node("222", "2221", "2222", "2223"), node("223", "2231", "2232", "2233")), node("23", node("231", "2311", "2312", "2313"), node("232", "2321", "2322", "2323"), node("233", "2331", "2332", "2333"))), node("3", node("31", node("311", "3111", "3112", "3113"), node("312", "3121", "3122", "3123"), node("313", "3131", "3132", "3133")), node("32", node("321", "3211", "3212", "3213"), node("322", "3221", "3222", "3223"), node("323", "3231", "3232", "3233")), node("33", node("331", "3311", "3312", "3313"), node("332", "3321", "3322", "3323"), node("333", "3331", "3332", "3333")))); }
rootDeep
272,750
Action (@NotNull TreePath path) { counter.incrementAndGet(); if (matches(path)) return Action.INTERRUPT; if (contains(path)) return Action.CONTINUE; return Action.SKIP_CHILDREN; }
visit
272,751
boolean (@NotNull TreePath path) { return false; }
matches
272,752
boolean (@NotNull TreePath path) { return true; }
contains
272,753
boolean (@NotNull TreePath path) { return depth > path.getPathCount(); }
contains
272,754
boolean (@NotNull TreePath path) { return value.equals(value(path)); }
matches
272,755
boolean (@NotNull TreePath path) { return value.startsWith(value(path)); }
contains
272,756
void () { TestApplicationManager.getInstance(); }
setUp
272,757
void () { testBackgroundThread(() -> null, test -> test.updateModelAndWait(model -> { for (int i = 0; i < 10000; i++) ((DefaultTreeModel)model).setRoot(createRoot()); }, test::done), false, 0); }
testAggressiveUpdating
272,758
void () { Disposable disposable = Disposer.newDisposable(); AsyncTreeModel model = new AsyncTreeModel(new DefaultTreeModel(new DefaultMutableTreeNode()), disposable); try { assert !model.isProcessing() : "created model should not update content"; } finally { EdtTestUtil.runInEdtAndWait(() -> Disposer.dispose(disposable)); } }
testProcessingNPE
272,759
void () { testAsync(() -> null, test -> testPathState0(test.tree, () -> test.updateModelAndWait(model -> ((DefaultTreeModel)model).setRoot(createRoot()), () -> testPathState1(test.tree, test::done)))); }
testNullRoot
272,760
void () { testAsync(AsyncTreeModelTest::createRoot, test -> testPathState1(test.tree, () -> test.updateModelAndWait(model -> ((DefaultTreeModel)model).setRoot(null), () -> testPathState0(test.tree, test::done)))); }
testRootOnly
272,761
void () { testRootOnlyUpdate(false); testRootOnlyUpdate(true); }
testRootOnlyUpdate
272,762
void (boolean mutable) { TreeNode first = new Node("root", mutable); TreeNode second = new Node("root", mutable); assert mutable == first.equals(second); assert first != second : "both nodes should not be the same"; testAsync(() -> first, test -> testPathState1(test.tree, () -> testRootOnlyUpdate(test, first, () -> test.updateModelAndWait(model -> ((DefaultTreeModel)model).setRoot(second), () -> testPathState1(test.tree, () -> testRootOnlyUpdate(test, second, test::done)))))); }
testRootOnlyUpdate
272,763
void (@NotNull ModelTest test, @NotNull TreeNode expected, @NotNull Runnable task) { Object actual = test.tree.getModel().getRoot(); assert expected.equals(actual) : "expected node should be equal to the tree root"; assert expected == actual : "expected node should be the same"; task.run(); }
testRootOnlyUpdate
272,764
void () { ArrayList<TreePath> list = new ArrayList<>(); testAsync(AsyncTreeModelTest::createMutableRoot, test -> TreeUtil.expandAll(test.tree, () -> testPathState(test.tree, " +'root'\n" + MUTABLE_CHILDREN, () -> collectTreePaths(test.tree, list, () -> test.updateModelAndWait(model -> ((DefaultTreeModel)model).setRoot(createMutableRoot()), () -> testPathState(test.tree, " +'root'\n" + MUTABLE_CHILDREN, () -> checkTreePaths(test.tree, list, test::done))))))); }
testChildrenUpdate
272,765
void (@NotNull JTree tree, @NotNull List<? super TreePath> list, @NotNull Runnable task) { list.clear(); forEachRow(tree, list::add); task.run(); }
collectTreePaths
272,766
void (@NotNull JTree tree, @NotNull List<TreePath> list, @NotNull Runnable task) { Iterator<TreePath> iterator = list.iterator(); forEachRow(tree, path -> { assertTrue(iterator.hasNext()); assertTreePath(path, iterator.next()); }); assertFalse(iterator.hasNext()); task.run(); }
checkTreePaths
272,767
void (@NotNull TreePath expected, @NotNull TreePath actual) { assertEquals("expected path should be equal to the actual path", expected, actual); // do no validate root node, because it is not updated in Swing's viewable row list if (expected.getParentPath() == null && actual.getParentPath() == null) return; assertComponent(expected.getLastPathComponent(), actual.getLastPathComponent()); assertTreePath(expected.getParentPath(), actual.getParentPath()); }
assertTreePath
272,768
void (@NotNull Object expected, @NotNull Object actual) { assertEquals("expected node should be equal to the actual node", expected, actual); assertNotSame(expected, actual); }
assertComponent
272,769
TreeNode () { return new Node(true, "root", new Node(true, "color", "red", "green", "blue"), new Node(true, "greek", "alpha", "beta", "gamma")); }
createMutableRoot
272,770
void () { TreeNode color = createColorNode(); TreeNode digit = createDigitNode(); TreeNode greek = createGreekNode(); TreeNode root = new Node("root", color, digit, greek); TreePath path = new TreePath(root); testAsync(() -> root, test -> testPathState(test.tree, " +'root'\n" + CHILDREN, () -> test.collapse(path, () -> testPathState1(test.tree, () -> test.setRootVisible(false, () -> testPathState0(test.tree, () -> test.expand(path, () -> testPathState(test.tree, CHILDREN, () -> test.expand(path.pathByAddingChild(color), () -> testPathState(test.tree, CHILDREN_COLOR, () -> test.expand(path.pathByAddingChild(greek), () -> testPathState(test.tree, CHILDREN_COLOR_GREEK, () -> test.collapse(path, () -> testPathState0(test.tree, () -> test.setRootVisible(true, () -> testPathState1(test.tree, () -> test.expand(path, () -> testPathState(test.tree, " +'root'\n" + CHILDREN_COLOR_GREEK, test::done)))))))))))))))))); }
testChildren
272,771
void () { Node node = new Node("node"); Node root = new Node("root", new Node("upper", new Node("middle", new Node("lower", node)))); TreePath tp = TreePathUtil.convertArrayToTreePath(node.getPath()); testAsync(() -> root, test -> testPathState(test.tree, " +'root'\n 'upper'\n", () -> test.resolve(tp, path -> test.expand(path.getParentPath(), () // expand parent path because leaf nodes are ignored -> testPathState(test.tree, " +'root'\n +'upper'\n +'middle'\n +'lower'\n 'node'\n", test::done))))); }
testChildrenResolve
272,772
void () { Node node = new Node("node"); Node root = new Node("root", new Node("upper", new Node("middle", new Node("lower", node)))); TreePath tp = TreePathUtil.convertArrayToTreePath(node.getPath(), Object::toString); testAsync(() -> root, test -> testPathState(test.tree, " +'root'\n 'upper'\n", () -> test.visit(new TreeVisitor.ByTreePath<>(tp, Object::toString), true, path -> test.expand(path.getParentPath(), () // expand parent path because leaf nodes are ignored -> testPathState(test.tree, " +'root'\n +'upper'\n +'middle'\n +'lower'\n 'node'\n", test::done))))); }
testChildrenVisit
272,773
void () { Node node = new Node("node"); Node root = new Node("root", new Node("upper", new Node("middle", new Node("lower", node)))); TreePath tp = TreePathUtil.convertArrayToTreePath(node.getPath(), Object::toString); testAsync(() -> root, test -> testPathState(test.tree, " +'root'\n 'upper'\n", () -> test.visit(new TreeVisitor.ByTreePath<>(tp, Object::toString), false, path -> { assertNull(path); test.done(); }))); }
testChildrenVisitWithoutLoading
272,774
void () { TreeNode color = createColorNode(); TreeNode digit = createDigitNode(); TreeNode greek = createGreekNode(); TreeNode root = new Node("root", color, digit, greek); TreePath path = new TreePath(root).pathByAddingChild(greek); testAsync(() -> root, test -> testPathState(test.tree, " +'root'\n" + CHILDREN, () -> test.fireStructureChanged(path))); }
testCollapsedNodeUpdateIfChildrenNotLoaded
272,775
void () { TreeNode color = createColorNode(); TreeNode digit = createDigitNode(); TreeNode greek = createGreekNode(); TreeNode root = new Node("root", color, digit, greek); TreePath path = new TreePath(root); testAsync(() -> root, test -> testPathState(test.tree, " +'root'\n" + CHILDREN, () -> test.collapse(path, () -> testPathState1(test.tree, () -> test.fireStructureChanged(path))))); }
testCollapsedNodeUpdateIfChildrenLoaded
272,776
void () { TreeNode color = createColorNode(); TreeNode digit = createDigitNode(); TreeNode greek = createGreekNode(); TreeNode root = new Node("root", color, digit, greek); TreePath path = new TreePath(root); testAsync(() -> root, test -> testPathState(test.tree, " +'root'\n" + CHILDREN, () -> test.fireStructureChanged(path))); }
testExpandedNodeUpdateIfChildrenLoaded
272,777
TreeNode () { return new Node("root"); }
createRoot
272,778
TreeNode () { return new Node("color", "red", "green", "blue"); }
createColorNode
272,779
TreeNode () { return new Node("digit", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"); }
createDigitNode
272,780
TreeNode () { return new Node("greek", "alpha", "beta", "gamma", "delta", "epsilon"); }
createGreekNode
272,781
void (@NotNull JTree tree, @NotNull String state, @NotNull Runnable task) { assertEquals("unexpected tree state", state, getPathState(tree)); task.run(); }
testPathState
272,782
void (@NotNull JTree tree, @NotNull Runnable task) { assert 0 == tree.getRowCount() : "tree should have no nodes"; testPathState(tree, "", task); }
testPathState0
272,783
void (@NotNull JTree tree, @NotNull Runnable task) { assert 1 == tree.getRowCount() : "tree should have only one node"; testPathState(tree, " 'root'\n", task); }
testPathState1
272,784
void (JTree tree, Consumer<? super TreePath> consumer) { int count = tree.getRowCount(); for (int row = 0; row < count; row++) { consumer.accept(tree.getPathForRow(row)); } }
forEachRow
272,785
String (JTree tree) { StringBuilder sb = new StringBuilder(); forEachRow(tree, path -> addState(sb, tree, path)); return sb.toString(); }
getPathState
272,786
void (StringBuilder sb, JTree tree, TreePath path) { boolean expanded = tree.isExpanded(path); boolean selected = tree.isPathSelected(path); sb.append(selected ? '[' : ' '); int count = path.getPathCount(); while (0 < count--) sb.append(" "); sb.append(expanded ? '+' : ' '); sb.append(path.getLastPathComponent()); if (selected) sb.append(']'); sb.append("\n"); }
addState
272,787
void (Supplier<? extends TreeNode> root, @NotNull Consumer<? super ModelTest> consumer) { testAsync(root, consumer, false); testAsync(root, consumer, true); }
testAsync
272,788
void (Supplier<? extends TreeNode> root, @NotNull Consumer<? super ModelTest> consumer, boolean showLoadingNode) { testEventDispatchThread(root, consumer, showLoadingNode); testBackgroundThread(root, consumer, showLoadingNode); testBackgroundPool(root, consumer, showLoadingNode); testBackgroundImmediateAsyncThread(root, consumer, showLoadingNode); testBackgroundAsyncThread(root, consumer, showLoadingNode); }
testAsync
272,789
void (Supplier<? extends TreeNode> root, Consumer<? super ModelTest> consumer, boolean showLoadingNode) { testEventDispatchThread(root, consumer, showLoadingNode, TreeTest.FAST); testEventDispatchThread(root, consumer, showLoadingNode, TreeTest.SLOW); }
testEventDispatchThread
272,790
void (Supplier<? extends TreeNode> root, Consumer<? super ModelTest> consumer, boolean showLoadingNode, int delay) { new AsyncTest(showLoadingNode, new EventDispatchThreadModel(delay, root)).start(consumer, getSecondsToWait(delay)); }
testEventDispatchThread
272,791
void (Supplier<? extends TreeNode> root, Consumer<? super ModelTest> consumer, boolean showLoadingNode) { testBackgroundThread(root, consumer, showLoadingNode, TreeTest.FAST); testBackgroundThread(root, consumer, showLoadingNode, TreeTest.SLOW); }
testBackgroundThread
272,792
void (Supplier<? extends TreeNode> root, Consumer<? super ModelTest> consumer, boolean showLoadingNode, int delay) { if (consumer != null) new AsyncTest(showLoadingNode, new BackgroundThreadModel(delay, root)).start(consumer, getSecondsToWait(delay)); }
testBackgroundThread
272,793
void (Supplier<? extends TreeNode> root, Consumer<? super ModelTest> consumer, boolean showLoadingNode) { testBackgroundImmediateAsyncThread(root, consumer, showLoadingNode, TreeTest.FAST); testBackgroundImmediateAsyncThread(root, consumer, showLoadingNode, TreeTest.SLOW); }
testBackgroundImmediateAsyncThread
272,794
void (Supplier<? extends TreeNode> root, Consumer<? super ModelTest> consumer, boolean showLoadingNode, int delay) { if (consumer != null) new AsyncTest(showLoadingNode, new BackgroundThreadImmediateAsyncModel(delay, root)).start(consumer, getSecondsToWait(delay)); }
testBackgroundImmediateAsyncThread
272,795
void (Supplier<? extends TreeNode> root, Consumer<? super ModelTest> consumer, boolean showLoadingNode) { testBackgroundAsyncThread(root, consumer, showLoadingNode, TreeTest.FAST); testBackgroundAsyncThread(root, consumer, showLoadingNode, TreeTest.SLOW); }
testBackgroundAsyncThread
272,796
void (Supplier<? extends TreeNode> root, Consumer<? super ModelTest> consumer, boolean showLoadingNode, int delay) { if (consumer != null) new AsyncTest(showLoadingNode, new BackgroundThreadAsyncModel(delay, root)).start(consumer, getSecondsToWait(delay)); }
testBackgroundAsyncThread
272,797
void (Supplier<? extends TreeNode> root, Consumer<? super ModelTest> consumer, boolean showLoadingNode) { testBackgroundPool(root, consumer, showLoadingNode, TreeTest.FAST); testBackgroundPool(root, consumer, showLoadingNode, TreeTest.SLOW); }
testBackgroundPool
272,798
void (Supplier<? extends TreeNode> root, Consumer<? super ModelTest> consumer, boolean showLoadingNode, int delay) { if (consumer != null) new AsyncTest(showLoadingNode, new BackgroundPoolModel(delay, root)).start(consumer, getSecondsToWait(delay)); }
testBackgroundPool
272,799
void (String prefix, long time) { time = System.currentTimeMillis() - time; if (PRINT) System.out.println(prefix + time + " ms"); }
printTime