Search in sources :

Example 1 with SaveViewerPlotAsImageDesktopDialog

use of org.rstudio.studio.client.workbench.views.viewer.export.SaveViewerPlotAsImageDesktopDialog in project rstudio by rstudio.

the class ViewerPresenter method onViewerSaveAsImage.

@Handler
public void onViewerSaveAsImage() {
    display_.bringToFront();
    final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error");
    indicator.onProgress("Preparing to export plot...");
    // get the default directory
    FileSystemItem defaultDir = ExportPlotUtils.getDefaultSaveDirectory(workbenchContext_.getCurrentWorkingDir());
    // get context
    server_.getViewerExportContext(defaultDir.getPath(), new SimpleRequestCallback<SavePlotAsImageContext>() {

        @Override
        public void onResponseReceived(SavePlotAsImageContext context) {
            indicator.onCompleted();
            new SaveViewerPlotAsImageDesktopDialog(globalDisplay_, display_.getUrl(), context, ExportPlotOptions.adaptToSize(pUIPrefs_.get().exportViewerOptions().getValue(), display_.getViewerFrameSize()), saveExportOptionsOperation_).showModal();
        }

        @Override
        public void onError(ServerError error) {
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : SavePlotAsImageContext(org.rstudio.studio.client.workbench.exportplot.model.SavePlotAsImageContext) FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) SaveViewerPlotAsImageDesktopDialog(org.rstudio.studio.client.workbench.views.viewer.export.SaveViewerPlotAsImageDesktopDialog) EnabledChangedHandler(org.rstudio.core.client.command.EnabledChangedHandler) Handler(org.rstudio.core.client.command.Handler)

Aggregations

EnabledChangedHandler (org.rstudio.core.client.command.EnabledChangedHandler)1 Handler (org.rstudio.core.client.command.Handler)1 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)1 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)1 ServerError (org.rstudio.studio.client.server.ServerError)1 SavePlotAsImageContext (org.rstudio.studio.client.workbench.exportplot.model.SavePlotAsImageContext)1 SaveViewerPlotAsImageDesktopDialog (org.rstudio.studio.client.workbench.views.viewer.export.SaveViewerPlotAsImageDesktopDialog)1