public final class TreeUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
TreeUtil.Traverse
Deprecated.
use TreeUtil#treePathTraverser()
|
Modifier and Type | Field and Description |
---|---|
static javax.swing.tree.TreePath[] |
EMPTY_TREE_PATH |
Modifier and Type | Method and Description |
---|---|
static void |
addChildrenTo(javax.swing.tree.MutableTreeNode node,
java.util.List<? extends javax.swing.tree.TreeNode> children) |
static void |
collapseAll(javax.swing.JTree tree,
boolean strict,
int keepSelectionLevel) |
static void |
collapseAll(javax.swing.JTree tree,
int keepSelectionLevel) |
static <T> java.util.List<T> |
collectExpandedObjects(javax.swing.JTree tree,
java.util.function.Function<? super javax.swing.tree.TreePath,? extends T> mapper) |
static <T> java.util.List<T> |
collectExpandedObjects(javax.swing.JTree tree,
javax.swing.tree.TreePath root,
java.util.function.Function<? super javax.swing.tree.TreePath,? extends T> mapper) |
static java.util.List<javax.swing.tree.TreePath> |
collectExpandedPaths(javax.swing.JTree tree) |
static java.util.List<javax.swing.tree.TreePath> |
collectExpandedPaths(javax.swing.JTree tree,
javax.swing.tree.TreePath root) |
static java.util.List<java.lang.Object> |
collectExpandedUserObjects(javax.swing.JTree tree) |
static java.util.List<java.lang.Object> |
collectExpandedUserObjects(javax.swing.JTree tree,
javax.swing.tree.TreePath root) |
static <T> java.util.List<T> |
collectSelectedObjects(javax.swing.JTree tree,
java.util.function.Function<? super javax.swing.tree.TreePath,? extends T> mapper) |
static <T> java.util.List<T> |
collectSelectedObjects(javax.swing.JTree tree,
javax.swing.tree.TreePath root,
java.util.function.Function<? super javax.swing.tree.TreePath,? extends T> mapper) |
static <T> java.util.List<T> |
collectSelectedObjectsOfType(javax.swing.JTree tree,
java.lang.Class<? extends T> type) |
static java.util.List<javax.swing.tree.TreePath> |
collectSelectedPaths(javax.swing.JTree tree) |
static java.util.List<javax.swing.tree.TreePath> |
collectSelectedPaths(javax.swing.JTree tree,
javax.swing.tree.TreePath root) |
static java.util.List<java.lang.Object> |
collectSelectedUserObjects(javax.swing.JTree tree) |
static java.util.List<java.lang.Object> |
collectSelectedUserObjects(javax.swing.JTree tree,
javax.swing.tree.TreePath root) |
static void |
dropSelectionButUnderPoint(javax.swing.JTree tree,
java.awt.Point treePoint) |
static void |
ensureSelection(javax.swing.JTree tree) |
static void |
expand(javax.swing.JTree tree,
int levels)
Expands n levels of the tree counting from the root
|
static void |
expand(javax.swing.JTree tree,
int depth,
java.lang.Runnable onDone)
Expands some nodes in the specified tree and runs the specified task on done.
|
static void |
expand(javax.swing.JTree tree,
TreeVisitor visitor,
java.util.function.Consumer<? super javax.swing.tree.TreePath> consumer)
Expands a node in the specified tree.
|
static void |
expandAll(javax.swing.JTree tree) |
static void |
expandAll(javax.swing.JTree tree,
java.lang.Runnable onDone)
Expands all nodes in the specified tree and runs the specified task on done.
|
static void |
expandRootChildIfOnlyOne(javax.swing.JTree tree) |
static javax.swing.tree.TreePath |
findCommonPath(javax.swing.tree.TreePath [] treePaths)
Deprecated.
use TreePathUtil#findCommonAncestor(TreePath...) instead
|
static javax.swing.tree.DefaultMutableTreeNode |
findNode(javax.swing.tree.DefaultMutableTreeNode aRoot,
Condition<? super javax.swing.tree.DefaultMutableTreeNode> condition) |
static javax.swing.tree.DefaultMutableTreeNode |
findNodeWithObject(javax.swing.tree.DefaultMutableTreeNode aRoot,
java.lang.Object aObject) |
static javax.swing.tree.TreeNode |
findNodeWithObject(java.lang.Object object,
javax.swing.tree.TreeModel model,
java.lang.Object parent) |
static <T> T |
findObjectInPath(javax.swing.tree.TreePath path,
java.lang.Class<T> clazz) |
static int |
getDepthOffset(javax.swing.JTree aTree) |
static java.util.Comparator<javax.swing.tree.TreePath> |
getDisplayOrderComparator(javax.swing.JTree tree) |
static Range<java.lang.Integer> |
getExpandControlRange(javax.swing.JTree aTree,
javax.swing.tree.TreePath path) |
static javax.swing.tree.TreePath |
getFirstLeafNodePath(javax.swing.JTree tree)
Deprecated.
|
static javax.swing.tree.TreePath |
getFirstNodePath(javax.swing.JTree tree) |
static <T> T |
getLastUserObject(java.lang.Class<T> type,
javax.swing.tree.TreePath path) |
static java.lang.Object |
getLastUserObject(javax.swing.tree.TreePath path) |
static int |
getNodeDepth(javax.swing.JTree tree,
javax.swing.tree.TreePath path) |
static int |
getNodeRowX(javax.swing.JTree tree,
int row) |
static javax.swing.tree.TreePath |
getPath(javax.swing.tree.TreeNode aRootNode,
javax.swing.tree.TreeNode aNode) |
static javax.swing.tree.TreePath |
getPathFromRoot(javax.swing.tree.TreeNode node) |
static RelativePoint |
getPointForBounds(javax.swing.JComponent aComponent,
java.awt.Rectangle aBounds) |
static RelativePoint |
getPointForPath(javax.swing.JTree aTree,
javax.swing.tree.TreePath path) |
static RelativePoint |
getPointForRow(javax.swing.JTree aTree,
int aRow) |
static RelativePoint |
getPointForSelection(javax.swing.JTree aTree) |
static javax.swing.tree.TreePath |
getSelectedPathIfOne(javax.swing.JTree tree) |
static <T> T |
getUserObject(java.lang.Class<T> type,
java.lang.Object node) |
static java.lang.Object |
getUserObject(java.lang.Object node) |
static int |
getVisibleRowCount(javax.swing.JTree tree)
Returns a number of tree rows currently visible.
|
static <T extends javax.swing.tree.TreeNode> |
indexedBinarySearch(T parent,
T key,
java.util.Comparator<? super T> comparator) |
static <T extends javax.swing.tree.MutableTreeNode> |
insertNode(T child,
T parent,
javax.swing.tree.DefaultTreeModel model,
boolean allowDuplication,
java.util.Comparator<? super T> comparator) |
static <T extends javax.swing.tree.MutableTreeNode> |
insertNode(T child,
T parent,
javax.swing.tree.DefaultTreeModel model,
java.util.Comparator<? super T> comparator) |
static void |
installActions(javax.swing.JTree tree) |
static void |
invalidateCacheAndRepaint(javax.swing.plaf.TreeUI ui) |
static boolean |
isAncestor(javax.swing.tree.TreeNode ancestor,
javax.swing.tree.TreeNode node) |
static boolean |
isLocationInExpandControl(javax.swing.JTree tree,
int x,
int y) |
static boolean |
isLocationInExpandControl(javax.swing.JTree tree,
javax.swing.tree.TreePath path,
int x,
int y) |
static boolean |
isOverSelection(javax.swing.JTree tree,
java.awt.Point point) |
static java.util.List<javax.swing.tree.TreeNode> |
listChildren(javax.swing.tree.TreeNode node) |
static void |
makeVisible(javax.swing.JTree tree,
TreeVisitor visitor,
java.util.function.Consumer<? super javax.swing.tree.TreePath> consumer)
Makes visible a node in the specified tree.
|
static ActionCallback |
moveDown(javax.swing.JTree tree) |
static ActionCallback |
movePageDown(javax.swing.JTree tree) |
static ActionCallback |
movePageUp(javax.swing.JTree tree) |
static void |
moveSelectedRow(javax.swing.JTree tree,
int direction) |
static ActionCallback |
moveUp(javax.swing.JTree tree) |
static JBIterable<java.lang.Object> |
nodeChildren(java.lang.Object node,
javax.swing.tree.TreeModel model) |
static JBIterable<javax.swing.tree.TreeNode> |
nodeChildren(javax.swing.tree.TreeNode treeNode) |
static Promise<?> |
promiseExpand(javax.swing.JTree tree,
int depth)
Promises to expand some nodes in the specified tree.
|
static Promise<java.util.List<javax.swing.tree.TreePath>> |
promiseExpand(javax.swing.JTree tree,
java.util.stream.Stream<? extends TreeVisitor> visitors)
Promises to expand several nodes in the specified tree.
|
static Promise<javax.swing.tree.TreePath> |
promiseExpand(javax.swing.JTree tree,
TreeVisitor visitor)
Promises to expand a node in the specified tree.
|
static Promise<?> |
promiseExpandAll(javax.swing.JTree tree)
Promises to expand all nodes in the specified tree.
|
static Promise<java.util.List<javax.swing.tree.TreePath>> |
promiseMakeVisible(javax.swing.JTree tree,
java.util.stream.Stream<? extends TreeVisitor> visitors)
Promises to make visible several nodes in the specified tree.
|
static Promise<javax.swing.tree.TreePath> |
promiseMakeVisible(javax.swing.JTree tree,
TreeVisitor visitor)
Promises to make visible a node in the specified tree.
|
static Promise<java.util.List<javax.swing.tree.TreePath>> |
promiseSelect(javax.swing.JTree tree,
java.util.stream.Stream<? extends TreeVisitor> visitors)
Promises to select several nodes in the specified tree.
|
static Promise<javax.swing.tree.TreePath> |
promiseSelect(javax.swing.JTree tree,
TreeVisitor visitor)
Promises to select a node in the specified tree.
|
static Promise<javax.swing.tree.TreePath> |
promiseSelectFirst(javax.swing.JTree tree)
Promises to select the first node in the specified tree.
|
static Promise<javax.swing.tree.TreePath> |
promiseSelectFirstLeaf(javax.swing.JTree tree)
Promises to select the first leaf node in the specified tree.
|
static Promise<javax.swing.tree.TreePath> |
promiseVisit(javax.swing.JTree tree,
TreeVisitor visitor)
Promises to process nodes in the specified tree.
|
static void |
removeLastPathComponent(javax.swing.JTree tree,
javax.swing.tree.TreePath pathToBeRemoved) |
static void |
removeSelected(javax.swing.JTree tree)
Removes last component in the current selection path.
|
static void |
restoreExpandedPaths(javax.swing.JTree tree,
java.util.List<? extends javax.swing.tree.TreePath> paths)
Expands specified paths.
|
static boolean |
scrollToVisible(javax.swing.JTree tree,
javax.swing.tree.TreePath path,
boolean centered) |
static void |
select(javax.swing.JTree tree,
TreeVisitor visitor,
java.util.function.Consumer<? super javax.swing.tree.TreePath> consumer)
Deprecated.
use
promiseSelect(tree, visitor).onSuccess(consumer) instead |
static ActionCallback |
selectFirstNode(javax.swing.JTree tree)
Tries to select the first node in the specified tree as soon as possible.
|
static ActionCallback |
selectInTree(javax.swing.tree.DefaultMutableTreeNode node,
boolean requestFocus,
javax.swing.JTree tree) |
static ActionCallback |
selectInTree(javax.swing.tree.DefaultMutableTreeNode node,
boolean requestFocus,
javax.swing.JTree tree,
boolean center) |
static ActionCallback |
selectInTree(Project project,
javax.swing.tree.DefaultMutableTreeNode node,
boolean requestFocus,
javax.swing.JTree tree,
boolean center) |
static javax.swing.tree.TreePath [] |
selectMaximals(javax.swing.tree.TreePath [] paths)
Deprecated.
use TreeCollector.TreePathRoots#collect(TreePath...) instead
|
static void |
selectNode(javax.swing.JTree tree,
javax.swing.tree.TreeNode node) |
static ActionCallback |
selectPath(javax.swing.JTree tree,
javax.swing.tree.TreePath path) |
static ActionCallback |
selectPath(javax.swing.JTree tree,
javax.swing.tree.TreePath path,
boolean center) |
static void |
selectPaths(javax.swing.JTree tree,
java.util.Collection<? extends javax.swing.tree.TreePath> paths)
Makes visible specified tree paths and select them.
|
static void |
selectPaths(javax.swing.JTree tree,
javax.swing.tree.TreePath... paths)
Deprecated.
use {
selectPaths(JTree, Collection) } instead |
static void |
selectRow(javax.swing.JTree tree,
int index)
Makes visible the specified tree row and selects it.
|
static ActionCallback |
showAndSelect(javax.swing.JTree tree,
int top,
int bottom,
int row,
int previous) |
static ActionCallback |
showAndSelect(javax.swing.JTree tree,
int top,
int bottom,
int row,
int previous,
boolean addToSelection) |
static ActionCallback |
showAndSelect(javax.swing.JTree tree,
int top,
int bottom,
int row,
int previous,
boolean addToSelection,
boolean scroll) |
static ActionCallback |
showAndSelect(javax.swing.JTree tree,
int top,
int bottom,
int row,
int previous,
boolean addToSelection,
boolean scroll,
boolean resetSelection) |
static ActionCallback |
showRowCentered(javax.swing.JTree tree,
int row,
boolean centerHorizontally) |
static ActionCallback |
showRowCentered(javax.swing.JTree tree,
int row,
boolean centerHorizontally,
boolean scroll) |
static void |
sort(javax.swing.tree.DefaultMutableTreeNode node,
java.util.Comparator comparator) |
static void |
sort(javax.swing.tree.DefaultTreeModel model,
java.util.Comparator comparator) |
static <T extends javax.swing.tree.MutableTreeNode> |
sortChildren(T node,
java.util.Comparator<? super T> comparator) |
static <T extends javax.swing.tree.MutableTreeNode> |
sortRecursively(T node,
java.util.Comparator<? super T> comparator) |
static boolean |
traverse(javax.swing.tree.TreeNode node,
TreeUtil.Traverse traverse)
Deprecated.
use TreeUtil#treeTraverser() or TreeUtil#treeNodeTraverser() directly
|
static boolean |
traverseDepth(javax.swing.tree.TreeNode node,
TreeUtil.Traverse traverse)
Deprecated.
use TreeUtil#treeTraverser() or TreeUtil#treeNodeTraverser() directly
|
static JBTreeTraverser<javax.swing.tree.TreeNode> |
treeNodeTraverser(javax.swing.tree.TreeNode treeNode) |
static JBTreeTraverser<javax.swing.tree.TreePath> |
treePathTraverser(javax.swing.JTree tree) |
static JBTreeTraverser<java.lang.Object> |
treeTraverser(javax.swing.JTree tree) |
static void |
unselectPath(javax.swing.JTree tree,
javax.swing.tree.TreePath path) |
static void |
visit(javax.swing.JTree tree,
TreeVisitor visitor,
java.util.function.Consumer<? super javax.swing.tree.TreePath> consumer)
Processes nodes in the specified tree.
|
static <T> void |
visitVisibleRows(javax.swing.JTree tree,
java.util.function.Function<? super javax.swing.tree.TreePath,? extends T> mapper,
java.util.function.Consumer<? super T> consumer)
Processes visible nodes in the specified tree.
|
static javax.swing.tree.TreePath |
visitVisibleRows(javax.swing.JTree tree,
TreeVisitor visitor)
Processes visible nodes in the specified tree.
|
public static JBTreeTraverser<java.lang.Object> treeTraverser(javax.swing.JTree tree)
public static JBTreeTraverser<javax.swing.tree.TreePath> treePathTraverser(javax.swing.JTree tree)
public static JBIterable<java.lang.Object> nodeChildren(java.lang.Object node, javax.swing.tree.TreeModel model)
public static JBTreeTraverser<javax.swing.tree.TreeNode> treeNodeTraverser(javax.swing.tree.TreeNode treeNode)
public static JBIterable<javax.swing.tree.TreeNode> nodeChildren(javax.swing.tree.TreeNode treeNode)
public static java.util.List<javax.swing.tree.TreePath> collectExpandedPaths(javax.swing.JTree tree)
tree
- a tree, which viewable paths are processedpublic static java.util.List<java.lang.Object> collectExpandedUserObjects(javax.swing.JTree tree)
tree
- a tree, which viewable paths are processedpublic static <T> java.util.List<T> collectExpandedObjects(javax.swing.JTree tree, java.util.function.Function<? super javax.swing.tree.TreePath,? extends T> mapper)
tree
- a tree, which viewable paths are processedmapper
- a function to convert a expanded tree path to a corresponding objectpublic static <T> T findObjectInPath(javax.swing.tree.TreePath path, java.lang.Class<T> clazz)
public static <T> java.util.List<T> collectSelectedObjectsOfType(javax.swing.JTree tree, java.lang.Class<? extends T> type)
tree
- a tree, which selection is processedtype
- a Class
object to filter selected user objectspublic static java.util.List<javax.swing.tree.TreePath> collectExpandedPaths(javax.swing.JTree tree, javax.swing.tree.TreePath root)
tree
- a tree, which viewable paths are processedroot
- an ascendant tree path to filter expanded tree pathspublic static java.util.List<java.lang.Object> collectExpandedUserObjects(javax.swing.JTree tree, javax.swing.tree.TreePath root)
tree
- a tree, which viewable paths are processedroot
- an ascendant tree path to filter expanded tree pathspublic static <T> java.util.List<T> collectExpandedObjects(javax.swing.JTree tree, javax.swing.tree.TreePath root, java.util.function.Function<? super javax.swing.tree.TreePath,? extends T> mapper)
tree
- a tree, which viewable paths are processedroot
- an ascendant tree path to filter expanded tree pathsmapper
- a function to convert a expanded tree path to a corresponding objectpublic static void restoreExpandedPaths(javax.swing.JTree tree, java.util.List<? extends javax.swing.tree.TreePath> paths)
tree
- JTree to apply expansion status topaths
- to expand. See collectExpandedPaths(JTree, TreePath)
public static javax.swing.tree.TreePath getPath(javax.swing.tree.TreeNode aRootNode, javax.swing.tree.TreeNode aNode)
public static boolean isAncestor(javax.swing.tree.TreeNode ancestor, javax.swing.tree.TreeNode node)
public static javax.swing.tree.TreePath getPathFromRoot(javax.swing.tree.TreeNode node)
public static javax.swing.tree.TreeNode findNodeWithObject(java.lang.Object object, javax.swing.tree.TreeModel model, java.lang.Object parent)
public static void removeSelected(javax.swing.JTree tree)
tree
- to remove selected node from.public static void removeLastPathComponent(javax.swing.JTree tree, javax.swing.tree.TreePath pathToBeRemoved)
public static javax.swing.tree.DefaultMutableTreeNode findNodeWithObject(javax.swing.tree.DefaultMutableTreeNode aRoot, java.lang.Object aObject)
public static javax.swing.tree.DefaultMutableTreeNode findNode(javax.swing.tree.DefaultMutableTreeNode aRoot, Condition<? super javax.swing.tree.DefaultMutableTreeNode> condition)
@Deprecated public static javax.swing.tree.TreePath findCommonPath(javax.swing.tree.TreePath [] treePaths)
public static ActionCallback selectFirstNode(javax.swing.JTree tree)
tree
- a tree, which node should be selectedpromiseSelectFirst(javax.swing.JTree)
public static javax.swing.tree.TreePath getFirstNodePath(javax.swing.JTree tree)
@Deprecated public static javax.swing.tree.TreePath getFirstLeafNodePath(javax.swing.JTree tree)
promiseSelectFirstLeaf(javax.swing.JTree)
@Deprecated public static javax.swing.tree.TreePath [] selectMaximals(javax.swing.tree.TreePath [] paths)
public static void sort(javax.swing.tree.DefaultTreeModel model, java.util.Comparator comparator)
public static void sort(javax.swing.tree.DefaultMutableTreeNode node, java.util.Comparator comparator)
public static <T extends javax.swing.tree.MutableTreeNode> void sortRecursively(T node, java.util.Comparator<? super T> comparator)
public static <T extends javax.swing.tree.MutableTreeNode> void sortChildren(T node, java.util.Comparator<? super T> comparator)
public static void addChildrenTo(javax.swing.tree.MutableTreeNode node, java.util.List<? extends javax.swing.tree.TreeNode> children)
@Deprecated public static boolean traverse(javax.swing.tree.TreeNode node, TreeUtil.Traverse traverse)
@Deprecated public static boolean traverseDepth(javax.swing.tree.TreeNode node, TreeUtil.Traverse traverse)
public static void selectRow(javax.swing.JTree tree, int index)
tree
- a tree to select inindex
- an index of a viewable node in the given treeJTree.getRowCount()
,
JTree.clearSelection()
public static void selectPaths(javax.swing.JTree tree, java.util.Collection<? extends javax.swing.tree.TreePath> paths)
tree
- a tree to select inpaths
- a collection of paths to selectJTree.clearSelection()
@Deprecated public static void selectPaths(javax.swing.JTree tree, javax.swing.tree.TreePath... paths)
selectPaths(JTree, Collection)
} insteadpublic static ActionCallback selectPath(javax.swing.JTree tree, javax.swing.tree.TreePath path)
public static ActionCallback selectPath(javax.swing.JTree tree, javax.swing.tree.TreePath path, boolean center)
public static ActionCallback moveDown(javax.swing.JTree tree)
public static ActionCallback moveUp(javax.swing.JTree tree)
public static ActionCallback movePageUp(javax.swing.JTree tree)
public static ActionCallback movePageDown(javax.swing.JTree tree)
public static ActionCallback showRowCentered(javax.swing.JTree tree, int row, boolean centerHorizontally)
public static ActionCallback showRowCentered(javax.swing.JTree tree, int row, boolean centerHorizontally, boolean scroll)
public static ActionCallback showAndSelect(javax.swing.JTree tree, int top, int bottom, int row, int previous)
public static ActionCallback showAndSelect(javax.swing.JTree tree, int top, int bottom, int row, int previous, boolean addToSelection)
public static ActionCallback showAndSelect(javax.swing.JTree tree, int top, int bottom, int row, int previous, boolean addToSelection, boolean scroll)
public static ActionCallback showAndSelect(javax.swing.JTree tree, int top, int bottom, int row, int previous, boolean addToSelection, boolean scroll, boolean resetSelection)
public static int getVisibleRowCount(javax.swing.JTree tree)
JTree.getVisibleRowCount()
which returns a preferred number of rows to be displayed within a scroll pane.tree
- tree to get the number of visible rowspublic static void installActions(javax.swing.JTree tree)
public static void collapseAll(javax.swing.JTree tree, int keepSelectionLevel)
tree
- a tree, which nodes should be collapsedkeepSelectionLevel
- a minimal path count of a lead selection path or -1
to restore old selectionpublic static void collapseAll(javax.swing.JTree tree, boolean strict, int keepSelectionLevel)
tree
- a tree, which nodes should be collapsedstrict
- use false
if a single top level node should not be collapsedkeepSelectionLevel
- a minimal path count of a lead selection path or -1
to restore old selectionpublic static void selectNode(javax.swing.JTree tree, javax.swing.tree.TreeNode node)
public static void moveSelectedRow(javax.swing.JTree tree, int direction)
public static java.util.List<javax.swing.tree.TreeNode> listChildren(javax.swing.tree.TreeNode node)
public static void expandRootChildIfOnlyOne(javax.swing.JTree tree)
public static void expandAll(javax.swing.JTree tree)
public static void expandAll(javax.swing.JTree tree, java.lang.Runnable onDone)
tree
- a tree, which nodes should be expandedonDone
- a task to run on EDT after expanding nodespublic static Promise<?> promiseExpandAll(javax.swing.JTree tree)
tree
- a tree, which nodes should be expandedpublic static void expand(javax.swing.JTree tree, int levels)
tree
- to expand nodes oflevels
- depths of the expantionpublic static void expand(javax.swing.JTree tree, int depth, java.lang.Runnable onDone)
tree
- a tree, which nodes should be expandeddepth
- a depth starting from the root nodeonDone
- a task to run on EDT after expanding nodespublic static Promise<?> promiseExpand(javax.swing.JTree tree, int depth)
tree
- a tree, which nodes should be expandeddepth
- a depth starting from the root nodepublic static ActionCallback selectInTree(javax.swing.tree.DefaultMutableTreeNode node, boolean requestFocus, javax.swing.JTree tree)
public static ActionCallback selectInTree(javax.swing.tree.DefaultMutableTreeNode node, boolean requestFocus, javax.swing.JTree tree, boolean center)
public static ActionCallback selectInTree(Project project, javax.swing.tree.DefaultMutableTreeNode node, boolean requestFocus, javax.swing.JTree tree, boolean center)
public static java.util.List<javax.swing.tree.TreePath> collectSelectedPaths(javax.swing.JTree tree)
tree
- a tree, which selection is processedpublic static java.util.List<java.lang.Object> collectSelectedUserObjects(javax.swing.JTree tree)
tree
- a tree, which selection is processedpublic static <T> java.util.List<T> collectSelectedObjects(javax.swing.JTree tree, java.util.function.Function<? super javax.swing.tree.TreePath,? extends T> mapper)
tree
- a tree, which selection is processedmapper
- a function to convert a selected tree path to a corresponding objectpublic static java.util.List<javax.swing.tree.TreePath> collectSelectedPaths(javax.swing.JTree tree, javax.swing.tree.TreePath root)
tree
- a tree, which selection is processedroot
- an ascendant tree path to filter selected tree pathspublic static java.util.List<java.lang.Object> collectSelectedUserObjects(javax.swing.JTree tree, javax.swing.tree.TreePath root)
tree
- a tree, which selection is processedroot
- an ascendant tree path to filter selected tree pathspublic static <T> java.util.List<T> collectSelectedObjects(javax.swing.JTree tree, javax.swing.tree.TreePath root, java.util.function.Function<? super javax.swing.tree.TreePath,? extends T> mapper)
tree
- a tree, which selection is processedroot
- an ascendant tree path to filter selected tree pathsmapper
- a function to convert a selected tree path to a corresponding objectpublic static void unselectPath(javax.swing.JTree tree, javax.swing.tree.TreePath path)
public static Range<java.lang.Integer> getExpandControlRange(javax.swing.JTree aTree, javax.swing.tree.TreePath path)
public static int getDepthOffset(javax.swing.JTree aTree)
public static int getNodeDepth(javax.swing.JTree tree, javax.swing.tree.TreePath path)
public static int getNodeRowX(javax.swing.JTree tree, int row)
public static boolean isLocationInExpandControl(javax.swing.JTree tree, int x, int y)
public static boolean isLocationInExpandControl(javax.swing.JTree tree, javax.swing.tree.TreePath path, int x, int y)
public static void invalidateCacheAndRepaint(javax.swing.plaf.TreeUI ui)
public static RelativePoint getPointForSelection(javax.swing.JTree aTree)
public static RelativePoint getPointForRow(javax.swing.JTree aTree, int aRow)
public static RelativePoint getPointForPath(javax.swing.JTree aTree, javax.swing.tree.TreePath path)
public static RelativePoint getPointForBounds(javax.swing.JComponent aComponent, java.awt.Rectangle aBounds)
public static boolean isOverSelection(javax.swing.JTree tree, java.awt.Point point)
public static void dropSelectionButUnderPoint(javax.swing.JTree tree, java.awt.Point treePoint)
public static java.lang.Object getUserObject(java.lang.Object node)
public static <T> T getUserObject(java.lang.Class<T> type, java.lang.Object node)
public static java.lang.Object getLastUserObject(javax.swing.tree.TreePath path)
path
public static <T> T getLastUserObject(java.lang.Class<T> type, javax.swing.tree.TreePath path)
public static javax.swing.tree.TreePath getSelectedPathIfOne(javax.swing.JTree tree)
public static void ensureSelection(javax.swing.JTree tree)
public static <T extends javax.swing.tree.MutableTreeNode> void insertNode(T child, T parent, javax.swing.tree.DefaultTreeModel model, java.util.Comparator<? super T> comparator)
public static <T extends javax.swing.tree.MutableTreeNode> void insertNode(T child, T parent, javax.swing.tree.DefaultTreeModel model, boolean allowDuplication, java.util.Comparator<? super T> comparator)
public static <T extends javax.swing.tree.TreeNode> int indexedBinarySearch(T parent, T key, java.util.Comparator<? super T> comparator)
public static java.util.Comparator<javax.swing.tree.TreePath> getDisplayOrderComparator(javax.swing.JTree tree)
public static void expand(javax.swing.JTree tree, TreeVisitor visitor, java.util.function.Consumer<? super javax.swing.tree.TreePath> consumer)
tree
- a tree, which nodes should be expandedvisitor
- a visitor that controls expanding of tree nodesconsumer
- a path consumer called on EDT if path is found and expandedpublic static Promise<javax.swing.tree.TreePath> promiseExpand(javax.swing.JTree tree, TreeVisitor visitor)
tree
- a tree, which nodes should be expandedvisitor
- a visitor that controls expanding of tree nodespublic static Promise<java.util.List<javax.swing.tree.TreePath>> promiseExpand(javax.swing.JTree tree, java.util.stream.Stream<? extends TreeVisitor> visitors)
tree
- a tree, which nodes should be expandedvisitors
- visitors to control expanding of tree nodespublic static void makeVisible(javax.swing.JTree tree, TreeVisitor visitor, java.util.function.Consumer<? super javax.swing.tree.TreePath> consumer)
tree
- a tree, which nodes should be made visiblevisitor
- a visitor that controls expanding of tree nodesconsumer
- a path consumer called on EDT if path is found and made visiblepublic static Promise<javax.swing.tree.TreePath> promiseMakeVisible(javax.swing.JTree tree, TreeVisitor visitor)
tree
- a tree, which nodes should be made visiblevisitor
- a visitor that controls expanding of tree nodespublic static Promise<java.util.List<javax.swing.tree.TreePath>> promiseMakeVisible(javax.swing.JTree tree, java.util.stream.Stream<? extends TreeVisitor> visitors)
tree
- a tree, which nodes should be made visiblevisitors
- visitors to control expanding of tree nodes@Deprecated public static void select(javax.swing.JTree tree, TreeVisitor visitor, java.util.function.Consumer<? super javax.swing.tree.TreePath> consumer)
promiseSelect(tree, visitor).onSuccess(consumer)
insteadtree
- a tree, which nodes should be selectedvisitor
- a visitor that controls expanding of tree nodesconsumer
- a path consumer called on EDT if path is found and selectedpublic static Promise<javax.swing.tree.TreePath> promiseSelect(javax.swing.JTree tree, TreeVisitor visitor)
tree
- a tree, which nodes should be selectedvisitor
- a visitor that controls expanding of tree nodespublic static Promise<java.util.List<javax.swing.tree.TreePath>> promiseSelect(javax.swing.JTree tree, java.util.stream.Stream<? extends TreeVisitor> visitors)
tree
- a tree, which nodes should be selectedvisitors
- visitors to control expanding of tree nodespublic static boolean scrollToVisible(javax.swing.JTree tree, javax.swing.tree.TreePath path, boolean centered)
tree
- a tree to scrollpath
- a visible tree path to scrollcentered
- true
to show the specified pathfalse
if a path is hidden (under a collapsed parent)public static Promise<javax.swing.tree.TreePath> promiseSelectFirst(javax.swing.JTree tree)
tree
- a tree, which node should be selectedpublic static Promise<javax.swing.tree.TreePath> promiseSelectFirstLeaf(javax.swing.JTree tree)
tree
- a tree, which node should be selectedpublic static void visit(javax.swing.JTree tree, TreeVisitor visitor, java.util.function.Consumer<? super javax.swing.tree.TreePath> consumer)
tree
- a tree, which nodes should be processedvisitor
- a visitor that controls processing of tree nodesconsumer
- a path consumer called on donepublic static Promise<javax.swing.tree.TreePath> promiseVisit(javax.swing.JTree tree, TreeVisitor visitor)
tree
- a tree, which nodes should be processedvisitor
- a visitor that controls processing of tree nodespublic static javax.swing.tree.TreePath visitVisibleRows(javax.swing.JTree tree, TreeVisitor visitor)
tree
- a tree, which nodes should be processedvisitor
- a visitor that controls processing of tree nodespublic static <T> void visitVisibleRows(javax.swing.JTree tree, java.util.function.Function<? super javax.swing.tree.TreePath,? extends T> mapper, java.util.function.Consumer<? super T> consumer)
tree
- a tree, which nodes should be processedmapper
- a function to convert a visible tree path to a corresponding objectconsumer
- a visible path processor