Search in sources :

Example 16 with ConfirmCallback

use of org.eclipse.che.ide.api.dialogs.ConfirmCallback in project che by eclipse.

the class SshKeyManagerPresenterTest method testOnDeleteClickedWhenDeleteKeyIsFailure.

@Test
public void testOnDeleteClickedWhenDeleteKeyIsFailure() throws OperationException {
    when(sshPairDto.getService()).thenReturn(SshKeyManagerPresenter.VCS_SSH_SERVICE);
    when(sshPairDto.getName()).thenReturn(GITHUB_HOST);
    SafeHtml safeHtml = mock(SafeHtml.class);
    ConfirmDialog confirmDialog = mock(ConfirmDialog.class);
    when(constant.deleteSshKeyQuestion(anyString())).thenReturn(safeHtml);
    when(safeHtml.asString()).thenReturn("");
    when(dialogFactory.createConfirmDialog(anyString(), anyString(), (ConfirmCallback) anyObject(), (CancelCallback) anyObject())).thenReturn(confirmDialog);
    presenter.onDeleteClicked(sshPairDto);
    verify(dialogFactory).createConfirmDialog(anyString(), anyString(), confirmCallbackCaptor.capture(), (CancelCallback) anyObject());
    ConfirmCallback confirmCallback = confirmCallbackCaptor.getValue();
    confirmCallback.accepted();
    verify(voidPromise).catchError(operationErrorCapture.capture());
    operationErrorCapture.getValue().apply(JsPromiseError.create(""));
    verify(confirmDialog).show();
    verify(service).deletePair(Matchers.eq(SshKeyManagerPresenter.VCS_SSH_SERVICE), anyString());
    verify(notificationManager).notify(anyString(), eq(StatusNotification.Status.FAIL), eq(FLOAT_MODE));
    verify(service, never()).getPairs(Matchers.eq(SshKeyManagerPresenter.VCS_SSH_SERVICE));
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog) Test(org.junit.Test)

Example 17 with ConfirmCallback

use of org.eclipse.che.ide.api.dialogs.ConfirmCallback in project che by eclipse.

the class EditDebugConfigurationsPresenter method onConfigurationSelected.

@Override
public void onConfigurationSelected(final DebugConfiguration configuration) {
    if (!isViewModified()) {
        handleConfigurationSelection(configuration);
        return;
    }
    final ConfirmCallback saveCallback = new ConfirmCallback() {

        @Override
        public void accepted() {
            updateConfiguration(editedConfiguration);
            fetchConfigurations();
            handleConfigurationSelection(configuration);
        }
    };
    final ConfirmCallback discardCallback = new ConfirmCallback() {

        @Override
        public void accepted() {
            reset();
            fetchConfigurations();
            handleConfigurationSelection(configuration);
        }
    };
    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 18 with ConfirmCallback

use of org.eclipse.che.ide.api.dialogs.ConfirmCallback in project che by eclipse.

the class WsAgentStateController method checkStateOfWsAgent.

private void checkStateOfWsAgent(WsAgentHealthStateDto agentHealthStateDto) {
    final int statusCode = agentHealthStateDto.getCode();
    final String infoWindowTitle = "Workspace Agent Not Responding";
    final boolean reloadPage = true;
    final boolean createSnapshot = true;
    final ConfirmCallback stopCallback = new StopCallback(!reloadPage, createSnapshot);
    final ConfirmCallback stopAndReloadCallback = new StopCallback(reloadPage, !createSnapshot);
    if (statusCode == 200) {
        dialogFactory.createChoiceDialog(infoWindowTitle, "Workspace agent is no longer responding. To fix the problem, verify you have a" + " good network connection and restart the workspace.", "Restart", "Close", stopAndReloadCallback, stopCallback).show();
    } else {
        dialogFactory.createChoiceDialog(infoWindowTitle, "Workspace agent is no longer responding. To fix the problem, restart the workspace.", "Restart", "Close", stopAndReloadCallback, stopCallback).show();
    }
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback)

Example 19 with ConfirmCallback

use of org.eclipse.che.ide.api.dialogs.ConfirmCallback in project che by eclipse.

the class DeleteRepositoryAction method actionPerformed.

/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
    final Project project = appContext.getRootProject();
    checkState(project != null, "Null project occurred");
    dialogFactory.createConfirmDialog(constant.deleteGitRepositoryTitle(), constant.deleteGitRepositoryQuestion(project.getName()), new ConfirmCallback() {

        @Override
        public void accepted() {
            presenter.deleteRepository(project);
        }
    }, null).show();
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback)

Example 20 with ConfirmCallback

use of org.eclipse.che.ide.api.dialogs.ConfirmCallback in project che by eclipse.

the class MergePresenter method onMergeClicked.

/** {@inheritDoc} */
@Override
public void onMergeClicked() {
    view.close();
    final GitOutputConsole console = gitOutputConsoleFactory.create(MERGE_COMMAND_NAME);
    service.merge(appContext.getDevMachine(), project.getLocation(), selectedReference.getDisplayName()).then(new Operation<MergeResult>() {

        @Override
        public void apply(MergeResult result) throws OperationException {
            console.print(formMergeMessage(result));
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(formMergeMessage(result));
            project.synchronize();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            if (error.getCause() instanceof ServerException && ((ServerException) error.getCause()).getErrorCode() == ErrorCodes.NO_COMMITTER_NAME_OR_EMAIL_DEFINED) {
                dialogFactory.createMessageDialog(constant.mergeTitle(), constant.committerIdentityInfoEmpty(), new ConfirmCallback() {

                    @Override
                    public void accepted() {
                    //do nothing
                    }
                }).show();
                return;
            }
            console.printError(error.getMessage());
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(constant.mergeFailed(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) ServerException(org.eclipse.che.ide.commons.exception.ServerException) PromiseError(org.eclipse.che.api.promises.client.PromiseError) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) MergeResult(org.eclipse.che.api.git.shared.MergeResult) Operation(org.eclipse.che.api.promises.client.Operation) 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