Search in sources :

Example 26 with TreePath

use of javax.swing.tree.TreePath in project binnavi by google.

the class CNodeExpander method expandNode.

/**
   * Expands the project tree node that represents the given object.
   * 
   * @param tree The project tree.
   * @param object Object whose node is expanded.
   */
public static void expandNode(final JTree tree, final Object object) {
    tree.expandPath(new TreePath(findNode(tree, object).getPath()));
    tree.validate();
}
Also used : TreePath(javax.swing.tree.TreePath)

Example 27 with TreePath

use of javax.swing.tree.TreePath in project binnavi by google.

the class TypeEditorPanel method getSelectedMembers.

@Override
public ImmutableList<TypeMember> getSelectedMembers() {
    final Builder<TypeMember> builder = ImmutableList.<TypeMember>builder();
    final TreePath[] paths = typesTree.getSelectionPaths();
    if (paths != null) {
        for (final TreePath path : typesTree.getSelectionPaths()) {
            final Object node = path.getLastPathComponent();
            if (node instanceof TypeMemberTreeNode) {
                builder.add(((TypeMemberTreeNode) node).getTypeMember());
            }
        }
    }
    return builder.build();
}
Also used : TreePath(javax.swing.tree.TreePath) TypeMember(com.google.security.zynamics.binnavi.disassembly.types.TypeMember)

Example 28 with TreePath

use of javax.swing.tree.TreePath in project binnavi by google.

the class JCriteriumTreeModel method nodeStructureChanged.

@Override
public void nodeStructureChanged(final TreeNode node) {
    final Set<ICriterium> criteriumSet = new HashSet<ICriterium>();
    final Enumeration<TreePath> expandedPaths = m_jtree.getExpandedDescendants(new TreePath(getRoot()));
    if (expandedPaths != null) {
        while (expandedPaths.hasMoreElements()) {
            final TreePath path = expandedPaths.nextElement();
            final JCriteriumTreeNode expandedNode = (JCriteriumTreeNode) path.getLastPathComponent();
            criteriumSet.add(expandedNode.getCriterium());
        }
    }
    super.nodeStructureChanged(node);
    final Enumeration<?> nodes = ((JCriteriumTreeNode) getRoot()).breadthFirstEnumeration();
    while (nodes.hasMoreElements()) {
        final JCriteriumTreeNode nextNode = (JCriteriumTreeNode) nodes.nextElement();
        if (criteriumSet.contains(nextNode.getCriterium())) {
            m_jtree.expandPath(new TreePath(nextNode.getPath()));
        }
    }
}
Also used : ICriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriterium) TreePath(javax.swing.tree.TreePath) HashSet(java.util.HashSet)

Example 29 with TreePath

use of javax.swing.tree.TreePath in project binnavi by google.

the class CCriteriumFunctions method appendCriterium.

/**
   * Appends a criterium to the criterium tree. The criterium is selected through the given combo
   * box.
   *
   * @param jtree Visible criteria tree.
   * @param ctree Backs the visible criteria tree.
   * @param conditionBox Provides the criterium to add.
   */
public static void appendCriterium(final JCriteriumTree jtree, final CCriteriumTree ctree, final CConditionBox conditionBox) {
    final TreePath path = jtree.getSelectionPath();
    if (path != null) {
        final JCriteriumTreeNode criteriumTreeNode = (JCriteriumTreeNode) path.getLastPathComponent();
        final CCriteriumTreeNode parent = CCriteriumFunctions.findNode(ctree.getRoot(), criteriumTreeNode.getCriterium());
        final CCriteriumWrapper selectedItem = (CCriteriumWrapper) conditionBox.getSelectedItem();
        if (selectedItem != null) {
            final ICriterium criterium = selectedItem.getObject().createCriterium();
            if (criterium != null) {
                appendCriterium(ctree, parent, criterium);
            }
        }
    }
}
Also used : TreePath(javax.swing.tree.TreePath) ICriterium(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.ICriterium) JCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionTree.JCriteriumTreeNode) CCriteriumWrapper(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.Conditions.CCriteriumWrapper) CCriteriumTreeNode(com.google.security.zynamics.binnavi.Gui.CriteriaDialog.ExpressionModel.CCriteriumTreeNode)

Example 30 with TreePath

use of javax.swing.tree.TreePath in project zaproxy by zaproxy.

the class AlertPanel method setLinkWithSitesTreeSelection.

/**
     * Sets whether the "Alerts" tree is filtered, or not based on a selected "Sites" tree node.
     * <p>
     * If {@code enabled} is {@code true} only the alerts of the selected "Sites" tree node will be shown.
     * </p>
     * <p>
     * Calling this method removes the filter "Just in Scope", if enabled, as they are mutually exclusive.
     * </p>
     * 
     * @param enabled {@code true} if the "Alerts" tree should be filtered based on the "Sites" tree selection, {@code false}
     *            otherwise.
     * @see ExtensionAlert#setShowJustInScope(boolean)
     */
public void setLinkWithSitesTreeSelection(boolean enabled) {
    linkWithSitesTreeButton.setSelected(enabled);
    if (enabled) {
        extension.setShowJustInScope(false);
        final JTree sitesTree = view.getSiteTreePanel().getTreeSite();
        final TreePath selectionPath = sitesTree.getSelectionPath();
        getTreeAlert().setModel(getLinkWithSitesTreeModel());
        if (selectionPath != null) {
            recreateLinkWithSitesTreeModel((SiteNode) selectionPath.getLastPathComponent());
        }
        sitesTree.addTreeSelectionListener(getLinkWithSitesTreeSelectionListener());
    } else {
        extension.setMainTreeModel();
        ((AlertNode) getLinkWithSitesTreeModel().getRoot()).removeAllChildren();
        view.getSiteTreePanel().getTreeSite().removeTreeSelectionListener(getLinkWithSitesTreeSelectionListener());
    }
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath)

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