void onSavePlotAsPdf()
{
view_.bringToFront();
final ProgressIndicator indicator =
globalDisplay_.getProgressIndicator("Error");
indicator.onProgress("Preparing to export plot...");
// get the default directory
final FileSystemItem defaultDir = ExportPlotUtils.getDefaultSaveDirectory(
workbenchContext_.getCurrentWorkingDir());
// get context
server_.getUniqueSavePlotStem(
defaultDir.getPath(),
new SimpleRequestCallback<String>() {
@Override
public void onResponseReceived(String stem)
{
indicator.onCompleted();
Size size = getPlotSize();
final SavePlotAsPdfOptions currentOptions =
SavePlotAsPdfOptions.adaptToSize(
uiPrefs_.get().savePlotAsPdfOptions().getValue(),
pixelsToInches(size.width),
pixelsToInches(size.height));
exportPlot_.savePlotAsPdf(
globalDisplay_,
server_,
session_.getSessionInfo(),
defaultDir,
stem,
currentOptions,
new OperationWithInput<SavePlotAsPdfOptions>() {
@Override
public void execute(SavePlotAsPdfOptions options)
{
if (!SavePlotAsPdfOptions.areEqual(
options,
currentOptions))
{
UIPrefs prefs = uiPrefs_.get();
prefs.savePlotAsPdfOptions().setGlobalValue(options);
prefs.writeUIPrefs();
}
}
}) ;
}
@Override
public void onError(ServerError error)
{
indicator.onError(error.getUserMessage());
}
});
}