Example usage for com.google.gwt.core.client JsArrayString push

List of usage examples for com.google.gwt.core.client JsArrayString push

Introduction

In this page you can find the example usage for com.google.gwt.core.client JsArrayString push.

Prototype

public final native void push(String value) ;

Source Link

Document

Pushes the given value onto the end of the array.

Usage

From source file:org.rstudio.studio.client.common.r.roxygen.RoxygenHelper.java

License:Open Source License

private static JsArrayString setdiff(JsArrayString self, JsArrayString other) {
    JsArrayString result = JsArray.createArray().cast();
    for (int i = 0; i < self.length(); i++)
        if (!contains(other, self.get(i)))
            result.push(self.get(i));
    return result;
}

From source file:org.rstudio.studio.client.common.r.roxygen.RoxygenHelper.java

License:Open Source License

private JsArrayString listParametersInRoxygenBlock(JsArrayString block, Pattern pattern) {
    JsArrayString roxygenParams = JsArrayString.createArray().cast();
    for (int i = 0; i < block.length(); i++) {
        String line = block.get(i);
        Match match = pattern.match(line, 0);
        if (match != null)
            roxygenParams.push(match.getGroup(1));
    }//from   www . j  a  v a 2 s .c o m

    return roxygenParams;
}

From source file:org.rstudio.studio.client.workbench.model.ClientState.java

License:Open Source License

public void putStrings(String group, String name, String[] value, int persist) {
    JsArrayString array = JsArrayString.createArray().cast();
    for (String v : value)
        array.push(v);
    this.putObject(group, name, array, persist);
}

From source file:org.rstudio.studio.client.workbench.prefs.views.PaneLayoutPreferencesPane.java

License:Open Source License

@Override
public boolean onApply(RPrefs rPrefs) {
    boolean restartRequired = super.onApply(rPrefs);

    if (dirty_) {
        JsArrayString panes = JsArrayString.createArray().cast();
        panes.push(leftTop_.getValue(leftTop_.getSelectedIndex()));
        panes.push(leftBottom_.getValue(leftBottom_.getSelectedIndex()));
        panes.push(rightTop_.getValue(rightTop_.getSelectedIndex()));
        panes.push(rightBottom_.getValue(rightBottom_.getSelectedIndex()));

        JsArrayString tabSet1 = JsArrayString.createArray().cast();
        for (String tab : tabSet1ModuleList_.getValue())
            tabSet1.push(tab);//from   w  ww .j  a  va2 s . c o  m

        JsArrayString tabSet2 = JsArrayString.createArray().cast();
        for (String tab : tabSet2ModuleList_.getValue())
            tabSet2.push(tab);

        uiPrefs_.paneConfig().setGlobalValue(PaneConfig.create(panes, tabSet1, tabSet2));

        dirty_ = false;
    }

    return restartRequired;
}

From source file:org.rstudio.studio.client.workbench.ui.PaneConfig.java

License:Open Source License

public static PaneConfig createDefault() {
    JsArrayString panes = createArray().cast();
    panes.push("Source");
    panes.push("Console");
    panes.push("TabSet1");
    panes.push("TabSet2");

    JsArrayString tabSet1 = createArray().cast();
    tabSet1.push("Environment");
    tabSet1.push("History");
    tabSet1.push("Build");
    tabSet1.push("VCS");
    tabSet1.push("Presentation");

    JsArrayString tabSet2 = createArray().cast();
    tabSet2.push("Files");
    tabSet2.push("Plots");
    tabSet2.push("Packages");
    tabSet2.push("Help");
    tabSet2.push("Viewer");

    return create(panes, tabSet1, tabSet2);
}

From source file:org.rstudio.studio.client.workbench.ui.PaneConfig.java

License:Open Source License

public final boolean validateAndAutoCorrect() {
    JsArrayString panes = getPanes();/*from w  w  w .  j  a va  2 s  .c om*/
    if (panes == null)
        return false;
    if (!sameElements(panes, new String[] { "Source", "Console", "TabSet1", "TabSet2" }))
        return false;

    JsArrayString ts1 = getTabSet1();
    JsArrayString ts2 = getTabSet2();
    if (ts1.length() == 0 || ts2.length() == 0)
        return false;

    // Replace any obsoleted tabs in the config
    replaceObsoleteTabs(ts1);
    replaceObsoleteTabs(ts2);

    // If any of these tabs are missing, then they can be added
    Set<String> addableTabs = makeSet(getAddableTabs());

    // If any of these tabs are missing, then the whole config is invalid
    Set<String> baseTabs = makeSet(getAllTabs());
    baseTabs.removeAll(addableTabs);

    for (String tab : JsUtil.asIterable(concat(ts1, ts2))) {
        if (!baseTabs.remove(tab) && !addableTabs.remove(tab))
            return false; // unknown tab
    }

    // If any baseTabs are still present, they weren't part of the tabsets
    if (baseTabs.size() > 0)
        return false;

    // Were any addable tabs missing? Add them the appropriate tabset
    // (Iterate over original array instead of addableTabs set so that order
    // is well-defined)
    for (String tab : getAddableTabs())
        if (addableTabs.contains(tab))
            if (tab.equals("Viewer"))
                ts2.push(tab);
            else
                ts1.push(tab);

    // These tabs can be hidden sometimes; they can't stand alone in a tabset
    Set<String> hideableTabs = makeSet(getHideableTabs());
    if (isSubset(hideableTabs, JsUtil.asIterable(ts1)) || isSubset(hideableTabs, JsUtil.asIterable(ts2))) {
        return false;
    }

    return true;
}

