Search in sources :

Example 46 with TreePath

use of javax.swing.tree.TreePath in project intellij-community by JetBrains.

the class RepositoryBrowserComponent method setSelectedNode.

public void setSelectedNode(@NotNull final TreeNode node) {
    final TreeNode[] pathNodes = ((RepositoryTreeModel) myRepositoryTree.getModel()).getPathToRoot(node);
    myRepositoryTree.setSelectionPath(new TreePath(pathNodes));
}
Also used : TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode)

Example 47 with TreePath

use of javax.swing.tree.TreePath in project intellij-community by JetBrains.

the class PyViewNumericContainerAction method update.

@Override
public void update(AnActionEvent e) {
    e.getPresentation().setVisible(false);
    TreePath[] paths = getSelectedPaths(e.getDataContext());
    if (paths != null) {
        if (paths.length > 1) {
            e.getPresentation().setVisible(false);
            return;
        }
        XValueNodeImpl node = getSelectedNode(e.getDataContext());
        if (node != null && node.getValueContainer() instanceof PyDebugValue && node.isComputed()) {
            PyDebugValue debugValue = (PyDebugValue) node.getValueContainer();
            String nodeType = debugValue.getType();
            if ("ndarray".equals(nodeType)) {
                e.getPresentation().setText("View as Array");
                e.getPresentation().setVisible(true);
            } else if (("DataFrame".equals(nodeType))) {
                e.getPresentation().setText("View as DataFrame");
                e.getPresentation().setVisible(true);
            } else {
                e.getPresentation().setVisible(false);
            }
        } else {
            e.getPresentation().setVisible(false);
        }
    }
}
Also used : PyDebugValue(com.jetbrains.python.debugger.PyDebugValue) TreePath(javax.swing.tree.TreePath) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl)

Example 48 with TreePath

use of javax.swing.tree.TreePath in project intellij-community by JetBrains.

the class AssociationsEditor method expandTree.

private void expandTree(DefaultTreeModel newModel) {
    final TreePath rootPath = new TreePath(newModel.getRoot());
    final Object element = myBuilder.getTreeStructure().getRootElement();
    myBuilder.batch(new Progressive() {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            myBuilder.expand(element, null);
            myBuilder.expand(myBuilder.getTreeStructure().getChildElements(element), null);
        }
    });
    myTree.setSelectionPath(rootPath);
    myTree.scrollRectToVisible(new Rectangle(new Point(0, 0)));
}
Also used : Progressive(com.intellij.openapi.progress.Progressive) TreePath(javax.swing.tree.TreePath) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator)

Example 49 with TreePath

use of javax.swing.tree.TreePath in project intellij-community by JetBrains.

the class ComponentTree method getSelectedComponents.

/**
   * TODO[vova] should return pair <RadComponent, TreePath>
   *
   * @return currently selected components.
   */
@NotNull
public RadComponent[] getSelectedComponents() {
    final TreePath[] paths = getSelectionPaths();
    if (paths == null) {
        return RadComponent.EMPTY_ARRAY;
    }
    final ArrayList<RadComponent> result = new ArrayList<>(paths.length);
    for (TreePath path : paths) {
        final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
        if (node != null && node.getUserObject() instanceof ComponentPtrDescriptor) {
            final ComponentPtrDescriptor descriptor = (ComponentPtrDescriptor) node.getUserObject();
            final ComponentPtr ptr = descriptor.getElement();
            if (ptr != null && ptr.isValid()) {
                result.add(ptr.getComponent());
            }
        }
    }
    return result.toArray(new RadComponent[result.size()]);
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) NotNull(org.jetbrains.annotations.NotNull)

Example 50 with TreePath

use of javax.swing.tree.TreePath in project intellij-community by JetBrains.

the class ComponentTree method getToolTipText.

@Nullable
public String getToolTipText(final MouseEvent e) {
    final TreePath path = getPathForLocation(e.getX(), e.getY());
    final RadComponent component = getComponentFromPath(path);
    if (component != null) {
        final ErrorInfo errorInfo = ErrorAnalyzer.getErrorForComponent(component);
        if (errorInfo != null) {
            return errorInfo.myDescription;
        }
    }
    return null;
}
Also used : TreePath(javax.swing.tree.TreePath) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

TreePath (javax.swing.tree.TreePath)539 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)177 ArrayList (java.util.ArrayList)58 TreeNode (javax.swing.tree.TreeNode)56 Nullable (org.jetbrains.annotations.Nullable)49 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)46 JTree (javax.swing.JTree)34 NotNull (org.jetbrains.annotations.NotNull)32 Test (org.junit.Test)22 Tree (com.intellij.ui.treeStructure.Tree)21 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)21 TreeSelectionListener (javax.swing.event.TreeSelectionListener)21 MouseEvent (java.awt.event.MouseEvent)18 Point (java.awt.Point)17 ActionEvent (java.awt.event.ActionEvent)15 KeyEvent (java.awt.event.KeyEvent)12 EVTask (net.sourceforge.processdash.ev.EVTask)12 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 KeyAdapter (java.awt.event.KeyAdapter)11 List (java.util.List)11