Search in sources :

Example 1 with ExtensionPopupMenu

use of org.zaproxy.zap.extension.ExtensionPopupMenu 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)

Example 2 with ExtensionPopupMenu

use of org.zaproxy.zap.extension.ExtensionPopupMenu in project zaproxy by zaproxy.

the class MainPopupMenu method getSuperMenu.

// ZAP: Added support for submenus
private JMenu getSuperMenu(String name, int index) {
    JMenu superMenu = superMenus.get(name);
    if (superMenu == null) {
        // Use an ExtensionPopupMenu so child menus are dismissed
        superMenu = new ExtensionPopupMenu(name) {

            private static final long serialVersionUID = 6825880451078204378L;

            @Override
            public boolean isEnableForComponent(Component invoker) {
                return true;
            }
        };
        superMenus.put(name, superMenu);
        addMenuItem(superMenu, index);
    }
    return superMenu;
}
Also used : ExtensionPopupMenu(org.zaproxy.zap.extension.ExtensionPopupMenu) Component(java.awt.Component) ExtensionPopupMenuComponent(org.zaproxy.zap.view.popup.ExtensionPopupMenuComponent) JMenu(javax.swing.JMenu)

Aggregations

Component (java.awt.Component)2 ExtensionPopupMenu (org.zaproxy.zap.extension.ExtensionPopupMenu)2 ExtensionPopupMenuComponent (org.zaproxy.zap.view.popup.ExtensionPopupMenuComponent)2 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 ExtensionPopupMenuItem (org.parosproxy.paros.extension.ExtensionPopupMenuItem)1