use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class NodeSelectDialog method getTreeSite.
private JTree getTreeSite() {
if (treeSite == null) {
this.siteTree = this.emptySiteTree();
treeSite = new JTree(this.siteTree);
treeSite.setShowsRootHandles(true);
treeSite.setName("nodeSelectTree");
treeSite.setToggleClickCount(1);
treeSite.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
treeSite.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
@Override
public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
SiteNode node = (SiteNode) treeSite.getLastSelectedPathComponent();
getSelectButton().setEnabled(node != null && (node.getParent() != null || allowRoot));
}
});
treeSite.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 (treeSite.getLastSelectedPathComponent() != null) {
// They selected a site node, deselect any context
getTreeContext().clearSelection();
}
if (e.getClickCount() > 1) {
// Its a double click - close the dialog to select this node
nodeSelected();
}
}
});
treeSite.setCellRenderer(new SiteMapTreeCellRenderer(new ArrayList<SiteMapListener>()));
}
return treeSite;
}
use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class NodeSelectDialog method nodeSelected.
private void nodeSelected() {
SiteNode node = (SiteNode) treeSite.getLastSelectedPathComponent();
if (node != null && (node.getParent() != null || allowRoot)) {
selectedSiteNode = (SiteNode) node.getUserObject();
selectedTarget = null;
NodeSelectDialog.this.setVisible(false);
}
}
use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class NodeSelectDialog method populateContexts.
private void populateContexts(SiteNode root) {
// Uncomment to hide contexts tree if there are no valid contexts -
// not sure if this is a good idea or not :/
//int contexts = 0;
int contextsInScope = 0;
for (Context ctx : Model.getSingleton().getSession().getContexts()) {
// TODO ignore handle protected mode?
if (ctx.getIncludeInContextRegexs().size() > 0) {
SiteNode node = new SiteNode(null, HistoryReference.TYPE_PROXIED, ctx.getName());
node.setUserObject(new Target(ctx));
root.add(node);
//contexts ++;
if (ctx.isInScope()) {
contextsInScope++;
}
}
}
if (contextsInScope > 1) {
// Allow user to choose everything in scope
SiteNode node = new SiteNode(null, HistoryReference.TYPE_PROXIED, Constant.messages.getString("context.allInScope"));
node.setUserObject(new Target(null, null, true, true));
root.add(node);
}
//this.getTreeContext().setVisible(contexts > 0);
this.getTreeContext().expandRow(0);
}
use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class NodeSelectDialog method populateNode.
private void populateNode(SiteNode src, SiteNode dest, SiteNode defaultNode) {
if (src.equals(defaultNode)) {
// Flag this for use later..
this.selectedSiteNode = dest;
}
for (int i = 0; i < src.getChildCount(); i++) {
SiteNode child = (SiteNode) src.getChildAt(i);
SiteNode copy = new SiteNode(null, HistoryReference.TYPE_PROXIED, child.getNodeName());
copy.setUserObject(child);
dest.add(copy);
this.populateNode(child, copy, defaultNode);
}
}
use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.
the class ContextsTreeCellRenderer method getTreeCellRendererComponent.
/**
* Sets custom tree node logos.
*/
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
SiteNode node = null;
Target target = null;
if (value instanceof SiteNode) {
node = (SiteNode) value;
if (node.getUserObject() instanceof Target) {
target = (Target) node.getUserObject();
}
}
if (node != null) {
if (node.isRoot()) {
setIcon(DisplayUtils.getScaledIcon(ROOT_ICON));
} else if (target != null) {
if (target.getContext() != null) {
if (target.getContext().isInScope()) {
setIcon(DisplayUtils.getScaledIcon(CONTEXT_IN_SCOPE_ICON));
} else {
setIcon(DisplayUtils.getScaledIcon(CONTEXT_ICON));
}
} else if (target.isInScopeOnly()) {
setIcon(DisplayUtils.getScaledIcon(ALL_IN_SCOPE_ICON));
}
}
}
return this;
}
Aggregations