*/
protected void addOrEditCommand(boolean add) {
ServerService service = getSelectedService();
if (service != null) {
ServiceCommand serviceCommandToEdit = !add ? getSelectedCommand() : null;
ServiceCommandWizard wizard = new ServiceCommandWizard(serviceCommands, service, serviceCommandToEdit);
Shell shell = getShell();
if (shell != null) {
WizardDialog dialog = new WizardDialog(shell, wizard);
if (dialog.open() == Window.OK) {
ServiceCommand editedCommand = wizard.getEditedServiceCommand();
if (editedCommand != null) {
// Add the new one
boolean added = new ServiceCommandManager(serviceCommands).addCommand(service.getServiceInfo(),
editedCommand);
if (!added) {
notifyStatusChange(CloudFoundryPlugin.getErrorStatus(Messages.ServiceTunnelCommandPart_ERROR_FAIL_TO_ADD
+ editedCommand.getDisplayName()));
return;
}
else {
// Delete the old command
if (serviceCommandToEdit != null) {
deleteCommand(serviceCommandToEdit);
}
CommandTerminal updatedTerminal = wizard.applyTerminalToAllCommands() ? editedCommand
.getCommandTerminal() : null;
setServiceCommandInput(service, editedCommand);
applyTerminalToAllCommands(updatedTerminal);
}