Search in sources :

Example 26 with TreeNode

use of javax.swing.tree.TreeNode in project jmeter by apache.

the class CollapseExpandTreeBranch method doAction.

/**
     * This method performs the actual command processing.
     *
     * @param e the generic UI action event
     */
@Override
public void doAction(ActionEvent e) {
    JMeterTreeListener treeListener = GuiPackage.getInstance().getTreeListener();
    JTree jTree = GuiPackage.getInstance().getMainFrame().getTree();
    JMeterTreeNode[] selectedNodes = treeListener.getSelectedNodes();
    for (JMeterTreeNode currentNode : selectedNodes) {
        if (!currentNode.isLeaf()) {
            TreeNode[] nodes = GuiPackage.getInstance().getTreeModel().getPathToRoot(currentNode);
            TreePath path = new TreePath(nodes);
            boolean collapse = ActionNames.COLLAPSE.equals(e.getActionCommand());
            expandCollapseNode(jTree, path, collapse);
        }
    }
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) JMeterTreeListener(org.apache.jmeter.gui.tree.JMeterTreeListener) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) TreeNode(javax.swing.tree.TreeNode) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode)

Example 27 with TreeNode

use of javax.swing.tree.TreeNode in project jmeter by apache.

the class CollapseExpandTreeBranch method expandCollapseNode.

private void expandCollapseNode(JTree jTree, TreePath parent, boolean collapse) {
    TreeNode node = (TreeNode) parent.getLastPathComponent();
    if (node.isLeaf()) {
        return;
    }
    Enumeration<?> children = node.children();
    while (children.hasMoreElements()) {
        TreeNode child = (TreeNode) children.nextElement();
        TreePath path = parent.pathByAddingChild(child);
        expandCollapseNode(jTree, path, collapse);
    }
    if (collapse) {
        jTree.collapsePath(parent);
    } else {
        jTree.expandPath(parent);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) TreeNode(javax.swing.tree.TreeNode)

Example 28 with TreeNode

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

the class InspectionViewNavigationPanel method resetChildrenNavigation.

private void resetChildrenNavigation() {
    final int currentChildrenCount = myNode.getChildCount();
    if (myShownChildrenCount != currentChildrenCount) {
        myLinks.removeAll();
        myLinks.add(Box.createVerticalStrut(JBUI.scale(10)));
        for (int i = 0; i < currentChildrenCount; i++) {
            final TreeNode child = myNode.getChildAt(i);
            final LinkLabel link = new LinkLabel(child.toString(), null) {

                @Override
                public void doClick() {
                    TreeUtil.selectInTree((DefaultMutableTreeNode) child, true, myTree);
                }
            };
            link.setBorder(IdeBorderFactory.createEmptyBorder(1, 17, 3, 1));
            myLinks.add(link);
        }
        myShownChildrenCount = currentChildrenCount;
    }
}
Also used : TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) LinkLabel(com.intellij.ui.components.labels.LinkLabel)

Example 29 with TreeNode

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

the class CachedInspectionTreeNode method dropCache.

@SuppressWarnings("ResultOfMethodCallIgnored")
protected void dropCache(Project project) {
    myValid = calculateIsValid();
    myPresentableName = calculatePresentableName();
    for (int i = 0; i < getChildCount(); i++) {
        TreeNode child = getChildAt(i);
        if (child instanceof CachedInspectionTreeNode) {
            ((CachedInspectionTreeNode) child).dropCache(project);
        }
    }
}
Also used : TreeNode(javax.swing.tree.TreeNode)

Example 30 with TreeNode

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

the class DetectedFrameworksTree method collapseDirectoryNode.

private static FrameworkDirectoryNode collapseDirectoryNode(FrameworkDirectoryNode node) {
    if (node.getChildCount() == 1) {
        final TreeNode child = node.getChildAt(0);
        if (child instanceof FrameworkDirectoryNode) {
            return collapseDirectoryNode((FrameworkDirectoryNode) child);
        }
    }
    for (int i = 0; i < node.getChildCount(); i++) {
        TreeNode child = node.getChildAt(i);
        if (child instanceof FrameworkDirectoryNode) {
            final FrameworkDirectoryNode collapsed = collapseDirectoryNode((FrameworkDirectoryNode) child);
            if (collapsed != child) {
                node.remove(i);
                node.insert(collapsed, i);
            }
        }
    }
    return node;
}
Also used : TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CheckedTreeNode(com.intellij.ui.CheckedTreeNode)

Aggregations

TreeNode (javax.swing.tree.TreeNode)149 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)74 TreePath (javax.swing.tree.TreePath)56 Nullable (org.jetbrains.annotations.Nullable)20 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)12 ArrayList (java.util.ArrayList)10 Enumeration (java.util.Enumeration)10 NotNull (org.jetbrains.annotations.NotNull)10 MutableTreeNode (javax.swing.tree.MutableTreeNode)8 JTree (javax.swing.JTree)7 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)6 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)4 Project (com.intellij.openapi.project.Project)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 CheckedTreeNode (com.intellij.ui.CheckedTreeNode)4 Tree (com.intellij.ui.treeStructure.Tree)4 Point (java.awt.Point)4 File (java.io.File)4 AllIcons (com.intellij.icons.AllIcons)3 Pair (com.intellij.openapi.util.Pair)3