Search in sources :

Example 96 with PromiseError

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

the class AbstractDebugger method connect.

@Override
public Promise<Void> connect(Map<String, String> connectionProperties) {
    if (isConnected()) {
        return Promises.reject(JsPromiseError.create("Debugger already connected"));
    }
    Promise<DebugSessionDto> connect = service.connect(debuggerType, connectionProperties);
    final DebuggerDescriptor debuggerDescriptor = toDescriptor(connectionProperties);
    Promise<Void> promise = connect.then(new Function<DebugSessionDto, Void>() {

        @Override
        public Void apply(final DebugSessionDto arg) throws FunctionException {
            DebuggerInfo debuggerInfo = arg.getDebuggerInfo();
            debuggerDescriptor.setInfo(debuggerInfo.getName() + " " + debuggerInfo.getVersion());
            setDebugSession(arg);
            preserveDebuggerState();
            startCheckingEvents();
            startDebugger(arg);
            return null;
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            Log.error(AbstractDebugger.class, arg.getMessage());
            throw new OperationException(arg.getCause());
        }
    });
    for (DebuggerObserver observer : observers) {
        observer.onDebuggerAttached(debuggerDescriptor, promise);
    }
    return promise;
}
Also used : DebuggerInfo(org.eclipse.che.api.debug.shared.model.DebuggerInfo) DebuggerDescriptor(org.eclipse.che.ide.debug.DebuggerDescriptor) Function(org.eclipse.che.api.promises.client.Function) 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) DebuggerObserver(org.eclipse.che.ide.debug.DebuggerObserver) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 97 with PromiseError

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

the class AbstractDebugger method addBreakpoint.

@Override
public void addBreakpoint(final VirtualFile file, final int lineNumber) {
    if (isConnected()) {
        String fqn = pathToFqn(file);
        if (fqn == null) {
            return;
        }
        final String filePath = file.getLocation().toString();
        LocationDto locationDto = dtoFactory.createDto(LocationDto.class).withLineNumber(lineNumber + 1).withTarget(fqn).withResourcePath(filePath).withResourceProjectPath(getProject(file).getPath());
        BreakpointDto breakpointDto = dtoFactory.createDto(BreakpointDto.class).withLocation(locationDto).withEnabled(true);
        Promise<Void> promise = service.addBreakpoint(debugSessionDto.getId(), breakpointDto);
        promise.then(new Operation<Void>() {

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

            @Override
            public void apply(PromiseError arg) throws OperationException {
                Log.error(AbstractDebugger.class, arg.getMessage());
            }
        });
    } else {
        Breakpoint breakpoint = new Breakpoint(Breakpoint.Type.BREAKPOINT, lineNumber, file.getLocation().toString(), file, false);
        for (DebuggerObserver observer : observers) {
            observer.onBreakpointAdded(breakpoint);
        }
    }
}
Also used : Breakpoint(org.eclipse.che.ide.api.debug.Breakpoint) Operation(org.eclipse.che.api.promises.client.Operation) JsPromiseError(org.eclipse.che.api.promises.client.js.JsPromiseError) PromiseError(org.eclipse.che.api.promises.client.PromiseError) BreakpointDto(org.eclipse.che.api.debug.shared.dto.BreakpointDto) 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 98 with PromiseError

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

the class AbstractDebugger method resume.

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

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

Example 99 with PromiseError

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

the class AbstractDebugger method setValue.

@Override
public void setValue(final Variable variable) {
    if (isConnected()) {
        Promise<Void> promise = service.setValue(debugSessionDto.getId(), asDto(variable));
        promise.then(new Operation<Void>() {

            @Override
            public void apply(Void arg) throws OperationException {
                for (DebuggerObserver observer : observers) {
                    observer.onValueChanged(variable.getVariablePath().getPath(), variable.getValue());
                }
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError arg) throws OperationException {
                Log.error(AbstractDebugger.class, arg.getMessage());
            }
        });
    }
}
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 100 with PromiseError

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

the class AbstractDebugger method stepOut.

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

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

Aggregations

PromiseError (org.eclipse.che.api.promises.client.PromiseError)137 OperationException (org.eclipse.che.api.promises.client.OperationException)123 Operation (org.eclipse.che.api.promises.client.Operation)109 Project (org.eclipse.che.ide.api.resources.Project)48 Resource (org.eclipse.che.ide.api.resources.Resource)40 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)21 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)20 Promise (org.eclipse.che.api.promises.client.Promise)19 List (java.util.List)15 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)13 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)13 Path (org.eclipse.che.ide.resource.Path)13 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)11 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)10 Credentials (org.eclipse.che.ide.api.subversion.Credentials)10 HashMap (java.util.HashMap)9 Function (org.eclipse.che.api.promises.client.Function)8 FunctionException (org.eclipse.che.api.promises.client.FunctionException)8