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