Search in sources :

Example 6 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class OpenImplementationPresenter method actionPerformed.

public void actionPerformed(final Member member) {
    if (member.isBinary()) {
        final Resource resource = context.getResource();
        if (resource == null) {
            return;
        }
        final Optional<Project> project = resource.getRelatedProject();
        service.getEntry(project.get().getLocation(), member.getLibId(), member.getRootPath()).then(new Operation<JarEntry>() {

            @Override
            public void apply(final JarEntry entry) throws OperationException {
                service.getContent(project.get().getLocation(), member.getLibId(), Path.valueOf(entry.getPath())).then(new Operation<ClassContent>() {

                    @Override
                    public void apply(ClassContent content) throws OperationException {
                        final String clazz = entry.getName().substring(0, entry.getName().indexOf('.'));
                        final VirtualFile file = new SyntheticFile(entry.getName(), clazz, content.getContent());
                        editorAgent.openEditor(file, new OpenEditorCallbackImpl() {

                            @Override
                            public void onEditorOpened(EditorPartPresenter editor) {
                                setCursor(member.getFileRegion());
                            }
                        });
                    }
                });
            }
        });
    } else {
        context.getWorkspaceRoot().getFile(member.getRootPath()).then(new Operation<Optional<File>>() {

            @Override
            public void apply(Optional<File> file) throws OperationException {
                if (file.isPresent()) {
                    editorAgent.openEditor(file.get(), new OpenEditorCallbackImpl() {

                        @Override
                        public void onEditorOpened(EditorPartPresenter editor) {
                            setCursor(member.getFileRegion());
                        }
                    });
                }
            }
        });
    }
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

        @Override
        public void execute() {
            activeEditor.setFocus();
        }
    });
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) ClassContent(org.eclipse.che.ide.ext.java.shared.dto.ClassContent) Optional(com.google.common.base.Optional) Scheduler(com.google.gwt.core.client.Scheduler) Resource(org.eclipse.che.ide.api.resources.Resource) OpenEditorCallbackImpl(org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl) Operation(org.eclipse.che.api.promises.client.Operation) JarEntry(org.eclipse.che.ide.ext.java.shared.JarEntry) Project(org.eclipse.che.ide.api.resources.Project) SyntheticFile(org.eclipse.che.ide.api.resources.SyntheticFile) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) File(org.eclipse.che.ide.api.resources.File) VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) SyntheticFile(org.eclipse.che.ide.api.resources.SyntheticFile) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 7 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class AbstractDebugger method deleteBreakpoint.

@Override
public void deleteBreakpoint(final VirtualFile file, final int lineNumber) {
    if (!isConnected()) {
        return;
    }
    LocationDto locationDto = dtoFactory.createDto(LocationDto.class);
    locationDto.setLineNumber(lineNumber + 1);
    String fqn = pathToFqn(file);
    if (fqn == null) {
        return;
    }
    locationDto.setTarget(fqn);
    Promise<Void> promise = service.deleteBreakpoint(debugSessionDto.getId(), locationDto);
    promise.then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
            for (DebuggerObserver observer : observers) {
                Breakpoint breakpoint = new Breakpoint(Breakpoint.Type.BREAKPOINT, lineNumber, file.getLocation().toString(), file, false);
                observer.onBreakpointDeleted(breakpoint);
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            Log.error(AbstractDebugger.class, arg.getMessage());
        }
    });
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) JsPromiseError(org.eclipse.che.api.promises.client.js.JsPromiseError) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) DebuggerObserver(org.eclipse.che.ide.debug.DebuggerObserver) LocationDto(org.eclipse.che.api.debug.shared.dto.LocationDto) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 8 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class AbstractDebugger method disconnect.

@Override
public void disconnect() {
    stopCheckingDebugEvents();
    Promise<Void> disconnect;
    if (isConnected()) {
        disconnect = service.disconnect(debugSessionDto.getId());
    } else {
        disconnect = Promises.resolve(null);
    }
    invalidateDebugSession();
    preserveDebuggerState();
    disconnect.then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
            for (DebuggerObserver observer : observers) {
                observer.onDebuggerDisconnected();
            }
            debuggerManager.setActiveDebugger(null);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            for (DebuggerObserver observer : observers) {
                observer.onDebuggerDisconnected();
            }
            debuggerManager.setActiveDebugger(null);
        }
    });
}
Also used : JsPromiseError(org.eclipse.che.api.promises.client.js.JsPromiseError) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) DebuggerObserver(org.eclipse.che.ide.debug.DebuggerObserver) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 9 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class AbstractDebugger method stepOver.

