use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class TextEditingTarget method postSaveCommand.
private Command postSaveCommand() {
return new Command() {
public void execute() {
// fire source document saved event
FileSystemItem file = FileSystemItem.createFile(docUpdateSentinel_.getPath());
events_.fireEvent(new SourceFileSaveCompletedEvent(file, docUpdateSentinel_.getContents(), docDisplay_.getCursorPosition()));
// check for source on save
if (fileType_.canSourceOnSave() && docUpdateSentinel_.sourceOnSave()) {
if (fileType_.isRd()) {
previewRd();
} else if (fileType_.canPreviewFromR()) {
previewFromR();
} else {
if (docDisplay_.hasBreakpoints()) {
hideBreakpointWarningBar();
}
consoleDispatcher_.executeSourceCommand(docUpdateSentinel_.getPath(), fileType_, docUpdateSentinel_.getEncoding(), activeCodeIsAscii(), false, false, docDisplay_.hasBreakpoints());
}
}
}
};
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class TextEditingTargetCompilePdfHelper method getTargetFile.
public FileSystemItem getTargetFile(FileSystemItem editorFile) {
ArrayList<TexMagicComment> magicComments = TexMagicComment.parseComments(docDisplay_.getCode());
String root = StringUtil.notNull(detectRootDirective(magicComments));
if (root.length() > 0) {
return FileSystemItem.createFile(editorFile.getParentPath().completePath(root));
} else {
String rootPref = prefs_.rootDocument().getValue();
if (rootPref.length() > 0) {
FileSystemItem projDir = session_.getSessionInfo().getActiveProjectDir();
if (projDir != null)
return FileSystemItem.createFile(projDir.completePath(rootPref));
else
return editorFile;
} else {
return editorFile;
}
}
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class TextEditingTargetRMarkdownHelper method getKnitWorkingDir.
public String getKnitWorkingDir(DocUpdateSentinel sourceDoc) {
// shortcut if we don't support manually specified working directories
if (!session_.getSessionInfo().getKnitWorkingDirAvailable())
return null;
// compute desired working directory type
String workingDirType = sourceDoc.getProperty(RenderRmdEvent.WORKING_DIR_PROP, prefs_.knitWorkingDir().getValue());
String workingDir = null;
if (workingDirType == UIPrefsAccessor.KNIT_DIR_PROJECT) {
// get the project directory, but if we don't have one (e.g. no
// project) use the default working directory for the session
FileSystemItem projectDir = session_.getSessionInfo().getActiveProjectDir();
if (projectDir != null)
workingDir = projectDir.getPath();
if (StringUtil.isNullOrEmpty(workingDir))
workingDir = session_.getSessionInfo().getDefaultWorkingDir();
} else if (workingDirType == UIPrefsAccessor.KNIT_DIR_CURRENT) {
workingDir = workbenchContext_.getCurrentWorkingDir().getPath();
}
return workingDir;
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class TextEditingTargetRMarkdownHelper method getRMarkdownParamsFile.
public void getRMarkdownParamsFile(final String file, final String encoding, final boolean contentKnownToBeAscii, final CommandWithArg<String> onReady) {
// can't do this if the server is already busy
if (workbenchContext_.isServerBusy()) {
globalDisplay_.showMessage(MessageDisplay.MSG_WARNING, "R Session Busy", "Unable to edit parameters (the R session is currently busy).");
return;
}
// meet all dependencies then ask for params
final String action = "Specifying Knit parameters";
dependencyManager_.withRMarkdown(action, new Command() {
@Override
public void execute() {
dependencyManager_.withShiny(action, new Command() {
@Override
public void execute() {
// subscribe to notification of params ready
// (ensure only one handler at a time is sucscribed)
rmdParamsReadyUnsubscribe();
rmdParamsReadyRegistration_ = eventBus_.addHandler(RmdParamsReadyEvent.TYPE, new RmdParamsReadyEvent.Handler() {
@Override
public void onRmdParamsReady(RmdParamsReadyEvent e) {
rmdParamsReadyUnsubscribe();
onReady.execute(e.getParamsFile());
}
});
// execute knit_with_parameters in the console
FileSystemItem targetFile = FileSystemItem.createFile(file);
consoleDispatcher_.executeCommandWithFileEncoding("knit_with_parameters", targetFile.getPath(), encoding, contentKnownToBeAscii);
}
});
}
});
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class TextEditingTarget method doSynctexSearch.
private void doSynctexSearch(boolean fromClick) {
SourceLocation sourceLocation = getSelectionAsSourceLocation(fromClick);
if (sourceLocation == null)
return;
// compute the target pdf
FileSystemItem editorFile = FileSystemItem.createFile(docUpdateSentinel_.getPath());
FileSystemItem targetFile = compilePdfHelper_.getTargetFile(editorFile);
String pdfFile = targetFile.getParentPath().completePath(targetFile.getStem() + ".pdf");
synctex_.forwardSearch(pdfFile, sourceLocation);
}
Aggregations