protected void addButtonsToButtonGroup(Composite parent) {
Button b = createPushButton2(parent, "Add");
b.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
MavenCommand command = new MavenCommand();
command.setId("" + maxCommandId);
MavenCommandDialog dialog = new MavenCommandDialog(new Shell(),
command);
dialog.create();
int result = dialog.open();
if (result == 0) {
commands.put(command.getId(), command);
nodeStore.put(PreferencesConstants.MAVEN_COMMAND_ALIAS
+ "." + maxCommandId, command.getAliasValue());
nodeStore.put(PreferencesConstants.MAVEN_COMMANDLINE + "."
+ maxCommandId, command.getCommandLine());
TableItem item = new TableItem(commandstable, SWT.LEFT);
item.setText(command.getAliasValue());
item.setData("id", command.getId());
item.setData("indexInTable", tableItems.size());
tableItems.put(command.getId(), item);
maxCommandId++;
}
}
});
b = createPushButton2(parent, "Edit");
b.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (selectedCommandsId.size() == 1) {
String id = selectedCommandsId.iterator().next();
MavenCommand command = commands.get(id);
MavenCommandDialog dialog = new MavenCommandDialog(
new Shell(), command);
dialog.create();
int result = dialog.open();
if (result == 0) {
;
commands.put(PreferencesConstants.MAVEN_COMMAND_ALIAS
+ "." + id, command);
nodeStore.put(PreferencesConstants.MAVEN_COMMAND_ALIAS
+ "." + id, command.getAliasValue());
nodeStore.put(PreferencesConstants.MAVEN_COMMANDLINE
+ "." + id, command.getCommandLine());
tableItems.get(id).setText(command.getAliasValue());
selectedCommandsId.clear();
maxCommandId++;
}
}
}