Search in sources :

Example 11 with JsObject

use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.

the class SatelliteManager method registerAsSatellite.

// called by satellites to connect themselves with the main window
private void registerAsSatellite(final String name, JavaScriptObject wnd) {
    // get the satellite and add it to our list. in some cases (such as
    // the Ctrl+R reload of an existing satellite window) we actually
    // already have a reference to this satellite in our list so in that
    // case we make sure not to add a duplicate
    WindowEx satelliteWnd = wnd.<WindowEx>cast();
    ActiveSatellite satellite = new ActiveSatellite(name, satelliteWnd);
    if (!satellites_.contains(satellite))
        satellites_.add(satellite);
    // augment the current session info with an up-to-date set of source 
    // documents
    SessionInfo sessionInfo = session_.getSessionInfo();
    sessionInfo.setSourceDocuments(pSourceWindowManager_.get().getSourceDocs());
    // clone the session info so the satellites aren't reading/writing the
    // same copy as the main window; pass the cloned copy along
    JsObject sessionInfoJs = session_.getSessionInfo().cast();
    callSetSessionInfo(satelliteWnd, sessionInfoJs.clone());
    // call setParams
    JavaScriptObject params = satelliteParams_.get(name);
    if (params != null)
        callSetParams(satelliteWnd, params);
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) WindowEx(org.rstudio.core.client.dom.WindowEx)

Example 12 with JsObject

use of org.rstudio.core.client.js.JsObject 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)

Example 13 with JsObject

use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.

the class ProjectTemplateWidget method fileInput.

private ProjectTemplateWidgetItem fileInput(final ProjectTemplateWidgetDescription description) {
    final FileChooserTextBox widget = new FileChooserTextBox(description.getLabel(), null);
    String defaultValue = description.getDefault();
    if (!StringUtil.isNullOrEmpty(defaultValue))
        widget.setText(defaultValue);
    return new ProjectTemplateWidgetItem(widget, new Collector() {

        @Override
        public void collectInput(JsObject receiver) {
            String value = widget.getText();
            receiver.setString(description.getParameter(), value);
        }
    });
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) FileChooserTextBox(org.rstudio.core.client.widget.FileChooserTextBox) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 14 with JsObject

use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.

the class ProjectTemplateWidget method selectBoxInput.

private ProjectTemplateWidgetItem selectBoxInput(final ProjectTemplateWidgetDescription description) {
    String[] fields = readSelectBoxFields(description);
    String label = ensureEndsWithColon(description.getLabel());
    final SelectWidget widget = new SelectWidget(label, fields);
    String defaultValue = description.getDefault();
    if (!StringUtil.isNullOrEmpty(defaultValue))
        widget.setValue(defaultValue);
    return new ProjectTemplateWidgetItem(widget, new Collector() {

        @Override
        public void collectInput(JsObject receiver) {
            String value = widget.getValue();
            receiver.setString(description.getParameter(), value);
        }
    });
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) SelectWidget(org.rstudio.core.client.widget.SelectWidget) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 15 with JsObject

use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.

the class ProjectTemplateWidget method textInput.

private ProjectTemplateWidgetItem textInput(final ProjectTemplateWidgetDescription description) {
    final TextBox primaryWidget = new TextBox();
    primaryWidget.setWidth("180px");
    String defaultValue = description.getDefault();
    if (!StringUtil.isNullOrEmpty(defaultValue))
        primaryWidget.setText(defaultValue);
    Grid grid = new Grid(1, 2);
    primaryWidget.getElement().setAttribute("spellcheck", "false");
    grid.setWidget(0, 0, new Label(ensureEndsWithColon(description.getLabel())));
    grid.setWidget(0, 1, primaryWidget);
    return new ProjectTemplateWidgetItem(grid, new Collector() {

        @Override
        public void collectInput(JsObject receiver) {
            String value = primaryWidget.getValue();
            receiver.setString(description.getParameter(), value);
        }
    });
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) Grid(com.google.gwt.user.client.ui.Grid) Label(com.google.gwt.user.client.ui.Label) TextBox(com.google.gwt.user.client.ui.TextBox) FileChooserTextBox(org.rstudio.core.client.widget.FileChooserTextBox) JsArrayString(com.google.gwt.core.client.JsArrayString)

Aggregations

JsObject (org.rstudio.core.client.js.JsObject)19 JsArrayString (com.google.gwt.core.client.JsArrayString)9 JSObjectStateValue (org.rstudio.studio.client.workbench.model.helper.JSObjectStateValue)4 JsArray (com.google.gwt.core.client.JsArray)3 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)3 SessionInfo (org.rstudio.studio.client.workbench.model.SessionInfo)3 WindowEx (org.rstudio.core.client.dom.WindowEx)2 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)2 FileChooserTextBox (org.rstudio.core.client.widget.FileChooserTextBox)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 Grid (com.google.gwt.user.client.ui.Grid)1 Label (com.google.gwt.user.client.ui.Label)1 TextBox (com.google.gwt.user.client.ui.TextBox)1 Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 DesktopMenuCallback (org.rstudio.core.client.command.impl.DesktopMenuCallback)1 ThemeStyles (org.rstudio.core.client.theme.res.ThemeStyles)1 SelectWidget (org.rstudio.core.client.widget.SelectWidget)1 EventBus (org.rstudio.studio.client.application.events.EventBus)1