Search in sources :

Example 31 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.

the class SetupChunkOptionsPopupPanel method initOptions.

@Override
protected void initOptions(final Command afterInit) {
    String chunkText = getChunkText();
    server_.extractChunkOptions(chunkText, new ServerRequestCallback<JsObject>() {

        @Override
        public void onError(ServerError error) {
            Debug.logError(error);
        }

        @Override
        public void onResponseReceived(JsObject object) {
            JsArrayString keys = object.keys();
            for (String key : JsUtil.asIterable(keys)) chunkOptions_.put(key, object.getAsString(key));
            afterInit.execute();
        }
    });
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) ServerError(org.rstudio.studio.client.server.ServerError) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 32 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.

the class BranchToolbarButton method onVcsRefresh.

@Override
public void onVcsRefresh(VcsRefreshEvent event) {
    ToolbarPopupMenu rootMenu = getMenu();
    rootMenu.setAutoHideRedundantSeparators(false);
    rootMenu.clearItems();
    JsArrayString branches = pVcsState_.get().getBranchInfo().getBranches();
    // separate branches based on remote name
    Map<String, List<String>> branchMap = new LinkedHashMap<String, List<String>>();
    List<String> localBranches = new ArrayList<String>();
    branchMap.put(LOCAL_BRANCHES, localBranches);
    for (String branch : JsUtil.asIterable(branches)) {
        if (branch.startsWith("remotes/")) {
            JsArrayString parts = StringUtil.split(branch, "/");
            if (parts.length() > 2) {
                String remote = parts.get(1);
                if (!branchMap.containsKey(remote))
                    branchMap.put(remote, new ArrayList<String>());
                List<String> remoteBranches = branchMap.get(remote);
                remoteBranches.add(branch);
            }
        } else {
            localBranches.add(branch);
        }
    }
    onBeforePopulateMenu(rootMenu);
    populateMenu(rootMenu, branchMap);
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) ScrollableToolbarPopupMenu(org.rstudio.core.client.widget.ScrollableToolbarPopupMenu) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) LinkedHashMap(java.util.LinkedHashMap)

Example 33 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.

the class ProjectTemplateWidget method readSelectBoxFields.

private String[] readSelectBoxFields(ProjectTemplateWidgetDescription description) {
    JsArrayString jsFields = description.getFields();
    int n = jsFields.length();
    String[] fields = new String[n];
    for (int i = 0; i < n; i++) fields[i] = jsFields.get(i);
    return fields;
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 34 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.

the class BuildToolsWebsitePanel method load.

@Override
void load(RProjectOptions options) {
    RProjectConfig config = options.getConfig();
    pathSelector_.setText(config.getWebsitePath());
    RProjectBuildOptions buildOptions = options.getBuildOptions();
    chkPreviewAfterBuilding_.setValue(buildOptions.getPreviewWebsite());
    chkLivePreviewSite_.setValue(buildOptions.getLivePreviewWebsite());
    RProjectBuildContext buildContext = options.getBuildContext();
    if (buildContext.isBookdownSite()) {
        // change caption
        chkPreviewAfterBuilding_.setText("Preview book after building");
        // get all available output formats
        JsArrayString formatsJson = buildContext.getWebsiteOutputFormats();
        ArrayList<String> formatNames = new ArrayList<String>();
        ArrayList<String> formats = new ArrayList<String>();
        // always include "All Formats"
        formatNames.add("(All Formats)");
        formats.add("all");
        for (int i = 0; i < formatsJson.length(); i++) {
            formatNames.add(formatsJson.get(i));
            formats.add(formatsJson.get(i));
        }
        websiteOutputFormat_.setChoices(formatNames.toArray(new String[] {}), formats.toArray(new String[] {}));
        websiteOutputFormat_.setValue(buildOptions.getWebsiteOutputFormat());
        websiteOutputFormat_.setVisible(true);
    }
}
Also used : RProjectBuildOptions(org.rstudio.studio.client.projects.model.RProjectBuildOptions) ArrayList(java.util.ArrayList) RProjectBuildContext(org.rstudio.studio.client.projects.model.RProjectBuildContext) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) RProjectConfig(org.rstudio.studio.client.projects.model.RProjectConfig)

Example 35 with JsArrayString

use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.

the class ProjectSourceControlPreferencesPane method initialize.

@Override
protected void initialize(RProjectOptions options) {
    // save the context
    vcsContext_ = options.getVcsContext();
    // populate the vcs selections list
    String[] vcsSelections = new String[] { NONE };
    JsArrayString applicableVcs = vcsContext_.getApplicableVcs();
    if (applicableVcs.length() > 0) {
        vcsSelections = new String[applicableVcs.length() + 1];
        vcsSelections[0] = NONE;
        for (int i = 0; i < applicableVcs.length(); i++) vcsSelections[i + 1] = applicableVcs.get(i);
    }
    vcsSelect_.setChoices(vcsSelections);
    // set override or default
    RProjectVcsOptions vcsOptions = options.getVcsOptions();
    if (vcsOptions.getActiveVcsOverride().length() > 0)
        setVcsSelection(vcsOptions.getActiveVcsOverride());
    else
        setVcsSelection(vcsContext_.getDetectedVcs());
}
Also used : RProjectVcsOptions(org.rstudio.studio.client.projects.model.RProjectVcsOptions) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Aggregations

JsArrayString (com.google.gwt.core.client.JsArrayString)86 ArrayList (java.util.ArrayList)15 JSONString (com.google.gwt.json.client.JSONString)5 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)5 ServerError (org.rstudio.studio.client.server.ServerError)4 JsArrayInteger (com.google.gwt.core.client.JsArrayInteger)3 Command (com.google.gwt.user.client.Command)3 List (java.util.List)3 KeySequence (org.rstudio.core.client.command.KeyboardShortcut.KeySequence)3 JsObject (org.rstudio.core.client.js.JsObject)3 RmdTemplateFormatOption (org.rstudio.studio.client.rmarkdown.model.RmdTemplateFormatOption)3 JsArrayBoolean (com.google.gwt.core.client.JsArrayBoolean)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)2 Label (com.google.gwt.user.client.ui.Label)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 Handler (org.rstudio.core.client.command.Handler)2 EnsureHeightHandler (org.rstudio.core.client.events.EnsureHeightHandler)2 EnsureVisibleHandler (org.rstudio.core.client.events.EnsureVisibleHandler)2 ChangeFontSizeHandler (org.rstudio.studio.client.application.events.ChangeFontSizeHandler)2 RmdFrontMatterOutputOptions (org.rstudio.studio.client.rmarkdown.model.RmdFrontMatterOutputOptions)2