use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class Source method newSourceDocWithTemplate.
private void newSourceDocWithTemplate(final TextFileType fileType, String name, String template, final Position cursorPosition, final CommandWithArg<EditingTarget> onSuccess, final TransformerCommand<String> contentTransformer) {
final ProgressIndicator indicator = new GlobalProgressDelayer(globalDisplay_, 500, "Creating new document...").getIndicator();
server_.getSourceTemplate(name, template, new ServerRequestCallback<String>() {
@Override
public void onResponseReceived(String templateContents) {
indicator.onCompleted();
if (contentTransformer != null)
templateContents = contentTransformer.transform(templateContents);
newDoc(fileType, templateContents, new ResultCallback<EditingTarget, ServerError>() {
@Override
public void onSuccess(EditingTarget target) {
if (cursorPosition != null)
target.setCursorPosition(cursorPosition);
if (onSuccess != null)
onSuccess.execute(target);
}
});
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class Plots method onSavePlotAsPdf.
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 = uiPrefs_.get().savePlotAsPdfOptions().getValue();
exportPlot_.savePlotAsPdf(globalDisplay_, server_, session_.getSessionInfo(), defaultDir, stem, currentOptions, pixelsToInches(size.width), pixelsToInches(size.height), 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());
}
});
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class Plots method onRemovePlot.
void onRemovePlot() {
// delete plot gesture indicates we are done with locator
safeClearLocator();
// confirm
globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Remove Plot", "Are you sure you want to remove the current plot?", new ProgressOperation() {
public void execute(final ProgressIndicator indicator) {
indicator.onProgress("Removing plot...");
server_.removePlot(new VoidServerRequestCallback(indicator));
}
}, true);
view_.bringToFront();
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class Presentation method onClearPresentationCache.
@Handler
void onClearPresentationCache() {
globalDisplay_.showYesNoMessage(MessageDialog.INFO, "Clear Knitr Cache", "Clearing the Knitr cache will discard previously cached " + "output and re-run all of the R code chunks within the " + "presentation.\n\n" + "Are you sure you want to clear the cache now?", false, new ProgressOperation() {
@Override
public void execute(final ProgressIndicator indicator) {
indicator.onProgress("Clearing Knitr Cache...");
server_.clearPresentationCache(new ServerRequestCallback<Void>() {
@Override
public void onResponseReceived(Void response) {
indicator.onCompleted();
refreshPresentation();
}
@Override
public void onError(ServerError error) {
indicator.onCompleted();
globalDisplay_.showErrorMessage("Error Clearing Cache", getErrorMessage(error));
}
});
}
}, new ProgressOperation() {
@Override
public void execute(ProgressIndicator indicator) {
indicator.onCompleted();
}
}, true);
}
use of org.rstudio.core.client.widget.ProgressIndicator 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());
}
});
}
Aggregations