use of org.rstudio.studio.client.rsconnect.model.RenderedDocPreview 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;
}
});
}
use of org.rstudio.studio.client.rsconnect.model.RenderedDocPreview in project rstudio by rstudio.
the class RSConnectPublishButton method setRmdPreview.
public void setRmdPreview(RmdPreviewParams params) {
if (params.isShinyDocument() || (params.getResult().isHtml() && params.getResult().getFormat() != null)) {
setContentType(params.isWebsiteRmd() ? RSConnect.CONTENT_TYPE_WEBSITE : RSConnect.CONTENT_TYPE_DOCUMENT);
docPreview_ = new RenderedDocPreview(params);
setContentPath(params.getResult().getTargetFile(), params.getOutputFile());
} else {
docPreview_ = null;
}
applyVisiblity();
}
use of org.rstudio.studio.client.rsconnect.model.RenderedDocPreview in project rstudio by rstudio.
the class RSConnectPublishButton method setRmd.
public void setRmd(String rmd, boolean isStatic) {
docPreview_ = new RenderedDocPreview(rmd, "", isStatic);
setContentPath(rmd, "");
SessionInfo sessionInfo = session_.getSessionInfo();
String buildType = sessionInfo.getBuildToolsType();
boolean setType = false;
if (buildType.equals(SessionInfo.BUILD_TOOLS_WEBSITE)) {
// if this is an Rmd with a content path
if (contentType_ == RSConnect.CONTENT_TYPE_DOCUMENT && !StringUtil.isNullOrEmpty(contentPath_)) {
// ...and if the content path is within the website dir,
String websiteDir = sessionInfo.getBuildTargetDir();
if (contentPath_.startsWith(websiteDir)) {
setType = true;
setContentType(RSConnect.CONTENT_TYPE_WEBSITE);
}
}
}
// if we haven't set the type yet, apply it
if (!setType)
setContentType(RSConnect.CONTENT_TYPE_DOCUMENT);
applyVisiblity();
}
use of org.rstudio.studio.client.rsconnect.model.RenderedDocPreview in project rstudio by rstudio.
the class RSConnectPublishButton method setHtmlPreview.
public void setHtmlPreview(HTMLPreviewResult params) {
if (params.getSucceeded()) {
setContentPath(params.getSourceFile(), params.getHtmlFile());
docPreview_ = new RenderedDocPreview(params);
applyVisiblity();
}
}
Aggregations