Search in sources :

Example 1 with BreakpointsSavedEvent

use of org.rstudio.studio.client.common.debugging.events.BreakpointsSavedEvent in project rstudio by rstudio.

the class BreakpointManager method notifyBreakpointsSaved.

private void notifyBreakpointsSaved(ArrayList<Breakpoint> breakpoints, boolean saved) {
    breakpointStateDirty_ = true;
    events_.fireEvent(new BreakpointsSavedEvent(breakpoints, saved));
}
Also used : BreakpointsSavedEvent(org.rstudio.studio.client.common.debugging.events.BreakpointsSavedEvent)

Example 2 with BreakpointsSavedEvent

use of org.rstudio.studio.client.common.debugging.events.BreakpointsSavedEvent in project rstudio by rstudio.

the class BreakpointManager method onSessionInit.

// Event handlers ----------------------------------------------------------
@Override
public void onSessionInit(SessionInitEvent sie) {
    // Establish a persistent object for the breakpoints. Note that this 
    // object is read by the server on init, so the scope/name pair here 
    // needs to match the pair on the server. 
    new JSObjectStateValue("debug-breakpoints", "debugBreakpointsState", ClientState.PROJECT_PERSISTENT, session_.getSessionInfo().getClientState(), false) {

        @Override
        protected void onInit(JsObject value) {
            if (value != null) {
                BreakpointState state = value.cast();
                // restore all of the breakpoints
                JsArray<Breakpoint> breakpoints = state.getPersistedBreakpoints();
                for (int idx = 0; idx < breakpoints.length(); idx++) {
                    Breakpoint breakpoint = breakpoints.get(idx);
                    // make sure the next breakpoint we create after a restore 
                    // has a value larger than any existing breakpoint
                    currentBreakpointId_ = Math.max(currentBreakpointId_, breakpoint.getBreakpointId() + 1);
                    addBreakpoint(breakpoint);
                }
                // this initialization happens after the source windows are
                // up, so fire an event to the editor to show all known 
                // breakpoints. as new source windows are opened, they will
                // call getBreakpointsInFile to populate themselves.
                events_.fireEvent(new BreakpointsSavedEvent(breakpoints_, true));
            }
        }

        @Override
        protected JsObject getValue() {
            BreakpointState state = BreakpointState.create();
            for (Breakpoint breakpoint : breakpoints_) {
                state.addPersistedBreakpoint(breakpoint);
            }
            breakpointStateDirty_ = false;
            return state.cast();
        }

        @Override
        protected boolean hasChanged() {
            return breakpointStateDirty_;
        }
    };
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) BreakpointsSavedEvent(org.rstudio.studio.client.common.debugging.events.BreakpointsSavedEvent) JSObjectStateValue(org.rstudio.studio.client.workbench.model.helper.JSObjectStateValue) BreakpointState(org.rstudio.studio.client.common.debugging.model.BreakpointState) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint)

Aggregations

BreakpointsSavedEvent (org.rstudio.studio.client.common.debugging.events.BreakpointsSavedEvent)2 JsObject (org.rstudio.core.client.js.JsObject)1 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)1 BreakpointState (org.rstudio.studio.client.common.debugging.model.BreakpointState)1 JSObjectStateValue (org.rstudio.studio.client.workbench.model.helper.JSObjectStateValue)1