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);
}
}
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;
}
Aggregations