Пример #1
0
 @Override
 public void onRmdRenderCompleted(RmdRenderCompletedEvent event) {
   // ensure we got a result--note that even a cancelled render generates an
   // event, but with an empty output file
   if (rmdRenderPending_
       && event.getResult() != null
       && !StringUtil.isNullOrEmpty(event.getResult().getOutputFile())) {
     RenderedDocPreview docPreview = new RenderedDocPreview(event.getResult());
     events_.fireEvent(
         RSConnectActionEvent.DeployDocEvent(
             docPreview,
             event.getResult().isWebsite()
                 ? RSConnect.CONTENT_TYPE_WEBSITE
                 : RSConnect.CONTENT_TYPE_DOCUMENT,
             publishAfterRmdRender_));
   }
   publishAfterRmdRender_ = null;
   rmdRenderPending_ = false;
   anyRmdRenderPending_ = false;
 }
Пример #2
0
 private void onPublishRecordClick(final RSConnectDeploymentRecord previous) {
   switch (contentType_) {
     case RSConnect.CONTENT_TYPE_HTML:
     case RSConnect.CONTENT_TYPE_PRES:
       if (publishHtmlSource_ == null) {
         display_.showErrorMessage(
             "Content Publish Failed", "No HTML could be generated for the content.");
         return;
       }
       publishHtmlSource_.generatePublishHtml(
           new CommandWithArg<String>() {
             @Override
             public void execute(String arg) {
               events_.fireEvent(
                   RSConnectActionEvent.DeployHtmlEvent(
                       contentType_, contentPath_, arg, publishHtmlSource_.getTitle(), previous));
             }
           });
       break;
     case RSConnect.CONTENT_TYPE_PLOT:
       // for plots, we need to generate the hosting HTML prior to publishing
       if (publishHtmlSource_ != null) {
         publishHtmlSource_.generatePublishHtml(
             new CommandWithArg<String>() {
               @Override
               public void execute(String htmlFile) {
                 events_.fireEvent(RSConnectActionEvent.DeployPlotEvent(htmlFile, previous));
               }
             });
       }
       break;
     case RSConnect.CONTENT_TYPE_APP:
     case RSConnect.CONTENT_TYPE_APP_SINGLE:
       // Shiny application
       events_.fireEvent(
           RSConnectActionEvent.DeployAppEvent(contentPath_, contentType_, previous));
       break;
     case RSConnect.CONTENT_TYPE_DOCUMENT:
       if (docPreview_ == null
           || (docPreview_.isStatic()
               && StringUtil.isNullOrEmpty(docPreview_.getOutputFile())
               && docPreview_.getSourceFile() != null)) {
         // if the doc has been saved but not been rendered, go render it and
         // come back when we're finished
         renderThenPublish(contentPath_, previous);
       } else {
         // All R Markdown variants (single/multiple and static/Shiny)
         if (docPreview_.getSourceFile() == null) {
           display_.showErrorMessage(
               "Unsaved Document",
               "Unsaved documents cannot be published. Save the document "
                   + "before publishing it.");
           break;
         }
         events_.fireEvent(
             RSConnectActionEvent.DeployDocEvent(
                 docPreview_, RSConnect.CONTENT_TYPE_DOCUMENT, previous));
       }
       break;
     case RSConnect.CONTENT_TYPE_WEBSITE:
       events_.fireEvent(
           RSConnectActionEvent.DeployDocEvent(
               docPreview_, RSConnect.CONTENT_TYPE_WEBSITE, previous));
       break;
     default:
       // should never happen
       display_.showErrorMessage(
           "Can't Publish " + RSConnect.contentTypeDesc(contentType_),
           "The content type '"
               + RSConnect.contentTypeDesc(contentType_)
               + "' is not currently supported for publishing.");
   }
 }