use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class CreateWorkspacePresenter method show.
/**
* Shows special dialog window which allows set up workspace which will be created.
*
* @param workspaces
* list of existing workspaces
*/
public void show(List<WorkspaceDto> workspaces, final Callback<Component, Exception> callback) {
this.callback = callback;
workspacesNames.clear();
for (WorkspaceDto workspace : workspaces) {
workspacesNames.add(workspace.getConfig().getName());
}
Promise<List<RecipeDescriptor>> recipes = recipeService.getAllRecipes();
recipes.then(new Operation<List<RecipeDescriptor>>() {
@Override
public void apply(List<RecipeDescriptor> recipeDescriptors) throws OperationException {
CreateWorkspacePresenter.this.recipes = recipeDescriptors;
}
});
String workspaceName = browserAddress.getWorkspaceName();
view.setWorkspaceName(workspaceName);
validateCreateWorkspaceForm();
view.show();
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class CreateWorkspacePresenter method createWorkspace.
private void createWorkspace() {
WorkspaceConfigDto workspaceConfig = getWorkspaceConfig();
workspaceClient.create(workspaceConfig, null).then(new Operation<WorkspaceDto>() {
@Override
public void apply(WorkspaceDto workspace) throws OperationException {
DefaultWorkspaceComponent component = wsComponentProvider.get();
component.startWorkspace(workspace, callback);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
callback.onFailure(new Exception(arg.getCause()));
}
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class RenamePresenter method showPreview.
private void showPreview() {
RefactoringSession session = dtoFactory.createDto(RefactoringSession.class);
session.setSessionId(renameRefactoringSession.getSessionId());
prepareRenameChanges(session).then(new Operation<ChangeCreationResult>() {
@Override
public void apply(ChangeCreationResult arg) throws OperationException {
if (arg.isCanShowPreviewPage() || arg.getStatus().getSeverity() <= 3) {
previewPresenter.show(renameRefactoringSession.getSessionId(), refactorInfo);
previewPresenter.setTitle(locale.renameItemTitle());
view.hide();
} else {
view.showErrorMessage(arg.getStatus());
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
notificationManager.notify(locale.failedToRename(), arg.getMessage(), FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class FindUsagesPresenter method findUsages.
public void findUsages(TextEditor activeEditor) {
final VirtualFile virtualFile = activeEditor.getEditorInput().getFile();
if (virtualFile instanceof Resource) {
final Project project = ((Resource) virtualFile).getRelatedProject().get();
if (project == null) {
return;
}
final Optional<Resource> srcFolder = ((Resource) virtualFile).getParentWithMarker(SourceFolderMarker.ID);
if (!srcFolder.isPresent()) {
return;
}
final String fqn = JavaUtil.resolveFQN((Container) srcFolder.get(), (Resource) virtualFile);
String projectPath = project.getLocation().toString();
FindUsagesRequest request = dtoFactory.createDto(FindUsagesRequest.class);
request.setFQN(fqn);
request.setProjectPath(projectPath);
request.setOffset(activeEditor.getCursorOffset());
Promise<FindUsagesResponse> promise = searchService.findUsages(request);
promise.then(new Operation<FindUsagesResponse>() {
@Override
public void apply(FindUsagesResponse arg) throws OperationException {
handleResponse(arg);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
Throwable cause = arg.getCause();
if (cause instanceof ServerException) {
handleError(((ServerException) cause).getHTTPStatus(), cause.getMessage());
return;
}
//in case websocket request
if (cause instanceof org.eclipse.che.ide.websocket.rest.exceptions.ServerException) {
handleError(((org.eclipse.che.ide.websocket.rest.exceptions.ServerException) cause).getHTTPStatus(), cause.getMessage());
return;
}
Log.error(getClass(), arg);
manager.notify(localizationConstant.failedToProcessFindUsage(), arg.getMessage(), FAIL, FLOAT_MODE);
}
});
}
}
use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.
the class ParametersHintsPresenter method show.
/**
* The method gets method parameters via {@link JavaNavigationService} and then call special method on view to display them.
*
* @param activeEditor
* active editor which contains method or constructor for which parameters will be displayed
*/
public void show(final TextEditor activeEditor) {
final int offset = activeEditor.getCursorOffset();
if (!isCursorInRightPlace(activeEditor, offset)) {
return;
}
VirtualFile file = activeEditor.getEditorInput().getFile();
if (file instanceof Resource) {
final Optional<Project> project = ((Resource) file).getRelatedProject();
final int lineStartOffset = getLineStartOffset(activeEditor, offset);
navigationService.getMethodParametersHints(project.get().getLocation(), JavaUtil.resolveFQN(file), offset, lineStartOffset).then(new Operation<List<MethodParameters>>() {
@Override
public void apply(List<MethodParameters> parameters) throws OperationException {
if (parameters.isEmpty()) {
return;
}
PositionConverter.PixelCoordinates coordinates = activeEditor.getPositionConverter().offsetToPixel(offset);
view.show(parameters, coordinates.getX(), coordinates.getY());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
Log.error(getClass(), error.getMessage());
}
});
}
}
Aggregations