use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.
the class RSConnectPublishSettings method toJso.
public JavaScriptObject toJso() {
JsObject obj = JsObject.createJsObject();
obj.setJsArrayString("deploy_files", JsArrayUtil.toJsArrayString(getDeployFiles()));
obj.setJsArrayString("additional_files", JsArrayUtil.toJsArrayString(getAdditionalFiles()));
obj.setJsArrayString("ignored_files", JsArrayUtil.toJsArrayString(getIgnoredFiles()));
obj.setBoolean("as_multiple", getAsMultiple());
obj.setBoolean("as_static", getAsStatic());
obj.setBoolean("show_diagnostics", RStudioGinjector.INSTANCE.getUIPrefs().showPublishDiagnostics().getValue());
return obj.cast();
}
use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.
the class RSConnectPublishSource method toJso.
public JavaScriptObject toJso() {
// create summary of publish source for server
JsObject obj = JsObject.createJsObject();
obj.setString("deploy_dir", getDeployDir());
obj.setString("deploy_file", isDocument() || isSingleFileShiny() ? getDeployFileName() : "");
obj.setString("source_file", isDocument() && getSourceFile() != null && getContentCategory() != RSConnect.CONTENT_CATEGORY_SITE ? getSourceFile() : "");
obj.setString("content_category", StringUtil.notNull(getContentCategory()));
return obj.cast();
}
use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.
the class ImportFileSettingsDialog method populateOutput.
private void populateOutput(DataPreviewResult result) {
JsArray<JsObject> output = result.getOutput();
JsArrayString names = result.getOutputNames();
int rows = output.length();
int cols = names.length();
Grid grid = new Grid(rows + 1, cols);
grid.setCellPadding(0);
grid.setCellSpacing(0);
grid.getRowFormatter().addStyleName(0, styles_.header());
for (int col = 0; col < cols; col++) grid.setText(0, col, names.get(col));
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
String val = output.get(row).getString(names.get(col), true);
if (val == null)
val = "NA";
grid.setText(row + 1, col, val);
}
}
outputPanel_.setWidget(grid);
}
use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.
the class Files method initSession.
private void initSession() {
final SessionInfo sessionInfo = session_.getSessionInfo();
ClientInitState state = sessionInfo.getClientState();
// make the column sort order persistent
new JSObjectStateValue(MODULE_FILES, KEY_SORT_ORDER, ClientState.PROJECT_PERSISTENT, state, false) {
@Override
protected void onInit(JsObject value) {
if (value != null)
columnSortOrder_ = value.cast();
else
columnSortOrder_ = null;
lastKnownState_ = columnSortOrder_;
view_.setColumnSortOrder(columnSortOrder_);
}
@Override
protected JsObject getValue() {
if (columnSortOrder_ != null)
return columnSortOrder_.cast();
else
return null;
}
@Override
protected boolean hasChanged() {
if (lastKnownState_ != columnSortOrder_) {
lastKnownState_ = columnSortOrder_;
return true;
} else {
return false;
}
}
private JsArray<ColumnSortInfo> lastKnownState_ = null;
};
// navigate to previous directory (works for resumed case)
new StringStateValue(MODULE_FILES, KEY_PATH, ClientState.PROJECT_PERSISTENT, state) {
@Override
protected void onInit(final String value) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
// we don't need to initialize from client state
if (hasNavigatedToDirectory_)
return;
// compute start dir
String path = transformPathStateValue(value);
FileSystemItem start = path != null ? FileSystemItem.createDir(path) : FileSystemItem.createDir(sessionInfo.getInitialWorkingDir());
navigateToDirectory(start);
}
});
}
@Override
protected String getValue() {
return currentPath_.getPath();
}
private String transformPathStateValue(String value) {
// if the value is null then return null
if (value == null)
return null;
// only respect the value for projects
String projectFile = session_.getSessionInfo().getActiveProjectFile();
if (projectFile == null)
return null;
// ensure that the value is within the project dir (it wouldn't
// be if the project directory has been moved or renamed)
String projectDirPath = FileSystemItem.createFile(projectFile).getParentPathString();
if (value.startsWith(projectDirPath))
return value;
else
return null;
}
};
}
use of org.rstudio.core.client.js.JsObject in project rstudio by rstudio.
the class AceEditor method resetCommands.
public void resetCommands() {
AceCommandManager manager = AceCommandManager.create();
JsObject commands = manager.getCommands();
for (String key : JsUtil.asIterable(commands.keys())) {
AceCommand command = commands.getObject(key);
getWidget().getEditor().getCommandManager().addCommand(command);
}
}
Aggregations