Search in sources :

Example 1 with RenderedDocPreview

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;
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) ServerError(org.rstudio.studio.client.server.ServerError) RmdOutputInfo(org.rstudio.studio.client.rmarkdown.model.RmdOutputInfo) RenderedDocPreview(org.rstudio.studio.client.rsconnect.model.RenderedDocPreview)

Example 2 with RenderedDocPreview

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();
}
Also used : RenderedDocPreview(org.rstudio.studio.client.rsconnect.model.RenderedDocPreview)

Example 3 with RenderedDocPreview

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();
}
Also used : SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) RenderedDocPreview(org.rstudio.studio.client.rsconnect.model.RenderedDocPreview)

Example 4 with RenderedDocPreview

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();
    }
}
Also used : RenderedDocPreview(org.rstudio.studio.client.rsconnect.model.RenderedDocPreview)

Aggregations

RenderedDocPreview (org.rstudio.studio.client.rsconnect.model.RenderedDocPreview)4 Command (com.google.gwt.user.client.Command)1 AppCommand (org.rstudio.core.client.command.AppCommand)1 RmdOutputInfo (org.rstudio.studio.client.rmarkdown.model.RmdOutputInfo)1 ServerError (org.rstudio.studio.client.server.ServerError)1 SessionInfo (org.rstudio.studio.client.workbench.model.SessionInfo)1