use of org.eclipse.che.ide.api.dialogs.ConfirmCallback 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.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