@Override
public void actionPerformed(ActionEvent actionEvent) {
final SonarServerConfigurable dlg = showSonarServerConfigurableDialog();
if (dlg.isOK()) {
SonarServerConfig newSonarConfigurationBean = dlg.toSonarServerConfigurationBean();
try {
SonarServers.add(newSonarConfigurationBean);
mySonarServersComboBox.addItem(makeObj(newSonarConfigurationBean.getName()));
UIUtil.selectComboBoxItem(mySonarServersComboBox, newSonarConfigurationBean.getName());
} catch (IllegalArgumentException e) {
Messages.showErrorDialog(newSonarConfigurationBean.getName() + " already exists", "SonarQube Name Error");
showSonarServerConfigurableDialog(newSonarConfigurationBean);
}
}
}
});
myEditSonarServerButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
final Object selectedSonarServer = sonarServersComboBox.getSelectedItem();
final Optional<SonarServerConfig> oldBean = SonarServers.get(selectedSonarServer.toString());
if (!oldBean.isPresent()) {
Messages.showErrorDialog(selectedSonarServer.toString() + " is not more preset", "Cannot Perform Edit");
} else {
final SonarServerConfigurable dlg = showSonarServerConfigurableDialog(oldBean.get());
if (dlg.isOK()) {
SonarServerConfig newSonarConfigurationBean = dlg.toSonarServerConfigurationBean();
try {
SonarServers.remove(oldBean.get().getName());
SonarServers.add(newSonarConfigurationBean);
mySonarServersComboBox.removeItem(selectedSonarServer);
mySonarServersComboBox.addItem(makeObj(newSonarConfigurationBean.getName()));
UIUtil.selectComboBoxItem(mySonarServersComboBox, newSonarConfigurationBean.getName());
} catch (IllegalArgumentException e) {
Messages.showErrorDialog(selectedSonarServer.toString() + " cannot be saved\n\n" + Throwables.getStackTraceAsString(e), "Cannot Perform Edit");
}
}
}