use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class TextEditingTarget method onClearPrerenderedOutput.
@Handler
void onClearPrerenderedOutput() {
withSavedDoc(new Command() {
@Override
public void execute() {
// determine the output path (use relative path if possible)
String path = docUpdateSentinel_.getPath();
String relativePath = FileSystemItem.createFile(path).getPathRelativeTo(workbenchContext_.getCurrentWorkingDir());
if (relativePath != null)
path = relativePath;
final String docPath = path;
globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Clear Prerendered Output", "This will remove all previously generated output " + "for " + docPath + " (html, prerendered data, knitr cache, etc.)." + "\n\nAre you sure you want to clear the output now?", false, new Operation() {
@Override
public void execute() {
String code = "rmarkdown::shiny_prerendered_clean(" + ConsoleDispatcher.escapedPath(docPath) + ")";
events_.fireEvent(new SendToConsoleEvent(code, true));
}
}, null, true);
}
});
}
use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class TextEditingTarget method onPreviewHTML.
@Handler
void onPreviewHTML() {
// last ditch extended type detection
String extendedType = extendedType_;
extendedType = rmarkdownHelper_.detectExtendedType(docDisplay_.getCode(), extendedType, fileType_);
if (extendedType == SourceDocument.XT_RMARKDOWN) {
renderRmd();
} else if (fileType_.isRd())
previewRd();
else if (fileType_.isRpres())
previewRpresentation();
else if (fileType_.isR())
onCompileNotebook();
else
previewHTML();
}
use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class TextEditingTarget method onFoldAll.
@Handler
void onFoldAll() {
if (useScopeTreeFolding()) {
// Fold all except anonymous braces
HashSet<Integer> rowsFolded = new HashSet<Integer>();
for (AceFold f : JsUtil.asIterable(docDisplay_.getFolds())) rowsFolded.add(f.getStart().getRow());
ScopeList scopeList = new ScopeList(docDisplay_);
scopeList.removeAll(ScopeList.ANON_BRACE);
for (Scope scope : scopeList) {
int row = scope.getFoldStart().getRow();
if (!rowsFolded.contains(row))
docDisplay_.addFoldFromRow(row);
}
} else {
docDisplay_.foldAll();
}
}
use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class TextEditingTarget method onClearKnitrCache.
@Handler
void onClearKnitrCache() {
withSavedDoc(new Command() {
@Override
public void execute() {
// determine the cache path (use relative path if possible)
String path = docUpdateSentinel_.getPath();
FileSystemItem fsi = FileSystemItem.createFile(path);
path = fsi.getParentPath().completePath(fsi.getStem() + "_cache");
String relativePath = FileSystemItem.createFile(path).getPathRelativeTo(workbenchContext_.getCurrentWorkingDir());
if (relativePath != null)
path = relativePath;
final String docPath = path;
globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Clear Knitr Cache", "Clearing the Knitr cache will delete the cache " + "directory for " + docPath + ". " + "\n\nAre you sure you want to clear the cache now?", false, new Operation() {
@Override
public void execute() {
String code = "unlink(" + ConsoleDispatcher.escapedPath(docPath) + ", recursive = TRUE)";
events_.fireEvent(new SendToConsoleEvent(code, true));
}
}, null, true);
}
});
}
use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.
the class TextEditingTarget method onGoToEndOfCurrentScope.
@Handler
void onGoToEndOfCurrentScope() {
docDisplay_.focus();
Scope scope = docDisplay_.getCurrentScope();
if (scope != null) {
Position end = scope.getEnd();
if (end != null) {
Position position = Position.create(end.getRow(), Math.max(0, end.getColumn() - 1));
docDisplay_.setCursorPosition(position);
}
}
}
Aggregations