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());
}
}
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);
}
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);
}
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));
}
}
}
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));
}
}
}
Aggregations