From source file:org.rstudio.studio.client.workbench.ui.PaneConfig.java

License:Open Source License

private JsArrayString concat(JsArrayString a, JsArrayString b) {
    JsArrayString ab = createArray().cast();
    for (int i = 0; i < a.length(); i++)
        ab.push(a.get(i));
    for (int i = 0; i < b.length(); i++)
        ab.push(b.get(i));/*from   w w w  . j a v a  2 s  .  c o  m*/
    return ab;
}

From source file:org.rstudio.studio.client.workbench.ui.PaneConfig.java

License:Open Source License

private static JsArrayString copy(JsArrayString array) {
    if (array == null)
        return null;

    JsArrayString copy = JsArrayString.createArray().cast();
    for (int i = 0; i < array.length(); i++)
        copy.push(array.get(i));
    return copy;//from   w w  w  . j a  v  a  2  s.c om
}

From source file:org.rstudio.studio.client.workbench.views.output.find.FindOutputPresenter.java

License:Open Source License

public void onFindInFiles(FindInFilesEvent event) {
    FindInFilesDialog dialog = new FindInFilesDialog(new OperationWithInput<FindInFilesDialog.State>() {
        @Override//from w  w  w.  ja v  a2s. com
        public void execute(final FindInFilesDialog.State input) {
            dialogState_ = input;

            stopAndClear();

            FileSystemItem searchPath = FileSystemItem.createDir(input.getPath());

            JsArrayString filePatterns = JsArrayString.createArray().cast();
            for (String pattern : input.getFilePatterns())
                filePatterns.push(pattern);

            server_.beginFind(input.getQuery(), input.isRegex(), !input.isCaseSensitive(), searchPath,
                    filePatterns, new SimpleRequestCallback<String>() {
                        @Override
                        public void onResponseReceived(String handle) {
                            currentFindHandle_ = handle;
                            updateSearchLabel(input.getQuery(), input.getPath(), input.isRegex());
                            view_.setStopSearchButtonVisible(true);

                            super.onResponseReceived(handle);

                            view_.ensureVisible(true);
                        }
                    });
        }
    });

    if (!StringUtil.isNullOrEmpty(event.getSearchPattern()))
        dialog.setSearchPattern(event.getSearchPattern());

    if (dialogState_ == null) {
        dialog.setDirectory(session_.getSessionInfo().getActiveProjectDir() != null
                ? session_.getSessionInfo().getActiveProjectDir()
                : workbenchContext_.getCurrentWorkingDir());
    } else {
        dialog.setState(dialogState_);
    }

    dialog.showModal();
}

From source file:org.rstudio.studio.client.workbench.views.source.editors.text.ChunkOutputWidget.java

License:Open Source License

public static void cacheEditorStyle(String foregroundColor, String backgroundColor, String aceEditorColor) {
    // use a muted version of the text color for the outline
    ColorUtil.RGBColor text = ColorUtil.RGBColor.fromCss(aceEditorColor);

    // dark themes require a slightly more pronounced color
    ColorUtil.RGBColor outline = new ColorUtil.RGBColor(text.red(), text.green(), text.blue(),
            text.isDark() ? 0.12 : 0.18);

    String border = outline.asRgb();

    // highlight color used in data chunks
    ColorUtil.RGBColor highlight = new ColorUtil.RGBColor(text.red(), text.green(), text.blue(), 0.02);

    // synthesize a surface color by blending the keyword color with the 
    // background
    JsArrayString classes = JsArrayString.createArray().cast();
    classes.push("ace_editor");
    classes.push("ace_keyword");
    ColorUtil.RGBColor surface = ColorUtil.RGBColor.fromCss(DomUtils.extractCssValue(classes, "color"));
    surface = surface.mixedWith(ColorUtil.RGBColor.fromCss(backgroundColor), 0.02, 1);

    s_colors = new EditorThemeListener.Colors(foregroundColor, backgroundColor, border, highlight.asRgb(),
            surface.asRgb());//from   w  w  w.  j  a v  a2 s  .c  om
}