Search in sources :

Example 21 with ZapMenuItem

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

the class ExtensionBreak method getMenuAddHttpBreakpoint.

private ZapMenuItem getMenuAddHttpBreakpoint() {
    if (menuHttpBreakpoint == null) {
        menuHttpBreakpoint = new ZapMenuItem("menu.tools.brk.custom", getView().getMenuShortcutKeyStroke(KeyEvent.VK_A, 0, false));
        menuHttpBreakpoint.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                // Check to see if anything is selected in the main tabs
                String url = "";
                Component c = getView().getMainFrame().getFocusOwner();
                if (c != null) {
                    if (c instanceof JList) {
                        // Handles the history list and similar
                        @SuppressWarnings("rawtypes") Object sel = ((JList) c).getSelectedValue();
                        try {
                            if (sel != null && sel instanceof HistoryReference && ((HistoryReference) sel).getURI() != null) {
                                url = ((HistoryReference) sel).getURI().toString();
                            }
                        } catch (Exception e1) {
                        // Ignore
                        }
                    } else if (c instanceof JTree) {
                        // Handles the Sites tree
                        TreePath path = ((JTree) c).getSelectionPath();
                        try {
                            if (path != null && path.getLastPathComponent() instanceof SiteNode) {
                                url = ((SiteNode) path.getLastPathComponent()).getHistoryReference().getURI().toString();
                            }
                        } catch (Exception e1) {
                        // Ignore
                        }
                    }
                }
                httpBreakpoints.handleAddBreakpoint(url);
            }
        });
    }
    return menuHttpBreakpoint;
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem) Component(java.awt.Component) JList(javax.swing.JList) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 22 with ZapMenuItem

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

the class ExtensionEdit method getMenuFind.

/**
 * This method initializes menuFind
 *
 * @return the 'Find' menu item.
 */
private ZapMenuItem getMenuFind() {
    if (menuFind == null) {
        menuFind = new ZapMenuItem("menu.edit.find", getFindDefaultKeyStroke());
        menuFind.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                showFindDialog(getView().getMainFrame(), null);
            }
        });
    }
    return menuFind;
}
Also used : ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem)

Example 23 with ZapMenuItem

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

the class ExtensionActiveScan method getMenuItemPolicy.

/**
 * This method initializes menuItemPolicy
 *
 * @return javax.swing.JMenuItem
 */
private ZapMenuItem getMenuItemPolicy() {
    if (menuItemPolicy == null) {
        menuItemPolicy = new ZapMenuItem("menu.analyse.scanPolicy", getView().getMenuShortcutKeyStroke(KeyEvent.VK_P, 0, false));
        menuItemPolicy.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                showPolicyManagerDialog();
            }
        });
    }
    return menuItemPolicy;
}
Also used : ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem)

Example 24 with ZapMenuItem

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

the class ExtensionActiveScan method getMenuItemCustomScan.

private ZapMenuItem getMenuItemCustomScan() {
    if (menuItemCustomScan == null) {
        menuItemCustomScan = new ZapMenuItem("menu.tools.ascanadv", getView().getMenuShortcutKeyStroke(KeyEvent.VK_A, KeyEvent.ALT_DOWN_MASK, false));
        menuItemCustomScan.setEnabled(Control.getSingleton().getMode() != Mode.safe);
        menuItemCustomScan.addActionListener(e -> showCustomScanDialog((Target) null));
    }
    return menuItemCustomScan;
}
Also used : Target(org.zaproxy.zap.model.Target) ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem)

Example 25 with ZapMenuItem

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

the class ExtensionKeyboard method addAllMenuItems.

private void addAllMenuItems(List<KeyboardShortcut> kss, JMenu menu, boolean reset) {
    for (Component c : menu.getMenuComponents()) {
        if (c instanceof ZapMenuItem) {
            kss.add(menuToShortcut((ZapMenuItem) c, reset));
        } else if (c instanceof JMenu) {
            addAllMenuItems(kss, (JMenu) c, reset);
        } else if (c instanceof JMenuItem) {
            JMenuItem menuItem = (JMenuItem) c;
            logger.debug("Unable to set accelerators on menu " + menuItem.getText());
        }
    }
}
Also used : ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem) Component(java.awt.Component) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Aggregations

ZapMenuItem (org.zaproxy.zap.view.ZapMenuItem)42 ActionEvent (java.awt.event.ActionEvent)14 Component (java.awt.Component)3 ActionListener (java.awt.event.ActionListener)2 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 Target (org.zaproxy.zap.model.Target)2 File (java.io.File)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)1 JFileChooser (javax.swing.JFileChooser)1 JList (javax.swing.JList)1 JTree (javax.swing.JTree)1 FileFilter (javax.swing.filechooser.FileFilter)1 TreePath (javax.swing.tree.TreePath)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 HistoryReference (org.parosproxy.paros.model.HistoryReference)1 SiteNode (org.parosproxy.paros.model.SiteNode)1 HttpMessage (org.parosproxy.paros.network.HttpMessage)1