Search in sources :

Example 6 with ExtensionPopupMenuItem

use of org.parosproxy.paros.extension.ExtensionPopupMenuItem in project zaproxy by zaproxy.

the class PopupMenuItemContextDataDriven method reCreateSubMenu.

protected void reCreateSubMenu(SiteNode sn) {
    final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
    for (ExtensionPopupMenuItem menu : subMenus) {
        mainPopupMenuItems.remove(menu);
    }
    subMenus.clear();
    Session session = Model.getSingleton().getSession();
    List<Context> contexts = session.getContexts();
    for (Context context : contexts) {
        if (context.isIncluded(sn)) {
            ExtensionPopupMenuItem piicm = createPopupDataDrivenNodeMenu(context);
            piicm.setMenuIndex(this.getMenuIndex());
            mainPopupMenuItems.add(piicm);
            this.subMenus.add(piicm);
        }
    }
}
Also used : Context(org.zaproxy.zap.model.Context) ExtensionPopupMenuItem(org.parosproxy.paros.extension.ExtensionPopupMenuItem) JMenuItem(javax.swing.JMenuItem) Session(org.parosproxy.paros.model.Session)

Example 7 with ExtensionPopupMenuItem

use of org.parosproxy.paros.extension.ExtensionPopupMenuItem in project zaproxy by zaproxy.

the class PopupMenuItemContextExclude method reCreateSubMenu.

protected void reCreateSubMenu() {
    final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
    for (ExtensionPopupMenuItem menu : subMenus) {
        mainPopupMenuItems.remove(menu);
    }
    subMenus.clear();
    Session session = Model.getSingleton().getSession();
    List<Context> contexts = session.getContexts();
    for (Context context : contexts) {
        ExtensionPopupMenuItem piicm = createPopupExcludeFromContextMenu(context);
        piicm.setMenuIndex(this.getMenuIndex());
        mainPopupMenuItems.add(piicm);
        this.subMenus.add(piicm);
    }
}
Also used : Context(org.zaproxy.zap.model.Context) ExtensionPopupMenuItem(org.parosproxy.paros.extension.ExtensionPopupMenuItem) JMenuItem(javax.swing.JMenuItem) Session(org.parosproxy.paros.model.Session)

Example 8 with ExtensionPopupMenuItem

use of org.parosproxy.paros.extension.ExtensionPopupMenuItem in project zaproxy by zaproxy.

the class MainPopupMenu method showImpl.

private synchronized void showImpl(PopupMenuInvokerWrapper invoker, final int x, final int y) {
    for (int i = 0; i < getComponentCount(); i++) {
        final Component component = getComponent(i);
        try {
            if (component != null && component instanceof ExtensionPopupMenuItem) {
                ExtensionPopupMenuItem menuItem = (ExtensionPopupMenuItem) component;
                // ZAP: prevents a NullPointerException when the treeSite doesn't have a node selected and a popup menu option (Delete/Purge) is selected
                menuItem.setVisible(invoker.isEnable(menuItem));
                if (Control.getSingleton().getMode().equals(Mode.safe) && !menuItem.isSafe()) {
                    // Safe mode, disable all nor safe menu items
                    menuItem.setEnabled(false);
                }
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
    for (int i = 0; i < itemList.size(); i++) {
        final JMenuItem menuItem = itemList.get(i);
        if (menuItem instanceof ExtensionPopupMenuItem) {
            handleMenuItem(invoker, (ExtensionPopupMenuItem) menuItem);
        } else if (menuItem instanceof ExtensionPopupMenu) {
            ExtensionPopupMenu item = (ExtensionPopupMenu) menuItem;
            prepareShow(item);
            handleMenu(invoker, item);
        }
    }
    PopupMenuUtils.removeTopAndBottomSeparators(this);
    if (PopupMenuUtils.isAtLeastOneChildComponentVisible(this)) {
        super.show(invoker.getComponent(), x, y);
    }
}
Also used : ExtensionPopupMenuItem(org.parosproxy.paros.extension.ExtensionPopupMenuItem) ExtensionPopupMenu(org.zaproxy.zap.extension.ExtensionPopupMenu) Component(java.awt.Component) ExtensionPopupMenuComponent(org.zaproxy.zap.view.popup.ExtensionPopupMenuComponent) JMenuItem(javax.swing.JMenuItem)

Aggregations

JMenuItem (javax.swing.JMenuItem)8 ExtensionPopupMenuItem (org.parosproxy.paros.extension.ExtensionPopupMenuItem)8 Session (org.parosproxy.paros.model.Session)7 Context (org.zaproxy.zap.model.Context)7 Component (java.awt.Component)1 ExtensionPopupMenu (org.zaproxy.zap.extension.ExtensionPopupMenu)1 ContextUserAuthManager (org.zaproxy.zap.extension.users.ContextUserAuthManager)1 User (org.zaproxy.zap.users.User)1 ExtensionPopupMenuComponent (org.zaproxy.zap.view.popup.ExtensionPopupMenuComponent)1 PopupMenuItemContext (org.zaproxy.zap.view.popup.PopupMenuItemContext)1