use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.
the class AceCommandManager method rebindCommand.
public final void rebindCommand(String id, List<KeySequence> keys) {
JsArrayString shortcuts = JavaScriptObject.createArray().cast();
for (KeySequence ks : keys) shortcuts.push(toAceStyleShortcutString(ks));
rebindCommand(id, shortcuts);
}
use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.
the class SetupChunkOptionsPopupPanel method getChunkText.
private String getChunkText() {
int chunkStart = position_.getRow();
int chunkEnd = findEndOfChunk();
JsArrayString chunkText = display_.getLines(chunkStart + 1, chunkEnd - 1);
return chunkText.join("\n");
}
use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.
the class CheckSpelling method handleMisspelledWord.
private void handleMisspelledWord(Range range) {
try {
docDisplay_.setSelectionRange(range);
docDisplay_.moveCursorNearTop();
view_.clearSuggestions();
view_.getReplacement().setText("");
final String word = docDisplay_.getTextForRange(range);
if (changeAll_.containsKey(word)) {
doReplacement(changeAll_.get(word));
findNextMisspelling();
return;
}
view_.getMisspelledWord().setText(word);
// This fixed delay is regrettable but necessary as it can take some
// time for Ace's scrolling logic to actually execute (i.e. the next
// time the renderloop runs). If we don't wait, then misspelled words
// at the end of the document will result in misreported cursor bounds,
// meaning we'll be avoiding a completely incorrect region.
Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
@Override
public boolean execute() {
showDialog(docDisplay_.getCursorBounds());
view_.focusReplacement();
spellChecker_.suggestionList(word, new ServerRequestCallback<JsArrayString>() {
@Override
public void onResponseReceived(JsArrayString response) {
String[] suggestions = JsUtil.toStringArray(response);
view_.setSuggestions(suggestions);
if (suggestions.length > 0) {
view_.getReplacement().setText(suggestions[0]);
view_.focusReplacement();
}
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
}
});
return false;
}
}, 100);
} catch (Exception e) {
Debug.log(e.toString());
close();
RStudioGinjector.INSTANCE.getGlobalDisplay().showErrorMessage("Check Spelling", "An error has occurred:\n\n" + e.getMessage());
callback_.onFailure(e);
}
}
use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.
the class ChooseEncodingDialog method setEncodings.
private void setEncodings(JsArrayString encodings, String encoding) {
listBox_.clear();
for (int i = 0; i < encodings.length(); i++) {
listBox_.addItem(encodings.get(i));
}
int sysIndex = findSystemEncodingIndex();
if (!StringUtil.isNullOrEmpty(systemEncoding_)) {
// Remove the system encoding (if it is present) so we can move it
// to the top of the list. If it's already present, use the same
// label (un-normalized encoding name) so it's consistent with
// related encodings that are also present in the list.
String sysEncName = sysIndex < 0 ? systemEncoding_ : listBox_.getValue(sysIndex);
if (sysIndex >= 0)
listBox_.removeItem(sysIndex);
listBox_.insertItem(sysEncName + " (System default)", systemEncoding_, 0);
}
if (includePromptForEncoding_) {
listBox_.insertItem(ASK_LABEL, "", 0);
}
if (isSystemEncoding(encoding))
setCurrentValue(listBox_.getValue(includePromptForEncoding_ ? 1 : 0));
else
setCurrentValue(encoding);
}
use of com.google.gwt.core.client.JsArrayString in project rstudio by rstudio.
the class RnwChunkOptions method completeValue.
private void completeValue(RnwWeave rnwWeave, String name, String value, JsArrayString completions) {
String optionType = StringUtil.notNull(this.getOptionType(name));
if (optionType.equals("logical")) {
CompletionOptions options = new CompletionOptions();
options.addOption("TRUE", 0);
options.addOption("FALSE", 0);
if (!rnwWeave.usesCodeForOptions()) {
// Legacy Sweave is case insensitive
options.addOption("true", 1);
options.addOption("false", 1);
options.addOption("True", 2);
options.addOption("False", 2);
}
for (String logical : options.getCompletions(value)) completions.push(logical);
} else if (optionType.equals("list")) {
CompletionOptions options = new CompletionOptions();
ArrayList<String> optionValues = this.getOptionValues(name);
if (!rnwWeave.usesCodeForOptions()) {
// Legacy Sweave
for (String optionVal : optionValues) options.addOption(optionVal, 0);
} else {
for (String optionVal : optionValues) options.addOption("'" + optionVal + "'", 0);
for (String optionVal : optionValues) options.addOption('"' + optionVal + '"', 1);
}
for (String option : options.getCompletions(value)) completions.push(option);
}
}
Aggregations