use of org.eclipse.che.ide.api.dialogs.ConfirmCallback in project che by eclipse.
the class EditDebugConfigurationsPresenter method onRemoveClicked.
@Override
public void onRemoveClicked(final DebugConfiguration selectedConfiguration) {
if (selectedConfiguration == null) {
return;
}
final ConfirmCallback confirmCallback = new ConfirmCallback() {
@Override
public void accepted() {
debugConfigurationsManager.removeConfiguration(selectedConfiguration);
view.selectNextItem();
fetchConfigurations();
}
};
final ConfirmDialog confirmDialog = dialogFactory.createConfirmDialog(locale.editConfigurationsViewRemoveTitle(), locale.editConfigurationsRemoveConfirmation(selectedConfiguration.getName()), confirmCallback, null);
confirmDialog.show();
}
use of org.eclipse.che.ide.api.dialogs.ConfirmCallback in project che by eclipse.
the class EditDebugConfigurationsPresenter method createNewConfiguration.
private void createNewConfiguration(final DebugConfigurationType type, final String customName, final Map<String, String> attributes) {
if (!isViewModified()) {
reset();
createConfiguration(type, customName, attributes);
return;
}
final ConfirmCallback saveCallback = new ConfirmCallback() {
@Override
public void accepted() {
updateConfiguration(editedConfiguration);
reset();
createConfiguration(type, customName, attributes);
}
};
final ConfirmCallback discardCallback = new ConfirmCallback() {
@Override
public void accepted() {
fetchConfigurations();
reset();
createConfiguration(type, customName, attributes);
}
};
final ChoiceDialog dialog = dialogFactory.createChoiceDialog(locale.editConfigurationsSaveChangesTitle(), locale.editConfigurationsSaveChangesConfirmation(editedConfiguration.getName()), coreLocale.save(), locale.editConfigurationsSaveChangesDiscard(), saveCallback, discardCallback);
dialog.show();
}
use of org.eclipse.che.ide.api.dialogs.ConfirmCallback in project che by eclipse.
the class EditCommandsPresenter method createNewCommand.
private void createNewCommand(final String type, final String commandLine, final String name, final Map<String, String> attributes) {
if (!isViewModified()) {
createCommand(type, commandLine, name, attributes);
return;
}
final ConfirmCallback saveCallback = new ConfirmCallback() {
@Override
public void accepted() {
updateCommand(editedCommand).then(new Operation<CommandImpl>() {
@Override
public void apply(CommandImpl arg) throws OperationException {
createCommand(type, commandLine, name, attributes);
}
});
}
};
final ConfirmCallback discardCallback = new ConfirmCallback() {
@Override
public void accepted() {
refreshView();
createCommand(type, commandLine, name, attributes);
}
};
ChoiceDialog dialog = dialogFactory.createChoiceDialog(machineLocale.editCommandsSaveChangesTitle(), machineLocale.editCommandsSaveChangesConfirmation(editedCommand.getName()), coreLocale.save(), machineLocale.editCommandsSaveChangesDiscard(), saveCallback, discardCallback);
dialog.show();
}
use of org.eclipse.che.ide.api.dialogs.ConfirmCallback in project che by eclipse.
the class RevertPresenter method createConfirmDialog.
private ConfirmDialog createConfirmDialog(final Project project, final Resource[] resources) {
final ConfirmCallback okCallback = new ConfirmCallback() {
@Override
public void accepted() {
final StatusNotification notification = new StatusNotification(constants.revertStarted(), PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
service.revert(project.getLocation(), toRelative(project, resources), "infinity").then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
List<String> errOutput = response.getErrOutput();
printResponse(response.getCommand(), response.getOutput(), errOutput, "svn revert");
if (errOutput == null || errOutput.size() == 0) {
notification.setTitle(constants.revertSuccessful());
notification.setStatus(SUCCESS);
} else {
notification.setTitle(constants.revertWarning());
notification.setStatus(SUCCESS);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notification.setTitle(constants.revertFailed());
notification.setStatus(FAIL);
}
});
}
};
final CancelCallback cancelCallback = new CancelCallback() {
@Override
public void cancelled() {
}
};
String pathsString = null;
for (Resource resource : resources) {
if (pathsString == null) {
pathsString = resource.getLocation().toString();
} else {
pathsString += ", " + resource.getLocation().toString();
}
}
String confirmText = resources.length > 0 ? constants.revertConfirmText(" to " + pathsString) : constants.revertConfirmText("");
return dialogFactory.createConfirmDialog(constants.revertTitle(), confirmText, okCallback, cancelCallback);
}
use of org.eclipse.che.ide.api.dialogs.ConfirmCallback in project che by eclipse.
the class DeleteResourceManager method onConfirm.
private ConfirmCallback onConfirm(final Resource[] resources, final AsyncCallback<Void> callback) {
return new ConfirmCallback() {
@Override
public void accepted() {
if (resources == null) {
//sometimes we may occur NPE here while reading length
callback.onFailure(new IllegalStateException());
return;
}
Promise<?>[] deleteAll = new Promise<?>[resources.length];
for (int i = 0; i < resources.length; i++) {
final Resource resource = resources[i];
deleteAll[i] = resource.delete().catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify("Failed to delete '" + resource.getName() + "'", error.getMessage(), FAIL, StatusNotification.DisplayMode.FLOAT_MODE);
}
});
}
promiseProvider.all(deleteAll).then(new Operation<JsArrayMixed>() {
@Override
public void apply(JsArrayMixed arg) throws OperationException {
callback.onSuccess(null);
}
});
}
};
}
Aggregations