Search in sources :

Example 96 with DefaultMutableTreeNode

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

the class JCheckBoxTree method addSubtreeToCheckingStateTracking.

// Creating data structure of the current model for the checking mechanism
private void addSubtreeToCheckingStateTracking(DefaultMutableTreeNode node) {
    TreeNode[] path = node.getPath();
    TreePath tp = new TreePath(path);
    CheckedNode cn = new CheckedNode(false, node.getChildCount() > 0, false);
    nodesCheckingState.put(tp, cn);
    for (int i = 0; i < node.getChildCount(); i++) {
        addSubtreeToCheckingStateTracking((DefaultMutableTreeNode) tp.pathByAddingChild(node.getChildAt(i)).getLastPathComponent());
    }
}
Also used : TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 97 with DefaultMutableTreeNode

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

the class JCheckBoxTree method main.

public static void main(String[] params) {
    // Simple test code
    JFrame f = new JFrame();
    f.setSize(new Dimension(500, 500));
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.setSize(new Dimension(500, 500));
    f.getContentPane().add(p);
    JCheckBoxTree cbt = new JCheckBoxTree();
    cbt.setShowsRootHandles(true);
    JScrollPane scroll = new JScrollPane();
    scroll.setViewportView(cbt);
    p.add(scroll, BorderLayout.CENTER);
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Tech");
    DefaultMutableTreeNode db = new DefaultMutableTreeNode("Db");
    root.add(db);
    db.add(new DefaultMutableTreeNode("HypersonicSQL"));
    db.add(new DefaultMutableTreeNode("MsSQL"));
    db.add(new DefaultMutableTreeNode("MySQL"));
    db.add(new DefaultMutableTreeNode("Oracle"));
    db.add(new DefaultMutableTreeNode("PostgreSQL"));
    DefaultMutableTreeNode os = new DefaultMutableTreeNode("OS");
    root.add(os);
    os.add(new DefaultMutableTreeNode("Linux"));
    DefaultMutableTreeNode ws = new DefaultMutableTreeNode("WS");
    root.add(ws);
    DefaultTreeModel model = new DefaultTreeModel(root);
    cbt.setModel(model);
    f.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JFrame(javax.swing.JFrame) Dimension(java.awt.Dimension) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 98 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode 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 99 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode 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 100 with DefaultMutableTreeNode

use of javax.swing.tree.DefaultMutableTreeNode in project Botnak by Gocnak.

the class GUIViewerList method filterNode.

private synchronized void filterNode(DefaultMutableTreeNode node, String text, DefaultMutableTreeNode filtered) {
    for (int i = 0; i < node.getChildCount(); i++) {
        DefaultMutableTreeNode nameNode = (DefaultMutableTreeNode) node.getChildAt(i);
        String name = (String) nameNode.getUserObject();
        if (name.startsWith(text)) {
            filtered.add(new DefaultMutableTreeNode(name));
        }
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Aggregations

DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)605 TreePath (javax.swing.tree.TreePath)162 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)85 Nullable (org.jetbrains.annotations.Nullable)50 ArrayList (java.util.ArrayList)44 TreeNode (javax.swing.tree.TreeNode)42 Test (org.junit.Test)39 JTree (javax.swing.JTree)34 NotNull (org.jetbrains.annotations.NotNull)32 VirtualFile (com.intellij.openapi.vfs.VirtualFile)28 JScrollPane (javax.swing.JScrollPane)25 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)21 TreeSelectionListener (javax.swing.event.TreeSelectionListener)21 Module (com.intellij.openapi.module.Module)20 Tree (com.intellij.ui.treeStructure.Tree)19 Enumeration (java.util.Enumeration)18 MProduct (org.compiere.model.MProduct)17 MouseEvent (java.awt.event.MouseEvent)15 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)14 List (java.util.List)13