Search in sources :

Example 1 with ConvertToShinyDocEvent

use of org.rstudio.studio.client.rmarkdown.events.ConvertToShinyDocEvent in project rstudio by rstudio.

the class RmdOutput method onRmdRenderCompleted.

@Override
public void onRmdRenderCompleted(RmdRenderCompletedEvent event) {
    renderInProgress_ = false;
    // that instead
    if (onRenderCompleted_ != null) {
        onRenderCompleted_.execute();
        onRenderCompleted_ = null;
        return;
    }
    // ignore failures and completed Shiny docs (the latter are handled when
    // the server starts rather than when the render process is finished)
    final RmdRenderResult result = event.getResult();
    if (result.isShinyDocument()) {
        shinyDoc_ = null;
        return;
    }
    if (result.hasShinyContent() && !result.isShinyDocument()) {
        // If the result has Shiny content but wasn't rendered as a Shiny
        // document, suggest rendering as a Shiny document instead
        new ShinyDocumentWarningDialog(new OperationWithInput<Integer>() {

            @Override
            public void execute(Integer input) {
                switch(input) {
                    case ShinyDocumentWarningDialog.RENDER_SHINY_NO:
                        if (result.getSucceeded())
                            displayRenderResult(result);
                        break;
                    case ShinyDocumentWarningDialog.RENDER_SHINY_ONCE:
                        rerenderAsShiny(result);
                        break;
                    case ShinyDocumentWarningDialog.RENDER_SHINY_ALWAYS:
                        events_.fireEvent(new ConvertToShinyDocEvent(result.getTargetFile()));
                        break;
                }
            }
        }).showModal();
    } else if (result.getSucceeded()) {
        displayRenderResult(event.getResult());
    }
}
Also used : ShinyDocumentWarningDialog(org.rstudio.studio.client.rmarkdown.ui.ShinyDocumentWarningDialog) OperationWithInput(org.rstudio.core.client.widget.OperationWithInput) ConvertToShinyDocEvent(org.rstudio.studio.client.rmarkdown.events.ConvertToShinyDocEvent) RmdRenderResult(org.rstudio.studio.client.rmarkdown.model.RmdRenderResult)

Aggregations

OperationWithInput (org.rstudio.core.client.widget.OperationWithInput)1 ConvertToShinyDocEvent (org.rstudio.studio.client.rmarkdown.events.ConvertToShinyDocEvent)1 RmdRenderResult (org.rstudio.studio.client.rmarkdown.model.RmdRenderResult)1 ShinyDocumentWarningDialog (org.rstudio.studio.client.rmarkdown.ui.ShinyDocumentWarningDialog)1