use of org.rstudio.core.client.CsvReader in project rstudio by rstudio.
the class RequestLogVisualization method onPreviewNativeEvent.
public void onPreviewNativeEvent(NativePreviewEvent event) {
if (event.getTypeInt() == Event.ONKEYDOWN) {
int keyCode = event.getNativeEvent().getKeyCode();
if (keyCode == KeyCodes.KEY_ESCAPE) {
CloseEvent.fire(RequestLogVisualization.this, RequestLogVisualization.this);
handlerRegistration_.removeHandler();
} else if (keyCode == 'R' && KeyboardShortcut.getModifierValue(event.getNativeEvent()) == 0) {
refresh(true, true);
} else if (keyCode == 'P') {
if (timerIsRunning_)
timer_.cancel();
else {
timer_.run();
timer_.scheduleRepeating(PERIOD_MILLIS);
}
timerIsRunning_ = !timerIsRunning_;
} else if (keyCode == 'E') {
CsvWriter writer = new CsvWriter();
writer.writeValue(now_ + "");
writer.endLine();
for (RequestLogEntry entry : entries_) entry.toCsv(writer);
TextBoxDialog dialog = new TextBoxDialog("Export", writer.getValue(), null);
dialog.showModal();
} else if (keyCode == 'I') {
TextBoxDialog dialog = new TextBoxDialog("Import", "", new OperationWithInput<String>() {
public void execute(String input) {
CsvReader reader = new CsvReader(input);
ArrayList<RequestLogEntry> entries = new ArrayList<RequestLogEntry>();
Iterator<String[]> it = reader.iterator();
String now = it.next()[0];
while (it.hasNext()) {
String[] line = it.next();
RequestLogEntry entry = RequestLogEntry.fromValues(line);
if (entry != null)
entries.add(entry);
}
now_ = Long.parseLong(now);
entries_ = entries.toArray(new RequestLogEntry[0]);
refresh(false, true);
}
});
dialog.showModal();
}
} else if (event.getTypeInt() == Event.ONKEYPRESS) {
if (event.getNativeEvent().getKeyCode() == '+') {
scaleMillisToPixels_ *= 2.0;
refresh(false, false);
} else if (event.getNativeEvent().getKeyCode() == '-') {
scaleMillisToPixels_ /= 2.0;
refresh(false, false);
}
}
}
use of org.rstudio.core.client.CsvReader in project rstudio by rstudio.
the class TextEditingTargetSpelling method readDictionary.
@Override
public ArrayList<String> readDictionary() {
ArrayList<String> ignoredWords = new ArrayList<String>();
String ignored = docUpdateSentinel_.getProperty(IGNORED_WORDS);
if (ignored != null) {
Iterator<String[]> iterator = new CsvReader(ignored).iterator();
if (iterator.hasNext()) {
String[] words = iterator.next();
for (String word : words) ignoredWords.add(word);
}
}
return ignoredWords;
}
Aggregations