use of org.rstudio.studio.client.rmarkdown.model.RmdOutputInfo in project rstudio by rstudio.
the class RSConnectPublishButton method renderThenPublish.
// for static content only: perform a just-in-time render if necessary and
// then publish the content
private void renderThenPublish(final String target, final RSConnectDeploymentRecord previous) {
// prevent re-entrancy
if (rmdInfoPending_)
return;
final Command renderCommand = new Command() {
@Override
public void execute() {
publishAfterRmdRender_ = previous;
rmdRenderPending_ = true;
anyRmdRenderPending_ = true;
if (commands_.knitDocument().isEnabled())
commands_.knitDocument().execute();
else if (commands_.previewHTML().isEnabled())
commands_.previewHTML().execute();
else
display_.showErrorMessage("Can't Render Document", "RStudio cannot render " + target + " for publishing.");
}
};
rmdInfoPending_ = true;
rmdServer_.getRmdOutputInfo(target, new ServerRequestCallback<RmdOutputInfo>() {
@Override
public void onResponseReceived(RmdOutputInfo response) {
if (response.isCurrent()) {
RenderedDocPreview preview = new RenderedDocPreview(target, response.getOutputFile(), true);
events_.fireEvent(RSConnectActionEvent.DeployDocEvent(preview, RSConnect.CONTENT_TYPE_DOCUMENT, previous));
} else {
renderCommand.execute();
}
rmdInfoPending_ = false;
}
@Override
public void onError(ServerError error) {
// if we failed to figure out whether we need to do a re-render,
// assume one is necessary
Debug.logError(error);
renderCommand.execute();
rmdInfoPending_ = false;
}
});
}
Aggregations