use of java.awt.event.ActionEvent 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 java.awt.event.ActionEvent 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 java.awt.event.ActionEvent in project freeline by alibaba.
the class UpdateAction method resultHandle.
/**
* 处理结果
*
* @param entity
* @param gradleBuildModels
*/
private void resultHandle(final GradleDependencyEntity entity, final Map<GradleBuildModel, List<ArtifactDependencyModel>> gradleBuildModels) {
String localVersion = null;
StringBuilder builder = new StringBuilder();
for (GradleBuildModel file : gradleBuildModels.keySet()) {
List<ArtifactDependencyModel> models = gradleBuildModels.get(file);
for (ArtifactDependencyModel dependencyModel1 : models) {
ArtifactDependencyModelWrapper dependencyModel = new ArtifactDependencyModelWrapper(dependencyModel1);
if (isClasspathLibrary(dependencyModel) || isDependencyLibrary(dependencyModel)) {
if (isClasspathLibrary(dependencyModel)) {
localVersion = dependencyModel.version();
}
builder.append(dependencyModel.configurationName()).append(" '").append(dependencyModel.group()).append(":").append(dependencyModel.name()).append(":").append(dependencyModel.version()).append("'").append("<br/>");
}
}
}
if (Utils.notEmpty(localVersion)) {
int compare = localVersion.compareTo(entity.getVersion());
final CheckUpdateDialog dialog = new CheckUpdateDialog();
dialog.getButtonOK().setEnabled(compare < 0);
dialog.setServerVersion(entity.getGroupId(), entity.getArtifactId(), entity.getVersion());
dialog.setServerUpdateTime(entity.getUpdateTime());
dialog.setLocalVersion(builder.toString());
dialog.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateAction(entity.getVersion(), gradleBuildModels);
dialog.dispose();
}
});
dialog.showDialog();
} else {
NotificationUtils.infoNotification("please add freeline dependency first");
}
}
use of java.awt.event.ActionEvent in project freeline by alibaba.
the class UsingReportAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent event) {
final Project project = event.getProject();
Module[] modules = ModuleManager.getInstance(project).getModules();
List<Pair<Module, PsiFile>> selectModulesList = new ArrayList<Pair<Module, PsiFile>>();
for (Module module : modules) {
GradleBuildFile file = GradleBuildFile.get(module);
if (file != null && !GradleUtil.isLibrary(file)) {
selectModulesList.add(Pair.create(module, file.getPsiFile()));
}
}
if (selectModulesList.size() > 1) {
final DialogBuilder builder = new DialogBuilder();
builder.setTitle("Freeline Reporter");
builder.resizable(false);
builder.setCenterPanel(new JLabel("There are multiple application modules, Please select the exact one.", Messages.getInformationIcon(), SwingConstants.CENTER));
builder.addOkAction().setText("Cancel");
for (final Pair<Module, PsiFile> pair : selectModulesList) {
builder.addAction(new AbstractAction(":" + pair.first.getName()) {
@Override
public void actionPerformed(ActionEvent e) {
builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
report(project, pair.getSecond());
}
});
}
if (builder.show() > -1) {
//return false;
}
} else if (selectModulesList.size() == 1) {
report(project, selectModulesList.get(0).getSecond());
}
}
use of java.awt.event.ActionEvent in project processing by processing.
the class Base method populateToolsMenu.
public void populateToolsMenu(JMenu toolsMenu) {
// If this is the first run, need to build out the lists
if (internalTools == null) {
rebuildToolList();
}
// coreTools = ToolContribution.loadAll(Base.getToolsFolder());
// contribTools = ToolContribution.loadAll(Base.getSketchbookToolsFolder());
// Collections.sort(coreTools);
// Collections.sort(contribTools);
// Collections.sort(coreTools, new Comparator<ToolContribution>() {
// @Override
// public int compare(ToolContribution o1, ToolContribution o2) {
// return o1.getMenuTitle().compareTo(o2.getMenuTitle());
// }
// });
toolsMenu.removeAll();
for (Tool tool : internalTools) {
toolsMenu.add(createToolItem(tool));
}
toolsMenu.addSeparator();
if (coreTools.size() > 0) {
for (Tool tool : coreTools) {
toolsMenu.add(createToolItem(tool));
}
toolsMenu.addSeparator();
}
if (contribTools.size() > 0) {
for (Tool tool : contribTools) {
toolsMenu.add(createToolItem(tool));
}
toolsMenu.addSeparator();
}
JMenuItem item = new JMenuItem(Language.text("menu.tools.add_tool"));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ContributionManager.openTools();
}
});
toolsMenu.add(item);
}
Aggregations