use of org.parosproxy.paros.model.SiteNode 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 org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class NodeSelectDialog method contextSelected.
private void contextSelected() {
SiteNode node = (SiteNode) treeContext.getLastSelectedPathComponent();
if (node != null && (node.getParent() != null || allowRoot)) {
selectedTarget = (Target) node.getUserObject();
selectedSiteNode = null;
NodeSelectDialog.this.setVisible(false);
}
}
use of org.parosproxy.paros.model.SiteNode 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 org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class NodeSelectDialog method getTreeContext.
private JTree getTreeContext() {
if (treeContext == null) {
this.contextTree = this.emptyContextTree();
treeContext = new JTree(this.contextTree);
treeContext.setShowsRootHandles(true);
treeContext.setName("nodeContextTree");
treeContext.setToggleClickCount(1);
treeContext.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
treeContext.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
@Override
public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
SiteNode node = (SiteNode) treeContext.getLastSelectedPathComponent();
getSelectButton().setEnabled(node != null && (node.getParent() != null || allowRoot));
}
});
treeContext.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mousePressed(java.awt.event.MouseEvent e) {
}
@Override
public void mouseReleased(java.awt.event.MouseEvent e) {
mouseClicked(e);
}
@Override
public void mouseClicked(java.awt.event.MouseEvent e) {
// right mouse button action
if (treeContext.getLastSelectedPathComponent() != null) {
// They selected a context node, deselect any site node
getTreeSite().clearSelection();
}
if (e.getClickCount() > 1) {
// Its a double click - close the dialog to select this node
contextSelected();
}
}
});
treeContext.setCellRenderer(new ContextsTreeCellRenderer());
}
return treeContext;
}
use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class NodeSelectDialog method emptySiteTree.
private DefaultTreeModel emptySiteTree() {
// Make a very sparse copy of the site tree
SiteNode siteRoot = (SiteNode) Model.getSingleton().getSession().getSiteTree().getRoot();
SiteNode root = new SiteNode(null, -1, Constant.messages.getString("tab.sites"));
root.setUserObject(siteRoot);
return new DefaultTreeModel(root);
}
Aggregations