use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class DebuggerTest method testGetValue.
@Test
public void testGetValue() throws Exception {
final VariableDto variableDto = mock(VariableDto.class);
final Variable variable = mock(Variable.class);
final Promise<SimpleValueDto> promiseValue = mock(Promise.class);
doReturn(variableDto).when(dtoFactory).createDto(VariableDto.class);
doReturn(mock(VariablePathDto.class)).when(dtoFactory).createDto(VariablePathDto.class);
doReturn(mock(VariablePathDto.class)).when(variable).getVariablePath();
doReturn(Collections.emptyList()).when(variable).getVariables();
doReturn(promiseValue).when(service).getValue(SESSION_ID, variableDto);
doReturn(promiseValue).when(promiseValue).then((Function<SimpleValueDto, Object>) any());
doReturn(promiseValue).when(promiseValue).catchError((Operation<PromiseError>) any());
Promise<SimpleValue> result = debugger.getValue(variable);
assertEquals(promiseValue, result);
}
use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class EvaluateExpressionPresenter method onEvaluateClicked.
/** {@inheritDoc} */
@Override
public void onEvaluateClicked() {
Debugger debugger = debuggerManager.getActiveDebugger();
if (debugger != null) {
view.setEnableEvaluateButton(false);
debugger.evaluate(view.getExpression()).then(new Operation<String>() {
@Override
public void apply(String result) throws OperationException {
view.setResult(result);
view.setEnableEvaluateButton(true);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
view.setResult(constant.evaluateExpressionFailed(error.getMessage()));
view.setEnableEvaluateButton(true);
}
});
}
}
use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class MovePresenter method show.
/**
* Show Move panel with the special information.
*
* @param refactorInfo
* information about the move operation
*/
public void show(final RefactorInfo refactorInfo) {
this.refactorInfo = refactorInfo;
view.setEnablePreviewButton(false);
view.setEnableAcceptButton(false);
view.clearErrorLabel();
CreateMoveRefactoring moveRefactoring = createMoveDto();
Promise<String> sessionIdPromise = refactorService.createMoveRefactoring(moveRefactoring);
sessionIdPromise.then(new Operation<String>() {
@Override
public void apply(String sessionId) throws OperationException {
MovePresenter.this.refactoringSessionId = sessionId;
showProjectsAndPackages();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), Status.FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class MovePresenter method onPreviewButtonClicked.
/** {@inheritDoc} */
@Override
public void onPreviewButtonClicked() {
RefactoringSession session = dtoFactory.createDto(RefactoringSession.class);
session.setSessionId(refactoringSessionId);
prepareMovingChanges(session).then(new Operation<ChangeCreationResult>() {
@Override
public void apply(ChangeCreationResult arg) throws OperationException {
if (arg.isCanShowPreviewPage()) {
previewPresenter.show(refactoringSessionId, refactorInfo);
view.hide();
} else {
view.showStatusMessage(arg.getStatus());
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(locale.showPreviewError(), error.getMessage(), Status.FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.
the class MovePresenter method showProjectsAndPackages.
private void showProjectsAndPackages() {
Promise<List<JavaProject>> projectsPromise = navigationService.getProjectsAndPackages(true);
projectsPromise.then(new Operation<List<JavaProject>>() {
@Override
public void apply(List<JavaProject> projects) throws OperationException {
List<JavaProject> currentProject = new ArrayList<>();
for (JavaProject project : projects) {
currentProject.add(project);
}
view.setTreeOfDestinations(currentProject);
view.show(refactorInfo);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(locale.showPackagesError(), error.getMessage(), Status.FAIL, FLOAT_MODE);
}
});
}
Aggregations