Search in sources :

Example 26 with JsArrayString

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

the class PaneLayoutPreferencesPane method onApply.

@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);
        JsArrayString tabSet2 = JsArrayString.createArray().cast();
        for (String tab : tabSet2ModuleList_.getValue()) tabSet2.push(tab);
        // Determine implicit preference for console top/bottom location
        // This needs to be saved so that when the user executes the 
        // Console on Left/Right commands we know whether to position 
        // the Console on the Top or Bottom
        PaneConfig prevConfig = uiPrefs_.paneConfig().getGlobalValue();
        boolean consoleLeftOnTop = prevConfig.getConsoleLeftOnTop();
        boolean consoleRightOnTop = prevConfig.getConsoleRightOnTop();
        final String kConsole = "Console";
        if (panes.get(0).equals(kConsole))
            consoleLeftOnTop = true;
        else if (panes.get(1).equals(kConsole))
            consoleLeftOnTop = false;
        else if (panes.get(2).equals(kConsole))
            consoleRightOnTop = true;
        else if (panes.get(3).equals(kConsole))
            consoleRightOnTop = false;
        uiPrefs_.paneConfig().setGlobalValue(PaneConfig.create(panes, tabSet1, tabSet2, consoleLeftOnTop, consoleRightOnTop));
        dirty_ = false;
    }
    return restartRequired;
}
Also used : PaneConfig(org.rstudio.studio.client.workbench.ui.PaneConfig) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 27 with JsArrayString

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

the class ClientState method putStrings.

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

Example 28 with JsArrayString

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

the class AceCommandManager method getRelevantCommands.

public final JsArray<AceCommand> getRelevantCommands() {
    JsObject allCommands = getCommands();
    JsArray<AceCommand> filtered = JavaScriptObject.createArray().cast();
    JsArrayString keys = allCommands.keys();
    for (String key : JsUtil.asIterable(keys)) {
        AceCommand command = allCommands.getObject(key);
        String name = command.getInternalName();
        if (!EXCLUDED_COMMANDS_MAP.hasKey(name)) {
            filtered.push(command);
        }
    }
    return sorted(filtered);
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 29 with JsArrayString

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

the class ChunkContextUi method switchChunk.

@Override
public void switchChunk(String chunkType) {
    if (chunk_ != null) {
        DocDisplay docDisplay = target_.getDocDisplay();
        Position start = chunk_.getPreamble();
        Position end = chunk_.getEnd();
        String chunkText = docDisplay.getTextForRange(Range.fromPoints(start, end));
        JsArrayString chunkLines = StringUtil.split(chunkText, "\n");
        if (chunkLines.length() > 0) {
            String firstLine = chunkLines.get(0);
            Position linedEnd = Position.create(start.getRow(), firstLine.length());
            String newFirstLine = firstLine.replaceFirst("[, ]*engine='[a-zA-Z]+'", "");
            newFirstLine = newFirstLine.replaceFirst("{[a-zA-Z]+", "{" + chunkType);
            docDisplay.replaceRange(Range.fromPoints(start, linedEnd), newFirstLine);
            target_.getNotebook().clearChunkOutput(chunk_);
        }
    }
}
Also used : Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) DocDisplay(org.rstudio.studio.client.workbench.views.source.editors.text.DocDisplay) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 30 with JsArrayString

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

the class TextEditingTargetRenameHelper method pushProtectedNames.

private void pushProtectedNames(Position position, Scope parentScope) {
    protectedNamesList_.add(new HashSet<String>());
    Scope scope = editor_.getScopeAtPosition(position);
    if (scope.isFunction() && scope != parentScope) {
        JsArrayString argNames = ((ScopeFunction) scope).getFunctionArgs();
        for (int i = 0; i < argNames.length(); i++) addProtectedName(argNames.get(i));
    }
}
Also used : 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