use of org.rstudio.studio.client.htmlpreview.events.ShowHTMLPreviewEvent in project rstudio by rstudio.
the class TextEditingTarget method doHtmlPreview.
private void doHtmlPreview(final Provider<HTMLPreviewParams> pParams) {
// command to show the preview window
final Command showPreviewWindowCommand = new Command() {
@Override
public void execute() {
HTMLPreviewParams params = pParams.get();
events_.fireEvent(new ShowHTMLPreviewEvent(params));
}
};
// command to run the preview
final Command runPreviewCommand = new Command() {
@Override
public void execute() {
final HTMLPreviewParams params = pParams.get();
server_.previewHTML(params, new SimpleRequestCallback<Boolean>());
}
};
if (pParams.get().isNotebook()) {
saveThenExecute(null, new Command() {
@Override
public void execute() {
generateNotebook(new Command() {
@Override
public void execute() {
showPreviewWindowCommand.execute();
runPreviewCommand.execute();
}
});
}
});
} else // due to popup activation rules but at least it will show up
if (isNewDoc()) {
saveThenExecute(null, CommandUtil.join(showPreviewWindowCommand, runPreviewCommand));
} else // beat the popup blockers) then save & run
if (dirtyState().getValue()) {
showPreviewWindowCommand.execute();
saveThenExecute(null, runPreviewCommand);
} else // otherwise show the preview window then run the preview
{
showPreviewWindowCommand.execute();
runPreviewCommand.execute();
}
}
Aggregations