Search in sources :

Example 1 with HTMLPreviewParams

use of org.rstudio.studio.client.htmlpreview.model.HTMLPreviewParams in project rstudio by rstudio.

the class HTMLPreviewApplicationWindow method onInitialize.

@Override
protected void onInitialize(LayoutPanel mainPanel, JavaScriptObject params) {
    Window.setTitle("RStudio: Preview HTML");
    // create the presenter and activate it with the passed params
    HTMLPreviewParams htmlPreviewParams = params.<HTMLPreviewParams>cast();
    presenter_ = pPresenter_.get();
    presenter_.onActivated(htmlPreviewParams);
    // enable command processing
    pDesktopHooks_.get();
    // make it fill the containing layout panel
    Widget presWidget = presenter_.asWidget();
    mainPanel.add(presWidget);
    mainPanel.setWidgetLeftRight(presWidget, 0, Unit.PX, 0, Unit.PX);
    mainPanel.setWidgetTopBottom(presWidget, 0, Unit.PX, 0, Unit.PX);
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) HTMLPreviewParams(org.rstudio.studio.client.htmlpreview.model.HTMLPreviewParams)

Example 2 with HTMLPreviewParams

use of org.rstudio.studio.client.htmlpreview.model.HTMLPreviewParams in project rstudio by rstudio.

the class TextEditingTarget method doHtmlPreview.

private void doHtmlPreview(final Provider<HTMLPreviewParams> pParams) {
    // command to show the preview window
    final Command showPreviewWindowCommand = new Command() {

        @Override
        public void execute() {
            HTMLPreviewParams params = pParams.get();
            events_.fireEvent(new ShowHTMLPreviewEvent(params));
        }
    };
    // command to run the preview
    final Command runPreviewCommand = new Command() {

        @Override
        public void execute() {
            final HTMLPreviewParams params = pParams.get();
            server_.previewHTML(params, new SimpleRequestCallback<Boolean>());
        }
    };
    if (pParams.get().isNotebook()) {
        saveThenExecute(null, new Command() {

            @Override
            public void execute() {
                generateNotebook(new Command() {

                    @Override
                    public void execute() {
                        showPreviewWindowCommand.execute();
                        runPreviewCommand.execute();
                    }
                });
            }
        });
    } else // due to popup activation rules but at least it will show up
    if (isNewDoc()) {
        saveThenExecute(null, CommandUtil.join(showPreviewWindowCommand, runPreviewCommand));
    } else // beat the popup blockers) then save & run
    if (dirtyState().getValue()) {
        showPreviewWindowCommand.execute();
        saveThenExecute(null, runPreviewCommand);
    } else // otherwise show the preview window then run the preview
    {
        showPreviewWindowCommand.execute();
        runPreviewCommand.execute();
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) ShowHTMLPreviewEvent(org.rstudio.studio.client.htmlpreview.events.ShowHTMLPreviewEvent) HTMLPreviewParams(org.rstudio.studio.client.htmlpreview.model.HTMLPreviewParams)

Example 3 with HTMLPreviewParams

use of org.rstudio.studio.client.htmlpreview.model.HTMLPreviewParams in project rstudio by rstudio.

the class HTMLPreviewApplicationWindow method reactivate.

@Override
public void reactivate(JavaScriptObject params) {
    if (params != null) {
        HTMLPreviewParams htmlPreviewParams = params.<HTMLPreviewParams>cast();
        presenter_.onActivated(htmlPreviewParams);
    }
}
Also used : HTMLPreviewParams(org.rstudio.studio.client.htmlpreview.model.HTMLPreviewParams)

Aggregations

HTMLPreviewParams (org.rstudio.studio.client.htmlpreview.model.HTMLPreviewParams)3 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)1 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 Command (com.google.gwt.user.client.Command)1 Widget (com.google.gwt.user.client.ui.Widget)1 AppCommand (org.rstudio.core.client.command.AppCommand)1 ShowHTMLPreviewEvent (org.rstudio.studio.client.htmlpreview.events.ShowHTMLPreviewEvent)1