Search in sources :

Example 1 with ContextsTreeCellRenderer

use of org.zaproxy.zap.view.ContextsTreeCellRenderer in project zaproxy by zaproxy.

the class SiteMapPanel method getTreeContext.

private JTree getTreeContext() {
    if (treeContext == null) {
        reloadContextTree();
        treeContext = new JTree(this.contextTree);
        treeContext.setShowsRootHandles(true);
        treeContext.setName(CONTEXT_TREE_COMPONENT_NAME);
        treeContext.setToggleClickCount(1);
        treeContext.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        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) {
                if (treeSite.getLastSelectedPathComponent() != null) {
                    // They selected a context node, deselect any context
                    getTreeSite().clearSelection();
                }
                if (e.getClickCount() > 1) {
                    // Its a double click - show the relevant context dialog
                    SiteNode node = (SiteNode) treeContext.getLastSelectedPathComponent();
                    if (node != null && node.getUserObject() != null) {
                        Target target = (Target) node.getUserObject();
                        getView().showSessionDialog(Model.getSingleton().getSession(), ContextGeneralPanel.getPanelName(target.getContext()));
                    }
                }
            }
        });
        treeContext.setComponentPopupMenu(new ContextsCustomPopupMenu());
        treeContext.setCellRenderer(new ContextsTreeCellRenderer());
    }
    return treeContext;
}
Also used : JTree(javax.swing.JTree) Target(org.zaproxy.zap.model.Target) ContextsTreeCellRenderer(org.zaproxy.zap.view.ContextsTreeCellRenderer) SiteNode(org.parosproxy.paros.model.SiteNode)

Aggregations

JTree (javax.swing.JTree)1 SiteNode (org.parosproxy.paros.model.SiteNode)1 Target (org.zaproxy.zap.model.Target)1 ContextsTreeCellRenderer (org.zaproxy.zap.view.ContextsTreeCellRenderer)1