@Nullable public static DebuggerTreeNodeImpl[] getSelectedNodes(DataContext dataContext) { DebuggerTree tree = getTree(dataContext); if (tree == null) return null; TreePath[] paths = tree.getSelectionPaths(); if (paths == null || paths.length == 0) { return EMPTY_TREE_NODE_ARRAY; } List<DebuggerTreeNodeImpl> nodes = new ArrayList<DebuggerTreeNodeImpl>(paths.length); for (TreePath path : paths) { Object component = path.getLastPathComponent(); if (component instanceof DebuggerTreeNodeImpl) { nodes.add((DebuggerTreeNodeImpl) component); } } return nodes.toArray(new DebuggerTreeNodeImpl[nodes.size()]); }
@Nullable public static DebuggerTreeNodeImpl getSelectedNode(DataContext dataContext) { DebuggerTree tree = getTree(dataContext); if (tree == null) return null; if (tree.getSelectionCount() != 1) { return null; } TreePath path = tree.getSelectionPath(); if (path == null) { return null; } Object component = path.getLastPathComponent(); if (!(component instanceof DebuggerTreeNodeImpl)) { return null; } return (DebuggerTreeNodeImpl) component; }