use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class ShowLogPresenter method showLog.
/**
* Fetches the count of revisions and opens the popup.
*/
public void showLog() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
checkState(resources.length == 1);
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<InfoResponse>() {
@Override
public Promise<InfoResponse> perform(Credentials credentials) {
return service.info(project.getLocation(), toRelative(project, resources[0]).toString(), "HEAD", false, credentials);
}
}, null).then(new Operation<InfoResponse>() {
@Override
public void apply(InfoResponse response) throws OperationException {
if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) {
printErrors(response.getErrorOutput(), constants.commandInfo());
notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
return;
}
SubversionItem subversionItem = response.getItems().get(0);
view.setRevisionCount(subversionItem.getRevision());
view.rangeField().setValue("1:" + subversionItem.getRevision());
view.show();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class PropertyEditorPresenter method onPropertyNameChanged.
@Override
public void onPropertyNameChanged(String propertyName) {
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
checkState(resources.length == 1);
service.propertyGet(project.getLocation(), propertyName, toRelative(project, resources[0])).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
view.setPropertyCurrentValue(response.getOutput());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class PropertyEditorPresenter method deleteProperty.
private void deleteProperty(Project project) {
final String propertyName = view.getSelectedProperty();
final Depth depth = view.getDepth();
final boolean force = view.isForceSelected();
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
checkState(resources.length == 1);
final StatusNotification notification = new StatusNotification(constants.propertyRemoveStart(), PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
service.propertyDelete(project.getLocation(), propertyName, depth, force, toRelative(project, resources[0])).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandProperty());
notification.setTitle(constants.propertyRemoveFinished());
notification.setStatus(SUCCESS);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notification.setTitle(constants.propertyRemoveFailed());
notification.setStatus(FAIL);
}
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class PropertyEditorPresenter method editProperty.
private void editProperty(Project project) {
final String propertyName = view.getSelectedProperty();
final Depth depth = view.getDepth();
final String propertyValue = view.getPropertyValue();
final boolean force = view.isForceSelected();
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
checkState(resources.length == 1);
final StatusNotification notification = new StatusNotification(constants.propertyModifyStart(), PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
service.propertySet(project.getLocation(), propertyName, propertyValue, depth, force, toRelative(project, resources[0])).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandProperty());
notification.setTitle(constants.propertyModifyFinished());
notification.setStatus(SUCCESS);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notification.setTitle(constants.propertyModifyFailed());
notification.setStatus(FAIL);
}
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class TestServiceClientTest method cancelledTestsBecauseCompilationNotStarted.
@Test
public void cancelledTestsBecauseCompilationNotStarted() {
Promise<CommandImpl> compileCommandPromise = createCommandPromise(new CommandImpl("test-compile", "mvn test-compile -f ${current.project.path}", "mvn"));
when(devMachine.getDescriptor()).thenReturn(machine);
Promise<TestResult> result = testServiceClient.runTestsAfterCompilation(projectPath, testFramework, parameters, statusNotification, compileCommandPromise);
triggerProcessEvents(processStartResponse(false));
verify(testServiceClient, never()).sendTests(anyString(), anyString(), anyMapOf(String.class, String.class));
verify(statusNotification).setContent("Compiling the project before starting the test session.");
result.catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError promiseError) throws OperationException {
Throwable cause = promiseError.getCause();
Assert.assertNotNull(cause);
Assert.assertEquals(TestServiceClient.PROJECT_BUILD_NOT_STARTED_MESSAGE, cause.getMessage());
}
});
}
Aggregations