From b27b606d2ffa87a365b377c5d92af3ea7fd4b44e Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Mon, 16 Oct 2017 20:28:49 +0300 Subject: [PATCH] introduce selectPaths --- .../src/com/intellij/util/ui/tree/TreeUtil.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/platform/platform-api/src/com/intellij/util/ui/tree/TreeUtil.java b/platform/platform-api/src/com/intellij/util/ui/tree/TreeUtil.java index d011cdc5964d..0f713d463944 100644 --- a/platform/platform-api/src/com/intellij/util/ui/tree/TreeUtil.java +++ b/platform/platform-api/src/com/intellij/util/ui/tree/TreeUtil.java @@ -344,6 +344,20 @@ public final class TreeUtil { return true; } + public static void selectPaths(@NotNull JTree tree, @NotNull Collection paths) { + if (paths.isEmpty()) return; + selectPaths(tree, paths.toArray(new TreePath[paths.size()])); + } + + public static void selectPaths(@NotNull JTree tree, @NotNull TreePath... paths) { + if (paths.length == 0) return; + for (TreePath path : paths) { + tree.makeVisible(path); + } + tree.setSelectionPaths(paths); + tree.scrollPathToVisible(paths[0]); + } + @NotNull public static ActionCallback selectPath(@NotNull final JTree tree, final TreePath path) { return selectPath(tree, path, true);