Search in sources :

Example 6 with ConfirmDialog

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

the class RenamePresenterTest method warningDialogShouldBeDisplayedWhenRefactoringPerformsWithWarning.

@Test
public void warningDialogShouldBeDisplayedWhenRefactoringPerformsWithWarning() throws OperationException {
    renamePresenter.show(session);
    ConfirmDialog dialog = mock(ConfirmDialog.class);
    RefactoringStatusEntry statusEntry = mock(RefactoringStatusEntry.class);
    List<RefactoringStatusEntry> entries = Collections.singletonList(statusEntry);
    when(refactoringStatus.getEntries()).thenReturn(entries);
    when(refactoringStatus.getSeverity()).thenReturn(2);
    when(dialogFactory.createConfirmDialog(anyString(), anyString(), anyString(), anyString(), Matchers.<ConfirmCallback>anyObject(), Matchers.<CancelCallback>anyObject())).thenReturn(dialog);
    renamePresenter.onAcceptButtonClicked();
    verify(changeCreationResultPromise).then(changeCreationResultCaptor.capture());
    changeCreationResultCaptor.getValue().apply(changeCreationResult);
    verify(dialogFactory).createConfirmDialog(anyString(), anyString(), anyString(), anyString(), Matchers.<ConfirmCallback>anyObject(), Matchers.<CancelCallback>anyObject());
    verify(dialog).show();
}
Also used : RefactoringStatusEntry(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatusEntry) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog) Test(org.junit.Test)

Example 7 with ConfirmDialog

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

the class BranchPresenterTest method testOnRenameClickedWhenRemoteBranchSelectedAndUserConfirmRename.

@Test
public void testOnRenameClickedWhenRemoteBranchSelectedAndUserConfirmRename() throws Exception {
    reset(selectedBranch);
    when(service.branchRename(anyObject(), anyObject(), anyString(), anyString())).thenReturn(voidPromise);
    when(voidPromise.then(any(Operation.class))).thenReturn(voidPromise);
    when(voidPromise.catchError(any(Operation.class))).thenReturn(voidPromise);
    when(selectedBranch.getDisplayName()).thenReturn(REMOTE_BRANCH_NAME);
    when(selectedBranch.isRemote()).thenReturn(true);
    InputDialog inputDialog = mock(InputDialog.class);
    when(dialogFactory.createInputDialog(anyString(), anyString(), anyString(), anyInt(), anyInt(), anyObject(), anyObject())).thenReturn(inputDialog);
    ConfirmDialog confirmDialog = mock(ConfirmDialog.class);
    when(dialogFactory.createConfirmDialog(anyString(), anyString(), anyObject(), anyObject())).thenReturn(confirmDialog);
    selectBranch();
    presenter.onRenameClicked();
    verify(dialogFactory).createConfirmDialog(anyString(), anyString(), confirmCallbackCaptor.capture(), anyObject());
    ConfirmCallback confirmCallback = confirmCallbackCaptor.getValue();
    confirmCallback.accepted();
    verify(dialogFactory).createInputDialog(anyString(), anyString(), anyString(), anyInt(), anyInt(), inputCallbackCaptor.capture(), anyObject());
    InputCallback inputCallback = inputCallbackCaptor.getValue();
    inputCallback.accepted(RETURNED_MESSAGE);
    verify(voidPromise).then(voidPromiseCaptor.capture());
    voidPromiseCaptor.getValue().apply(null);
    verify(selectedBranch, times(2)).getDisplayName();
    verify(service, times(2)).branchList(anyObject(), anyObject(), eq(LIST_ALL));
    verify(console, never()).printError(anyString());
    verify(notificationManager, never()).notify(anyString());
    verify(constant, never()).branchRenameFailed();
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) InputDialog(org.eclipse.che.ide.api.dialogs.InputDialog) InputCallback(org.eclipse.che.ide.api.dialogs.InputCallback) Operation(org.eclipse.che.api.promises.client.Operation) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Example 8 with ConfirmDialog

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

the class RevertPresenter method show.

public void show() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    ConfirmDialog confirmDialog = createConfirmDialog(project, resources);
    confirmDialog.show();
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Resource(org.eclipse.che.ide.api.resources.Resource) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog)

Example 9 with ConfirmDialog

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

the class EditCommandsPresenter method onRemoveClicked.

@Override
public void onRemoveClicked() {
    final CommandImpl selectedCommand = view.getSelectedCommand();
    if (selectedCommand == null) {
        return;
    }
    final ConfirmCallback confirmCallback = new ConfirmCallback() {

        @Override
        public void accepted() {
            commandManager.remove(selectedCommand.getName()).then(new Operation<Void>() {

                @Override
                public void apply(Void arg) throws OperationException {
                    view.selectNeighborCommand(selectedCommand);
                    commandProcessingCallback = getCommandProcessingCallback();
                    refreshView();
                }
            }).catchError(new Operation<PromiseError>() {

                @Override
                public void apply(PromiseError arg) throws OperationException {
                    dialogFactory.createMessageDialog("Error", arg.getMessage(), null).show();
                }
            });
        }
    };
    ConfirmDialog confirmDialog = dialogFactory.createConfirmDialog(machineLocale.editCommandsViewRemoveTitle(), machineLocale.editCommandsRemoveConfirmation(selectedCommand.getName()), confirmCallback, null);
    confirmDialog.show();
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException) ConfirmDialog(org.eclipse.che.ide.api.dialogs.ConfirmDialog)

Example 10 with ConfirmDialog

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

the class SshKeyManagerPresenterTest method testOnDeleteClickedWhenDeleteKeyIsSuccess.

@Test
public void testOnDeleteClickedWhenDeleteKeyIsSuccess() 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).then(operationVoidCapture.capture());
    operationVoidCapture.getValue().apply(null);
    verify(confirmDialog).show();
    verify(service).deletePair(Matchers.eq(SshKeyManagerPresenter.VCS_SSH_SERVICE), eq(GITHUB_HOST));
    verify(service).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)

Aggregations

ConfirmDialog (org.eclipse.che.ide.api.dialogs.ConfirmDialog)14 Test (org.junit.Test)11 ConfirmCallback (org.eclipse.che.ide.api.dialogs.ConfirmCallback)8 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)6 ArrayList (java.util.ArrayList)2 Operation (org.eclipse.che.api.promises.client.Operation)2 SshPairDto (org.eclipse.che.api.ssh.shared.dto.SshPairDto)2 OperationException (org.eclipse.che.api.promises.client.OperationException)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 CommandImpl (org.eclipse.che.ide.api.command.CommandImpl)1 CancelCallback (org.eclipse.che.ide.api.dialogs.CancelCallback)1 InputCallback (org.eclipse.che.ide.api.dialogs.InputCallback)1 InputDialog (org.eclipse.che.ide.api.dialogs.InputDialog)1 Project (org.eclipse.che.ide.api.resources.Project)1 Resource (org.eclipse.che.ide.api.resources.Resource)1 BaseTest (org.eclipse.che.ide.ext.git.client.BaseTest)1 RefactoringStatusEntry (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatusEntry)1 ProcessTreeNode (org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)1