Search in sources :

Example 1 with SavePlotAsImageContext

use of org.rstudio.studio.client.workbench.exportplot.model.SavePlotAsImageContext in project rstudio by rstudio.

the class Plots method onSavePlotAsImage.

void onSavePlotAsImage() {
    view_.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_.getSavePlotContext(defaultDir.getPath(), new SimpleRequestCallback<SavePlotAsImageContext>() {

        @Override
        public void onResponseReceived(SavePlotAsImageContext context) {
            indicator.onCompleted();
            exportPlot_.savePlotAsImage(globalDisplay_, server_, context, ExportPlotOptions.adaptToSize(uiPrefs_.get().exportPlotOptions().getValue(), getPlotSize()), saveExportOptionsOperation_);
        }

        @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)

Example 2 with SavePlotAsImageContext

use of org.rstudio.studio.client.workbench.exportplot.model.SavePlotAsImageContext 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

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