Search in sources :

Example 11 with JsArrayString

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

the class PaneConfig method validateAndAutoCorrect.

public final boolean validateAndAutoCorrect() {
    JsArrayString panes = getPanes();
    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);
    // last one in the tabset.
    if (!ts1.get(ts1.length() - 1).equals("Presentation")) {
        Debug.logToConsole("Invaliding tabset config (Presentation index)");
        return false;
    }
    // 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))
            // unknown tab
            return false;
    }
    // If any baseTabs are still present, they weren't part of the tabsets
    if (baseTabs.size() > 0)
        return false;
    // 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;
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 12 with JsArrayString

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

the class PaneManager method createPanes.

private ArrayList<LogicalWindow> createPanes(PaneConfig config) {
    ArrayList<LogicalWindow> results = new ArrayList<LogicalWindow>();
    JsArrayString panes = config.getPanes();
    for (int i = 0; i < 4; i++) {
        results.add(panesByName_.get(panes.get(i)));
    }
    return results;
}
Also used : LogicalWindow(org.rstudio.core.client.layout.LogicalWindow) ArrayList(java.util.ArrayList) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 13 with JsArrayString

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

the class RoxygenHelper method listParametersInRoxygenBlock.

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

Example 14 with JsArrayString

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

the class RoxygenHelper method insertRoxygenTemplate.

private void insertRoxygenTemplate(String name, JsArrayString argNames, JsArrayString argTypes, String argTagName, String type, Position position) {
    String roxygenParams = argsToExampleRoxygen(argNames, argTypes, argTagName);
    // if there were one or more arguments.
    if (argNames.length() != 0)
        roxygenParams += "\n#'\n";
    String block = "#' Title\n" + "#'\n" + roxygenParams + "#' @return\n" + "#' @export\n" + "#'\n" + "#' @examples\n";
    Position insertionPosition = Position.create(position.getRow(), 0);
    editor_.insertCode(insertionPosition, block);
}
Also used : Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 15 with JsArrayString

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

the class DesktopApplicationHeader method respondToUpdateCheck.

private void respondToUpdateCheck(final UpdateCheckResult result, boolean manual) {
    boolean ignoredUpdate = false;
    if (result.getUpdateVersion().length() > 0) {
        JsArrayString ignoredUpdates = ignoredUpdates_.getIgnoredUpdates();
        for (int i = 0; i < ignoredUpdates.length(); i++) {
            if (ignoredUpdates.get(i).equals(result.getUpdateVersion())) {
                ignoredUpdate = true;
            }
        }
    }
    if (result.getUpdateVersion().length() > 0 && !ignoredUpdate) {
        ArrayList<String> buttonLabels = new ArrayList<String>();
        ArrayList<Operation> buttonOperations = new ArrayList<Operation>();
        buttonLabels.add("Quit and Download...");
        buttonOperations.add(new Operation() {

            @Override
            public void execute() {
                appQuit_.prepareForQuit("Update RStudio", new QuitContext() {

                    @Override
                    public void onReadyToQuit(boolean saveChanges) {
                        Desktop.getFrame().browseUrl(result.getUpdateUrl());
                        appQuit_.performQuit(saveChanges);
                    }
                });
            }
        });
        buttonLabels.add("Remind Later");
        buttonOperations.add(new Operation() {

            @Override
            public void execute() {
            // Don't do anything here; the prompt will re-appear the next
            // time we do an update check
            }
        });
        // Only provide the option to ignore the update if it's not urgent.
        if (result.getUpdateUrgency() == 0) {
            buttonLabels.add("Ignore Update");
            buttonOperations.add(new Operation() {

                @Override
                public void execute() {
                    ignoredUpdates_.addIgnoredUpdate(result.getUpdateVersion());
                    ignoredUpdatesDirty_ = true;
                }
            });
        }
        globalDisplay_.showGenericDialog(GlobalDisplay.MSG_QUESTION, "Update Available", result.getUpdateMessage(), buttonLabels, buttonOperations, 0);
    } else if (manual) {
        globalDisplay_.showMessage(GlobalDisplay.MSG_INFO, "No Update Available", "You're using the newest version of RStudio.");
    }
}
Also used : QuitContext(org.rstudio.studio.client.application.ApplicationQuit.QuitContext) ArrayList(java.util.ArrayList) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) Operation(org.rstudio.core.client.widget.Operation)

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