use of org.rstudio.studio.client.workbench.views.source.model.SourceDocumentResult in project rstudio by rstudio.
the class Source method openNotebook.
private void openNotebook(final FileSystemItem rnbFile, final TextFileType fileType, final ResultCallback<EditingTarget, ServerError> resultCallback) {
// construct path to .Rmd
final String rnbPath = rnbFile.getPath();
final String rmdPath = FilePathUtils.filePathSansExtension(rnbPath) + ".Rmd";
final FileSystemItem rmdFile = FileSystemItem.createFile(rmdPath);
// TODO: should we perform conflict resolution here as well?
if (openFileAlreadyOpen(rmdFile, resultCallback))
return;
// ask the server to extract the .Rmd, then open that
Command extractRmdCommand = new Command() {
@Override
public void execute() {
server_.extractRmdFromNotebook(rnbPath, new ServerRequestCallback<SourceDocumentResult>() {
@Override
public void onResponseReceived(SourceDocumentResult doc) {
openNotebook(rmdFile, doc, resultCallback);
}
@Override
public void onError(ServerError error) {
globalDisplay_.showErrorMessage("Notebook Open Failed", "This notebook could not be opened. \n\n" + error.getMessage());
resultCallback.onFailure(error);
}
});
}
};
dependencyManager_.withRMarkdown("R Notebook", "Using R Notebooks", extractRmdCommand);
}
Aggregations