Search in sources :

Example 1 with OperationException

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();
}
Also used : WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) RecipeDescriptor(org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 2 with OperationException

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()));
        }
    });
}
Also used : DefaultWorkspaceComponent(org.eclipse.che.ide.workspace.DefaultWorkspaceComponent) PromiseError(org.eclipse.che.api.promises.client.PromiseError) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 3 with OperationException

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);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) RefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringSession) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) ChangeCreationResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeCreationResult) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 4 with OperationException

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);
            }
        });
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) FindUsagesResponse(org.eclipse.che.ide.ext.java.shared.dto.search.FindUsagesResponse) ServerException(org.eclipse.che.ide.commons.exception.ServerException) FindUsagesRequest(org.eclipse.che.ide.ext.java.shared.dto.search.FindUsagesRequest) SVGResource(org.vectomatic.dom.svg.ui.SVGResource) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 5 with OperationException

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());
            }
        });
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) List(java.util.List) MethodParameters(org.eclipse.che.ide.ext.java.shared.dto.model.MethodParameters) PositionConverter(org.eclipse.che.ide.api.editor.position.PositionConverter) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

OperationException (org.eclipse.che.api.promises.client.OperationException)158 PromiseError (org.eclipse.che.api.promises.client.PromiseError)123 Operation (org.eclipse.che.api.promises.client.Operation)115 Project (org.eclipse.che.ide.api.resources.Project)53 Resource (org.eclipse.che.ide.api.resources.Resource)48 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)21 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)21 List (java.util.List)19 Promise (org.eclipse.che.api.promises.client.Promise)17 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)15 Path (org.eclipse.che.ide.resource.Path)15 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)14 ArrayList (java.util.ArrayList)13 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)13 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)12 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)11 Optional (com.google.common.base.Optional)10 HashMap (java.util.HashMap)10 File (org.eclipse.che.ide.api.resources.File)10 Credentials (org.eclipse.che.ide.api.subversion.Credentials)10