Search in sources :

Example 56 with JButton

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

the class ManageAddOnsDialog method getCheckForUpdatesButton.

private JButton getCheckForUpdatesButton() {
    if (checkForUpdatesButton == null) {
        checkForUpdatesButton = new JButton();
        checkForUpdatesButton.setText(Constant.messages.getString("cfu.button.checkForUpdates"));
        checkForUpdatesButton.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                checkForUpdates();
            }
        });
    }
    return checkForUpdatesButton;
}
Also used : JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent)

Example 57 with JButton

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

the class ManageAddOnsDialog method getUpdateButton.

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

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                processUpdates(installedAddOnsModel.getSelectedUpdates());
            }
        });
    }
    return updateButton;
}
Also used : JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent)

Example 58 with JButton

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

the class ExtensionAutoUpdate method getOutOfDateButton.

private JButton getOutOfDateButton() {
    if (outOfDateButton == null) {
        outOfDateButton = new JButton(Constant.messages.getString("cfu.label.outofdateaddons"));
        outOfDateButton.setIcon(new ImageIcon(// Alert triangle
        ExtensionAutoUpdate.class.getResource("/resource/icon/16/050.png")));
        outOfDateButton.addActionListener(new ActionListener() {

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

Example 59 with JButton

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

the class ExtensionAutoUpdate method alertIfOutOfDate.

private void alertIfOutOfDate(boolean alwaysPrompt) {
    final OptionsParamCheckForUpdates options = getModel().getOptionsParam().getCheckForUpdatesParam();
    Date today = new Date();
    Date releaseCreated = Constant.getReleaseCreateDate();
    Date lastInstallWarning = options.getDayLastInstallWarned();
    int result = -1;
    logger.debug("Install created " + releaseCreated);
    if (releaseCreated != null) {
        // Should only be null for dev builds
        int daysOld = dayDiff(today, releaseCreated);
        logger.debug("Install is " + daysOld + " days old");
        if (daysOld > 365) {
            // Oh no, its more than a year old!
            boolean setCfuOnStart = false;
            if (alwaysPrompt || lastInstallWarning == null || dayDiff(today, lastInstallWarning) > 30) {
                JCheckBox cfuOnStart = new JCheckBox(Constant.messages.getString("cfu.label.cfuonstart"));
                cfuOnStart.setSelected(true);
                String msg = Constant.messages.getString("cfu.label.oldzap");
                result = View.getSingleton().showYesNoDialog(View.getSingleton().getMainFrame(), new Object[] { msg, cfuOnStart });
                setCfuOnStart = cfuOnStart.isSelected();
            }
            options.setDayLastInstallWarned();
            if (result == JOptionPane.OK_OPTION) {
                if (setCfuOnStart) {
                    options.setCheckOnStart(true);
                }
                getAddOnsDialog().setVisible(true);
                getAddOnsDialog().checkForUpdates();
            } else if (!oldZapAlertAdded) {
                JButton button = new JButton(Constant.messages.getString("cfu.label.outofdatezap"));
                button.setIcon(new ImageIcon(// Alert triangle
                ExtensionAutoUpdate.class.getResource("/resource/icon/16/050.png")));
                button.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        alertIfOutOfDate(true);
                    }
                });
                View.getSingleton().getMainFrame().getMainFooterPanel().addFooterToolbarLeftComponent(button);
                oldZapAlertAdded = true;
            }
            return;
        }
    }
    Date lastChecked = options.getDayLastChecked();
    Date lastUpdateWarning = options.getDayLastUpdateWarned();
    Date installDate = Constant.getInstallDate();
    if (installDate == null || dayDiff(today, installDate) < 90) {
    // Dont warn if installed in the last 3 months
    } else if (lastChecked == null || dayDiff(today, lastChecked) > 90) {
        // Not checked for updates in 3 months :(
        boolean setCfuOnStart = false;
        if (alwaysPrompt || lastUpdateWarning == null || dayDiff(today, lastUpdateWarning) > 30) {
            JCheckBox cfuOnStart = new JCheckBox(Constant.messages.getString("cfu.label.cfuonstart"));
            cfuOnStart.setSelected(true);
            String msg = Constant.messages.getString("cfu.label.norecentcfu");
            result = View.getSingleton().showYesNoDialog(View.getSingleton().getMainFrame(), new Object[] { msg, cfuOnStart });
            setCfuOnStart = cfuOnStart.isSelected();
        }
        options.setDayLastUpdateWarned();
        if (result == JOptionPane.OK_OPTION) {
            if (setCfuOnStart) {
                options.setCheckOnStart(true);
            }
            getAddOnsDialog().setVisible(true);
            getAddOnsDialog().checkForUpdates();
            if (noCfuAlertAdded) {
                View.getSingleton().getMainFrame().getMainFooterPanel().removeFooterToolbarLeftComponent(getOutOfDateButton());
            }
        } else if (!noCfuAlertAdded) {
            View.getSingleton().getMainFrame().getMainFooterPanel().addFooterToolbarLeftComponent(getOutOfDateButton());
            noCfuAlertAdded = true;
        }
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) ImageIcon(javax.swing.ImageIcon) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Date(java.util.Date)

Example 60 with JButton

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

the class ManageAddOnsDialog method getDownloadZapButton.

private JButton getDownloadZapButton() {
    if (downloadZapButton == null) {
        downloadZapButton = new JButton();
        if (Constant.isKali()) {
            getDownloadZapButton().setText(Constant.messages.getString("cfu.button.zap.options"));
        } else {
            downloadZapButton.setText(Constant.messages.getString("cfu.button.zap.download"));
        }
        downloadZapButton.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                if (extension.downloadLatestRelease()) {
                    setDownloadingZap();
                }
            }
        });
    }
    return downloadZapButton;
}
Also used : JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent)

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