use of org.rstudio.studio.client.notebook.CompileNotebookOptions in project rstudio by rstudio.
the class TextEditingTarget method generateNotebook.
private void generateNotebook(final Command executeOnSuccess) {
// default title
String defaultTitle = docUpdateSentinel_.getProperty(NOTEBOOK_TITLE);
if (StringUtil.isNullOrEmpty(defaultTitle))
defaultTitle = FileSystemItem.getNameFromPath(docUpdateSentinel_.getPath());
// default author
String defaultAuthor = docUpdateSentinel_.getProperty(NOTEBOOK_AUTHOR);
if (StringUtil.isNullOrEmpty(defaultAuthor)) {
defaultAuthor = prefs_.compileNotebookOptions().getValue().getAuthor();
if (StringUtil.isNullOrEmpty(defaultAuthor))
defaultAuthor = session_.getSessionInfo().getUserIdentity();
}
// default type
String defaultType = docUpdateSentinel_.getProperty(NOTEBOOK_TYPE);
if (StringUtil.isNullOrEmpty(defaultType)) {
defaultType = prefs_.compileNotebookOptions().getValue().getType();
if (StringUtil.isNullOrEmpty(defaultType))
defaultType = CompileNotebookOptions.TYPE_DEFAULT;
}
CompileNotebookOptionsDialog dialog = new CompileNotebookOptionsDialog(getId(), defaultTitle, defaultAuthor, defaultType, new OperationWithInput<CompileNotebookOptions>() {
@Override
public void execute(CompileNotebookOptions input) {
server_.createNotebook(input, new SimpleRequestCallback<CompileNotebookResult>() {
@Override
public void onResponseReceived(CompileNotebookResult response) {
if (response.getSucceeded()) {
executeOnSuccess.execute();
} else {
globalDisplay_.showErrorMessage("Unable to Compile Report", response.getFailureMessage());
}
}
});
// save options for this document
HashMap<String, String> changedProperties = new HashMap<String, String>();
changedProperties.put(NOTEBOOK_TITLE, input.getNotebookTitle());
changedProperties.put(NOTEBOOK_AUTHOR, input.getNotebookAuthor());
changedProperties.put(NOTEBOOK_TYPE, input.getNotebookType());
docUpdateSentinel_.modifyProperties(changedProperties, null);
// save global prefs
CompileNotebookPrefs prefs = CompileNotebookPrefs.create(input.getNotebookAuthor(), input.getNotebookType());
if (!CompileNotebookPrefs.areEqual(prefs, prefs_.compileNotebookOptions().getValue())) {
prefs_.compileNotebookOptions().setGlobalValue(prefs);
prefs_.writeUIPrefs();
}
}
});
dialog.showModal();
}
Aggregations