Search in sources :

Example 61 with JButton

use of javax.swing.JButton in project zaproxy by zaproxy.

the class ManageAddOnsDialog method getUninstallButton.

private JButton getUninstallButton() {
    if (uninstallButton == null) {
        uninstallButton = new JButton();
        uninstallButton.setText(Constant.messages.getString("cfu.button.addons.uninstall"));
        // Nothing will be selected initially
        uninstallButton.setEnabled(false);
        uninstallButton.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                Set<AddOn> selectedAddOns = installedAddOnsModel.getSelectedAddOns();
                if (selectedAddOns.isEmpty()) {
                    return;
                }
                Set<AddOn> addOnsBeingDownloaded = installedAddOnsModel.getDownloadingAddOns();
                addOnsBeingDownloaded.addAll(uninstalledAddOnsModel.getDownloadingAddOns());
                AddOnDependencyChecker calc = new AddOnDependencyChecker(installedAddOns, latestInfo);
                AddOnDependencyChecker.UninstallationResult changes = calc.calculateUninstallChanges(selectedAddOns);
                if (!calc.confirmUninstallChanges(ManageAddOnsDialog.this, changes, addOnsBeingDownloaded)) {
                    return;
                }
                Set<AddOn> addOns = changes.getUninstallations();
                Set<Extension> extensions = changes.getExtensions();
                if (!extension.warnUnsavedResourcesOrActiveActions(ManageAddOnsDialog.this, addOns, extensions, false)) {
                    return;
                }
                extension.uninstallAddOnsWithView(ManageAddOnsDialog.this, addOns, false, new HashSet<AddOn>());
            }
        });
    }
    return uninstallButton;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent) HashSet(java.util.HashSet)

Example 62 with JButton

use of javax.swing.JButton in project zaproxy by zaproxy.

the class CertificateView method initComponents.

/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
private void initComponents() {
    closeButton = new JButton();
    certificateScrollPane = new JScrollPane();
    certificateTextArea = new ZapTextArea();
    //TODO: Constant for messages.properties
    setTitle("Certificate");
    //TODO: Constant for messages.properties
    closeButton.setText("Close");
    closeButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            closeButtonActionPerformed(evt);
        }
    });
    certificateScrollPane.setViewportView(certificateTextArea);
    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(closeButton, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE).addComponent(certificateScrollPane, GroupLayout.DEFAULT_SIZE, 658, Short.MAX_VALUE)).addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addComponent(certificateScrollPane, GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(closeButton).addContainerGap()));
    pack();
}
Also used : JScrollPane(javax.swing.JScrollPane) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) GroupLayout(javax.swing.GroupLayout) ZapTextArea(org.zaproxy.zap.utils.ZapTextArea)

Example 63 with JButton

use of javax.swing.JButton in project zaproxy by zaproxy.

the class ExtensionAutoUpdate method getAddonsButton.

private JButton getAddonsButton() {
    if (addonsButton == null) {
        addonsButton = new JButton();
        addonsButton.setIcon(new ImageIcon(ExtensionAutoUpdate.class.getResource("/resource/icon/fugue/block.png")));
        addonsButton.setToolTipText(Constant.messages.getString("cfu.button.addons.browse"));
        addonsButton.setEnabled(true);
        addonsButton.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                getAddOnsDialog().setVisible(true);
            }
        });
    }
    return this.addonsButton;
}
Also used : ImageIcon(javax.swing.ImageIcon) ActionListener(java.awt.event.ActionListener) JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent)

Example 64 with JButton

use of javax.swing.JButton in project zaproxy by zaproxy.

the class PolicyManagerDialog method getExportButton.

private JButton getExportButton() {
    if (this.exportButton == null) {
        this.exportButton = new JButton(Constant.messages.getString("ascan.policymgr.button.export"));
        this.exportButton.setEnabled(false);
        this.exportButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                String name = (String) getParamsModel().getValueAt(getParamsTable().getSelectedRow(), 0);
                if (name != null) {
                    JFileChooser chooser = new JFileChooser(Constant.getPoliciesDir());
                    File file = new File(Constant.getZapHome(), name + PolicyManager.POLICY_EXTENSION);
                    chooser.setSelectedFile(file);
                    chooser.setFileFilter(new FileFilter() {

                        @Override
                        public boolean accept(File file) {
                            if (file.isDirectory()) {
                                return true;
                            } else if (file.isFile() && file.getName().endsWith(".policy")) {
                                return true;
                            }
                            return false;
                        }

                        @Override
                        public String getDescription() {
                            return Constant.messages.getString("file.format.zap.policy");
                        }
                    });
                    int rc = chooser.showSaveDialog(View.getSingleton().getMainFrame());
                    if (rc == JFileChooser.APPROVE_OPTION) {
                        file = chooser.getSelectedFile();
                        if (file == null) {
                            return;
                        }
                        try {
                            ScanPolicy policy = extension.getPolicyManager().getPolicy(name);
                            if (policy != null) {
                                extension.getPolicyManager().exportPolicy(policy, file);
                            }
                        } catch (ConfigurationException e1) {
                            logger.error(e1.getMessage(), e1);
                            View.getSingleton().showWarningDialog(Constant.messages.getString("ascan.policy.load.error"));
                        }
                    }
                }
            }
        });
    }
    return this.exportButton;
}
Also used : ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) ConfigurationException(org.apache.commons.configuration.ConfigurationException) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) FileFilter(javax.swing.filechooser.FileFilter) File(java.io.File)

Example 65 with JButton

use of javax.swing.JButton in project zaproxy by zaproxy.

the class PolicyManagerDialog method getRemoveButton.

private JButton getRemoveButton() {
    if (this.removeButton == null) {
        this.removeButton = new JButton(Constant.messages.getString("ascan.policymgr.button.remove"));
        this.removeButton.setEnabled(false);
        this.removeButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                String name = (String) getParamsModel().getValueAt(getParamsTable().getSelectedRow(), 0);
                if (name != null) {
                    if (View.getSingleton().showConfirmDialog(PolicyManagerDialog.this, Constant.messages.getString("ascan.policymgr.warn.delete")) == JOptionPane.OK_OPTION) {
                        extension.getPolicyManager().deletePolicy(name);
                        policyNamesChanged();
                    }
                }
            }
        });
    }
    return this.removeButton;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton)

Aggregations

JButton (javax.swing.JButton)923 JPanel (javax.swing.JPanel)408 ActionEvent (java.awt.event.ActionEvent)389 ActionListener (java.awt.event.ActionListener)317 JLabel (javax.swing.JLabel)278 JScrollPane (javax.swing.JScrollPane)166 BoxLayout (javax.swing.BoxLayout)158 FlowLayout (java.awt.FlowLayout)142 BorderLayout (java.awt.BorderLayout)138 Dimension (java.awt.Dimension)138 Insets (java.awt.Insets)114 JTextField (javax.swing.JTextField)114 GridBagLayout (java.awt.GridBagLayout)110 JCheckBox (javax.swing.JCheckBox)103 GridBagConstraints (java.awt.GridBagConstraints)95 ImageIcon (javax.swing.ImageIcon)95 JTable (javax.swing.JTable)67 JDialog (javax.swing.JDialog)65 JComboBox (javax.swing.JComboBox)56 JTextArea (javax.swing.JTextArea)56