.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
stopEditing();
ServerConfiguration serverConfiguration = ServerConfiguration.byDefault();
ConfigurationDialog dialog = new ConfigurationDialog(mainPanel, mongoManager, serverConfiguration);
dialog.setTitle("Add a Mongo Server");
dialog.show();
if (!dialog.isOK()) {
return;
}
configurations.add(serverConfiguration);
int index = configurations.size() - 1;
tableModel.fireTableRowsInserted(index, index);
table.getSelectionModel().setSelectionInterval(index, index);
table.scrollRectToVisible(table.getCellRect(index, 0, true));
}
})
.setAddActionName("addServer")
.setEditAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
stopEditing();
int selectedIndex = table.getSelectedRow();
if (selectedIndex < 0 || selectedIndex >= tableModel.getRowCount()) {
return;
}
ServerConfiguration sourceConfiguration = configurations.get(selectedIndex);
ServerConfiguration copiedCconfiguration = sourceConfiguration.clone();
ConfigurationDialog dialog = new ConfigurationDialog(mainPanel, mongoManager, copiedCconfiguration);
dialog.setTitle("Edit a Mongo Server");
dialog.show();