myAddLocalAnalysisScriptButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final LocalAnalysisScriptConfigurable dlg = showLocalAnalysisScriptConfigurableDialog();
if (dlg.isOK()) {
final LocalAnalysisScript newLocalAnalysisScript = dlg.toLocalAnalysisScript();
try {
LocalAnalysisScripts.add(newLocalAnalysisScript);
myLocalAnalysisScriptComboBox.addItem(makeObj(newLocalAnalysisScript.getName()));
UIUtil.selectComboBoxItem(myLocalAnalysisScriptComboBox, newLocalAnalysisScript.getName());
} catch (IllegalArgumentException ex) {
Messages.showErrorDialog(newLocalAnalysisScript.getName() + " already exists", "Local Analysis Script Name Error");
showLocalAnalysisScriptConfigurableDialog(newLocalAnalysisScript);
}
}
}
});
myEditLocalAnalysisScriptButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
final Object selected = myLocalAnalysisScriptComboBox.getSelectedItem();
final Optional<LocalAnalysisScript> previous = LocalAnalysisScripts.get(selected.toString());
if (!previous.isPresent()) {
Messages.showErrorDialog(selected.toString() + " is not more preset", "Cannot Perform Edit");
} else {
final LocalAnalysisScriptConfigurable dlg = showLocalAnalysisScriptConfigurableDialog(previous.get());
if (dlg.isOK()) {
LocalAnalysisScript next = dlg.toLocalAnalysisScript();
try {
LocalAnalysisScripts.remove(previous.get().getName());
LocalAnalysisScripts.add(next);
myLocalAnalysisScriptComboBox.removeItem(selected);
myLocalAnalysisScriptComboBox.addItem(makeObj(next.getName()));
UIUtil.selectComboBoxItem(myLocalAnalysisScriptComboBox, next.getName());
} catch (IllegalArgumentException e) {
Messages.showErrorDialog(selected.toString() + " cannot be saved\n\n" + Throwables.getStackTraceAsString(e), "Cannot Perform Edit");
}
}
}