Search in sources :

Example 1 with ConfirmCallback

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();
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog)

Example 2 with ConfirmCallback

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();
}
Also used : ChoiceDialog(org.eclipse.che.ide.api.dialogs.ChoiceDialog) ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback)

Example 3 with ConfirmCallback

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();
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) ChoiceDialog(org.eclipse.che.ide.api.dialogs.ChoiceDialog) ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 4 with ConfirmCallback

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);
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) PromiseError(org.eclipse.che.api.promises.client.PromiseError) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Resource(org.eclipse.che.ide.api.resources.Resource) CancelCallback(org.eclipse.che.ide.api.dialogs.CancelCallback) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 5 with ConfirmCallback

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);
                }
            });
        }
    };
}
Also used : Promise(org.eclipse.che.api.promises.client.Promise) ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) JsPromiseError(org.eclipse.che.api.promises.client.js.JsPromiseError) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) JsArrayMixed(com.google.gwt.core.client.JsArrayMixed) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

ConfirmCallback (org.eclipse.che.ide.api.dialogs.ConfirmCallback)23 OperationException (org.eclipse.che.api.promises.client.OperationException)9 ConfirmDialog (org.eclipse.che.ide.api.dialogs.ConfirmDialog)8 Operation (org.eclipse.che.api.promises.client.Operation)7 PromiseError (org.eclipse.che.api.promises.client.PromiseError)6 Test (org.junit.Test)6 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)5 Resource (org.eclipse.che.ide.api.resources.Resource)5 CancelCallback (org.eclipse.che.ide.api.dialogs.CancelCallback)4 ChoiceDialog (org.eclipse.che.ide.api.dialogs.ChoiceDialog)4 Promise (org.eclipse.che.api.promises.client.Promise)3 CommandImpl (org.eclipse.che.ide.api.command.CommandImpl)3 InputCallback (org.eclipse.che.ide.api.dialogs.InputCallback)3 Project (org.eclipse.che.ide.api.resources.Project)3 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 ArrayList (java.util.ArrayList)2 Function (org.eclipse.che.api.promises.client.Function)2 FunctionException (org.eclipse.che.api.promises.client.FunctionException)2 RequestCall (org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.RequestCall)2 SshPairDto (org.eclipse.che.api.ssh.shared.dto.SshPairDto)2