Search in sources :

Example 71 with TreePath

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

the class JCheckBoxTree method updatePredecessorsAllChildrenSelectedState.

private void updatePredecessorsAllChildrenSelectedState(TreePath tp) {
    TreePath parentPath = tp.getParentPath();
    if (parentPath == null) {
        return;
    }
    CheckedNode parentCheckedNode = nodesCheckingState.get(parentPath);
    parentCheckedNode.allChildrenSelected = true;
    DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) parentPath.getLastPathComponent();
    for (int i = 0; i < parentNode.getChildCount(); i++) {
        TreePath childPath = parentPath.pathByAddingChild(parentNode.getChildAt(i));
        CheckedNode childCheckedNode = nodesCheckingState.get(childPath);
        if (!allSelected(childCheckedNode)) {
            parentCheckedNode.allChildrenSelected = false;
            break;
        }
    }
    updatePredecessorsAllChildrenSelectedState(parentPath);
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 72 with TreePath

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

the class PopupMenuExportSelectedURLs method getOutputSet.

private SortedSet<String> getOutputSet(TreePath[] startingPoints) {
    JTree siteTree = extension.getView().getSiteTreePanel().getTreeSite();
    ArrayList<TreePath> startingPts = new ArrayList<TreePath>();
    if (ArrayUtils.isEmpty(startingPoints)) {
        startingPts.add(new TreePath(siteTree.getModel().getRoot()));
    } else {
        startingPts.addAll(Arrays.asList(startingPoints));
    }
    SortedSet<String> outputSet = new TreeSet<String>();
    for (TreePath aPath : startingPts) {
        Enumeration<?> en = (((SiteNode) aPath.getLastPathComponent()).preorderEnumeration());
        while (en.hasMoreElements()) {
            SiteNode node = (SiteNode) en.nextElement();
            if (node.isRoot()) {
                continue;
            }
            HistoryReference nodeHR = node.getHistoryReference();
            if (nodeHR != null && !HistoryReference.getTemporaryTypes().contains(nodeHR.getHistoryType())) {
                outputSet.add(nodeHR.getURI().toString());
            }
        }
    }
    return outputSet;
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 73 with TreePath

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

the class TechnologyTreePanel method setTechSet.

/**
     * Sets the technologies that should be selected, if included, and not if excluded.
     *
     * @param techSet the technologies that will be selected, if included, and not if excluded.
     * @see TechSet#includes(Tech)
     */
public void setTechSet(TechSet techSet) {
    Set<Tech> includedTech = techSet.getIncludeTech();
    Iterator<Entry<Tech, DefaultMutableTreeNode>> iter = techToNodeMap.entrySet().iterator();
    while (iter.hasNext()) {
        Entry<Tech, DefaultMutableTreeNode> node = iter.next();
        TreePath tp = this.getPath(node.getValue());
        Tech tech = node.getKey();
        if (ArrayUtils.contains(Tech.builtInTopLevelTech, tech)) {
            techTree.check(tp, containsAnyOfTopLevelTech(includedTech, tech));
        } else {
            techTree.check(tp, techSet.includes(tech));
        }
    }
}
Also used : Tech(org.zaproxy.zap.model.Tech) Entry(java.util.Map.Entry) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath)

Example 74 with TreePath

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

the class NodeSelectDialog method showDialog.

public SiteNode showDialog(SiteNode defaultNode) {
    // Assume Contexts cant be selected
    this.getTreeContext().setVisible(false);
    SiteNode siteRoot = (SiteNode) Model.getSingleton().getSession().getSiteTree().getRoot();
    populateNode(siteRoot, (SiteNode) this.siteTree.getRoot(), defaultNode);
    if (selectedSiteNode != null) {
        // Found the default node, select it
        TreePath path = new TreePath(this.siteTree.getPathToRoot(selectedSiteNode));
        this.getTreeSite().setExpandsSelectedPaths(true);
        this.getTreeSite().setSelectionPath(path);
        this.getTreeSite().scrollPathToVisible(path);
        this.getTreeSite().expandPath(path);
    } else {
        // no default path, just expand the top level
        TreePath path = new TreePath(this.siteTree.getPathToRoot((TreeNode) this.siteTree.getRoot()));
        this.getTreeSite().expandPath(path);
    }
    this.setVisible(true);
    // The dialog is modal so this wont return until the dialog visibility is unset
    return selectedSiteNode;
}
Also used : TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 75 with TreePath

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

the class NodeSelectDialog method showDialog.

public Target showDialog(Target defaultTarget) {
    // Assume Contexts can be selected
    this.getTreeContext().setVisible(true);
    SiteNode siteRoot = (SiteNode) Model.getSingleton().getSession().getSiteTree().getRoot();
    populateContexts((SiteNode) this.contextTree.getRoot());
    if (defaultTarget != null) {
        populateNode(siteRoot, (SiteNode) this.siteTree.getRoot(), defaultTarget.getStartNode());
    } else {
        populateNode(siteRoot, (SiteNode) this.siteTree.getRoot(), null);
    }
    if (selectedSiteNode != null) {
        // Found the default node, select it
        TreePath path = new TreePath(this.siteTree.getPathToRoot(selectedSiteNode));
        this.getTreeSite().setExpandsSelectedPaths(true);
        this.getTreeSite().setSelectionPath(path);
        this.getTreeSite().scrollPathToVisible(path);
        this.getTreeSite().expandPath(path);
    } else {
        // no default path, just expand the top level
        TreePath path = new TreePath(this.siteTree.getPathToRoot((TreeNode) this.siteTree.getRoot()));
        this.getTreeSite().expandPath(path);
    }
    this.setVisible(true);
    // The dialog is modal so this wont return until the dialog visibility is unset
    if (selectedSiteNode != null) {
        return new Target(selectedSiteNode);
    }
    return selectedTarget;
}
Also used : Target(org.zaproxy.zap.model.Target) TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) SiteNode(org.parosproxy.paros.model.SiteNode)

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