@Override
public void stepOver() {
    if (isConnected()) {
        for (DebuggerObserver observer : observers) {
            observer.onPreStepOver();
        }
        removeCurrentLocation();
        preserveDebuggerState();
        StepOverActionDto action = dtoFactory.createDto(StepOverActionDto.class);
        action.setType(Action.TYPE.STEP_OVER);
        Promise<Void> promise = service.stepOver(debugSessionDto.getId(), action);
        promise.catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError arg) throws OperationException {
                Log.error(AbstractDebugger.class, arg.getCause());
            }
        });
    }
}
Also used : StepOverActionDto(org.eclipse.che.api.debug.shared.dto.action.StepOverActionDto) JsPromiseError(org.eclipse.che.api.promises.client.js.JsPromiseError) PromiseError(org.eclipse.che.api.promises.client.PromiseError) DebuggerObserver(org.eclipse.che.ide.debug.DebuggerObserver) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 10 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class AbstractDebugger method addHandlers.

private void addHandlers(final MessageBusProvider messageBusProvider) {
    eventBus.addHandler(WsAgentStateEvent.TYPE, new WsAgentStateHandler() {

        @Override
        public void onWsAgentStarted(WsAgentStateEvent event) {
            messageBus = messageBusProvider.getMachineMessageBus();
            if (!isConnected()) {
                return;
            }
            Promise<DebugSessionDto> promise = service.getSessionInfo(debugSessionDto.getId());
            promise.then(new Operation<DebugSessionDto>() {

                @Override
                public void apply(DebugSessionDto arg) throws OperationException {
                    debuggerManager.setActiveDebugger(AbstractDebugger.this);
                    setDebugSession(arg);
                    DebuggerInfo debuggerInfo = arg.getDebuggerInfo();
                    String info = debuggerInfo.getName() + " " + debuggerInfo.getVersion();
                    String address = debuggerInfo.getHost() + ":" + debuggerInfo.getPort();
                    DebuggerDescriptor debuggerDescriptor = new DebuggerDescriptor(info, address);
                    JsPromise<Void> promise = Promises.resolve(null);
                    for (DebuggerObserver observer : observers) {
                        observer.onDebuggerAttached(debuggerDescriptor, promise);
                    }
                    startCheckingEvents();
                }
            }).catchError(new Operation<PromiseError>() {

                @Override
                public void apply(PromiseError arg) throws OperationException {
                    if (!isConnected()) {
                        invalidateDebugSession();
                    }
                }
            });
        }

        @Override
        public void onWsAgentStopped(WsAgentStateEvent event) {
        }
    });
    this.debuggerEventsHandler = new SubscriptionHandler<DebuggerEventDto>(new DebuggerEventUnmarshaller(dtoFactory)) {

        @Override
        public void onMessageReceived(DebuggerEventDto result) {
            if (!isConnected()) {
                return;
            }
            onEventListReceived(result);
        }

        @Override
        public void onErrorReceived(Throwable exception) {
            if (!isConnected()) {
                return;
            }
            try {
                messageBus.unsubscribe(eventChannel, this);
            } catch (WebSocketException e) {
                Log.error(AbstractDebugger.class, e);
            }
            if (exception instanceof ServerException) {
                ServerException serverException = (ServerException) exception;
                if (HTTPStatus.INTERNAL_ERROR == serverException.getHTTPStatus() && serverException.getMessage() != null && serverException.getMessage().contains("not found")) {
                    disconnect();
                }
            }
        }
    };
}
Also used : DebuggerInfo(org.eclipse.che.api.debug.shared.model.DebuggerInfo) ServerException(org.eclipse.che.ide.websocket.rest.exceptions.ServerException) WebSocketException(org.eclipse.che.ide.websocket.WebSocketException) WsAgentStateHandler(org.eclipse.che.ide.api.machine.events.WsAgentStateHandler) DebuggerDescriptor(org.eclipse.che.ide.debug.DebuggerDescriptor) JsPromise(org.eclipse.che.api.promises.client.js.JsPromise) Operation(org.eclipse.che.api.promises.client.Operation) JsPromise(org.eclipse.che.api.promises.client.js.JsPromise) Promise(org.eclipse.che.api.promises.client.Promise) DebuggerEventDto(org.eclipse.che.api.debug.shared.dto.event.DebuggerEventDto) JsPromiseError(org.eclipse.che.api.promises.client.js.JsPromiseError) PromiseError(org.eclipse.che.api.promises.client.PromiseError) DebugSessionDto(org.eclipse.che.api.debug.shared.dto.DebugSessionDto) WsAgentStateEvent(org.eclipse.che.ide.api.machine.events.WsAgentStateEvent) DebuggerObserver(org.eclipse.che.ide.debug.DebuggerObserver) 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