Search in sources :

Example 6 with ZapMenuItem

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

the class ExtensionAutoUpdate method getMenuItemCheckUpdate.

/**
 * This method initializes menuItemEncoder
 *
 * @return javax.swing.JMenuItem
 */
private ZapMenuItem getMenuItemCheckUpdate() {
    if (menuItemCheckUpdate == null) {
        menuItemCheckUpdate = new ZapMenuItem("cfu.help.menu.check", getView().getMenuShortcutKeyStroke(KeyEvent.VK_U, 0, false));
        menuItemCheckUpdate.setText(Constant.messages.getString("cfu.help.menu.check"));
        menuItemCheckUpdate.addActionListener(new java.awt.event.ActionListener() {

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

Example 7 with ZapMenuItem

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

the class ExtensionAutoUpdate method getMenuItemLoadAddOn.

private ZapMenuItem getMenuItemLoadAddOn() {
    if (menuItemLoadAddOn == null) {
        menuItemLoadAddOn = new ZapMenuItem("cfu.file.menu.loadaddon", getView().getMenuShortcutKeyStroke(KeyEvent.VK_L, 0, false));
        menuItemLoadAddOn.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                try {
                    JFileChooser chooser = new JFileChooser(Model.getSingleton().getOptionsParam().getUserDirectory());
                    File file = null;
                    chooser.setFileFilter(new FileFilter() {

                        @Override
                        public boolean accept(File file) {
                            return file.isDirectory() || (file.isFile() && AddOn.isAddOnFileName(file.getName()));
                        }

                        @Override
                        public String getDescription() {
                            return Constant.messages.getString("file.format.zap.addon");
                        }
                    });
                    int rc = chooser.showOpenDialog(getView().getMainFrame());
                    if (rc == JFileChooser.APPROVE_OPTION) {
                        file = chooser.getSelectedFile();
                        if (file == null) {
                            return;
                        }
                        installLocalAddOn(file.toPath());
                    }
                } catch (Exception e1) {
                    logger.error(e1.getMessage(), e1);
                }
            }
        });
    }
    return menuItemLoadAddOn;
}
Also used : JFileChooser(javax.swing.JFileChooser) ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem) FileFilter(javax.swing.filechooser.FileFilter) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConfigurationException(org.apache.commons.configuration.ConfigurationException) IOException(java.io.IOException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 8 with ZapMenuItem

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

the class MainMenuBar method getMenuFileExitAndDelete.

private javax.swing.JMenuItem getMenuFileExitAndDelete() {
    if (menuFileExitAndDelete == null) {
        menuFileExitAndDelete = new ZapMenuItem("menu.file.exit.delete");
        menuFileExitAndDelete.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                int ans = View.getSingleton().showConfirmDialog(Constant.messages.getString("menu.file.exit.delete.warning"));
                if (ans == JOptionPane.OK_OPTION) {
                    Control.getSingleton().exitAndDeleteSession(Model.getSingleton().getSession().getFileName());
                }
            }
        });
    }
    return menuFileExitAndDelete;
}
Also used : ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem) ActionEvent(java.awt.event.ActionEvent)

Example 9 with ZapMenuItem

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

the class MainMenuBar method getMenuFileExit.

private JMenuItem getMenuFileExit() {
    if (menuFileExit == null) {
        menuFileExit = new ZapMenuItem("menu.file.exit");
        menuFileExit.addActionListener(new java.awt.event.ActionListener() {

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

Example 10 with ZapMenuItem

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

the class MainMenuBar method getMenuFileSaveAs.

private JMenuItem getMenuFileSaveAs() {
    if (menuFileSaveAs == null) {
        menuFileSaveAs = new ZapMenuItem("menu.file.persistSession");
        menuFileSaveAs.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                if (Model.getSingleton().getSession().isNewState()) {
                    getMenuFileControl().saveAsSession();
                } else {
                    View.getSingleton().showWarningDialog(Constant.messages.getString("menu.file.sessionExists.error"));
                }
                if (!Model.getSingleton().getSession().isNewState()) {
                    toggleSnapshotState(true);
                }
            }
        });
    }
    return menuFileSaveAs;
}
Also used : ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem) ActionEvent(java.awt.event.ActionEvent)

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