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