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);
}
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_;
}
};
}
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);
}
});
}
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);
}
});
}
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);
}
});
}
Aggregations