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();
}
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();
}
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();
}
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();
}
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));
}
Aggregations