Search in sources :

Example 1 with JsObject

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();
}
Also used : JsObject(org.rstudio.core.client.js.JsObject)

Example 2 with JsObject

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();
}
Also used : JsObject(org.rstudio.core.client.js.JsObject)

Example 3 with JsObject

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);
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 4 with JsObject

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;
        }
    };
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) JsArray(com.google.gwt.core.client.JsArray) FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) StringStateValue(org.rstudio.studio.client.workbench.model.helper.StringStateValue) ClientInitState(org.rstudio.studio.client.workbench.model.ClientInitState) JSObjectStateValue(org.rstudio.studio.client.workbench.model.helper.JSObjectStateValue)

Example 5 with JsObject

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);
    }
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) 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