use of org.rstudio.studio.client.rmarkdown.model.RmdCreatedTemplate in project rstudio by rstudio.
the class TextEditingTargetRMarkdownHelper method createDraftFromTemplate.
private void createDraftFromTemplate(final RmdChosenTemplate template, final String target) {
final ProgressIndicator progress = new GlobalProgressDelayer(globalDisplay_, 250, "Creating R Markdown Document...").getIndicator();
server_.createRmdFromTemplate(target, template.getTemplatePath(), template.createDir(), new ServerRequestCallback<RmdCreatedTemplate>() {
@Override
public void onResponseReceived(RmdCreatedTemplate created) {
// write a pref indicating this is the preferred template--
// we'll default to it the next time we load the template list
prefs_.rmdPreferredTemplatePath().setGlobalValue(template.getTemplatePath());
prefs_.writeUIPrefs();
FileSystemItem file = FileSystemItem.createFile(created.getPath());
eventBus_.fireEvent(new FileEditEvent(file));
progress.onCompleted();
}
@Override
public void onError(ServerError error) {
progress.onError("Couldn't create a template from " + template.getTemplatePath() + " at " + target + ".\n\n" + error.getMessage());
}
});
}
Aggregations