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;
}
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;
}
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;
}
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);
}
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.");
}
}
Aggregations