use of org.eclipse.che.ide.debug.DebuggerObserver 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());
}
});
}
use of org.eclipse.che.ide.debug.DebuggerObserver 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);
}
});
}
use of org.eclipse.che.ide.debug.DebuggerObserver 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());
}
});
}
}
use of org.eclipse.che.ide.debug.DebuggerObserver 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();
}
}
}
};
}
use of org.eclipse.che.ide.debug.DebuggerObserver in project che by eclipse.
the class AbstractDebugger method deleteAllBreakpoints.
@Override
public void deleteAllBreakpoints() {
if (!isConnected()) {
return;
}
Promise<Void> promise = service.deleteAllBreakpoints(debugSessionDto.getId());
promise.then(new Operation<Void>() {
@Override
public void apply(Void arg) throws OperationException {
for (DebuggerObserver observer : observers) {
observer.onAllBreakpointsDeleted();
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
Log.error(AbstractDebugger.class, arg.getMessage());
}
});
}
Aggregations