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