use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class TextEditingTarget method isPackageDocumentationFile.
private boolean isPackageDocumentationFile() {
if (getPath() == null) {
return false;
}
String type = session_.getSessionInfo().getBuildToolsType();
if (!type.equals(SessionInfo.BUILD_TOOLS_PACKAGE)) {
return false;
}
FileSystemItem srcFile = FileSystemItem.createFile(getPath());
FileSystemItem projectDir = session_.getSessionInfo().getActiveProjectDir();
if (srcFile.getPath().startsWith(projectDir.getPath() + "/vignettes"))
return true;
else if (srcFile.getParentPathString().equals(projectDir.getPath()) && srcFile.getExtension().toLowerCase().equals(".md"))
return true;
else
return false;
}
use of org.rstudio.core.client.files.FileSystemItem 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.files.FileSystemItem in project rstudio by rstudio.
the class TextEditingTarget method fireCompilePdfEvent.
private void fireCompilePdfEvent(String path, String encoding, String completedAction, boolean useInternalPreview) {
// first validate the path to make sure it doesn't contain spaces
FileSystemItem file = FileSystemItem.createFile(path);
if (file.getName().indexOf(' ') != -1) {
globalDisplay_.showErrorMessage("Invalid Filename", "The file '" + file.getName() + "' cannot be compiled to " + "a PDF because TeX does not understand paths with spaces. " + "If you rename the file to remove spaces then " + "PDF compilation will work correctly.");
return;
}
CompilePdfEvent event = new CompilePdfEvent(compilePdfHelper_.getTargetFile(file), encoding, getSelectionAsSourceLocation(false), completedAction, useInternalPreview);
events_.fireEvent(event);
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class ViewerPresenter method onViewerSaveAsImage.
@Handler
public void onViewerSaveAsImage() {
display_.bringToFront();
final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error");
indicator.onProgress("Preparing to export plot...");
// get the default directory
FileSystemItem defaultDir = ExportPlotUtils.getDefaultSaveDirectory(workbenchContext_.getCurrentWorkingDir());
// get context
server_.getViewerExportContext(defaultDir.getPath(), new SimpleRequestCallback<SavePlotAsImageContext>() {
@Override
public void onResponseReceived(SavePlotAsImageContext context) {
indicator.onCompleted();
new SaveViewerPlotAsImageDesktopDialog(globalDisplay_, display_.getUrl(), context, ExportPlotOptions.adaptToSize(pUIPrefs_.get().exportViewerOptions().getValue(), display_.getViewerFrameSize()), saveExportOptionsOperation_).showModal();
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
Aggregations