@Nullable private TreePath getSelectedUniquePath() { JTree tree = getTree(); if (tree == null) return null; TreePath[] paths = tree.getSelectionPaths(); return paths == null || paths.length != 1 ? null : paths[0]; }
public void addSelectionPathTo(final Object element) { DefaultMutableTreeNode node = myAbstractTreeBuilder.getNodeForElement(element); if (node != null) { final JTree tree = getTree(); final TreePath path = new TreePath(node.getPath()); if (node == tree.getModel().getRoot() && !tree.isExpanded(path)) tree.expandPath(path); tree.addSelectionPath(path); } }
private void applySelected(final JTree tree, final DefaultMutableTreeNode node) { TreeUtil.unselect(tree, node); List<TreePath> selectionPaths = new ArrayList<TreePath>(); for (List<PathElement> pathElements : mySelectedPaths) { applySelectedTo(pathElements, tree.getModel().getRoot(), tree, selectionPaths); } if (selectionPaths.size() > 1) { for (TreePath path : selectionPaths) { tree.addSelectionPath(path); } } }
@Override public void update(AnActionEvent e) { Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); e.getPresentation().setEnabled(false); if (focusOwner instanceof JComponent && SpeedSearchBase.hasActiveSpeedSearch((JComponent) focusOwner)) { return; } if (StackingPopupDispatcher.getInstance().isPopupFocused()) return; if (focusOwner instanceof JTree) { JTree tree = (JTree) focusOwner; if (!tree.isEditing()) { e.getPresentation().setEnabled(true); } } else if (focusOwner instanceof JTable) { JTable table = (JTable) focusOwner; if (!table.isEditing()) { e.getPresentation().setEnabled(true); } } }
@Nullable private Object[] getSelectedTreeElements() { final JTree tree = getTree(); return tree != null ? convertPathsToTreeElements(tree.getSelectionPaths()) : null; }
private Object[] getSelectedElements() { final JTree tree = getTree(); return tree != null ? convertPathsToValues(tree.getSelectionPaths()) : ArrayUtil.EMPTY_OBJECT_ARRAY; }
public ActionCallback expand(DefaultMutableTreeNode node) { myTree.expandPath(new TreePath(node.getPath())); return new ActionCallback.Done(); }
public void applyTo(final JTree tree, final DefaultMutableTreeNode node) { applyExpanded(getFacade(tree), node); if (tree.getSelectionCount() == 0) { applySelected(tree, node); } }
public void applyTo(JTree tree) { applyExpanded(getFacade(tree), tree.getModel().getRoot()); }