use of org.rstudio.studio.client.server.ServerError 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());
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class ImportFileSettingsDialog method updateOutput.
private void updateOutput() {
if (separator_.getSelectedIndex() < 0 || quote_.getSelectedIndex() < 0 || decimal_.getSelectedIndex() < 0) {
return;
}
updateRequest_.invalidate();
final Token invalidationToken = updateRequest_.getInvalidationToken();
progress_.onProgress("Updating preview");
server_.getOutputPreview(dataFile_.getPath(), encoding_.getValue(encoding_.getSelectedIndex()), headingYes_.getValue().booleanValue(), separator_.getValue(separator_.getSelectedIndex()), decimal_.getValue(decimal_.getSelectedIndex()), quote_.getValue(quote_.getSelectedIndex()), comment_.getValue(comment_.getSelectedIndex()), new ServerRequestCallback<DataPreviewResult>() {
@Override
public void onResponseReceived(DataPreviewResult response) {
if (invalidationToken.isInvalid())
return;
progress_.onProgress(null);
populateOutput(response);
}
@Override
public void onError(ServerError error) {
if (invalidationToken.isInvalid())
return;
progress_.onProgress(null);
globalDisplay_.showErrorMessage("Error", error.getUserMessage());
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class Packages method withPackageInstallContext.
private void withPackageInstallContext(final OperationWithInput<PackageInstallContext> operation) {
final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error");
indicator.onProgress("Retrieving package installation context...");
server_.getPackageInstallContext(new SimpleRequestCallback<PackageInstallContext>() {
@Override
public void onResponseReceived(PackageInstallContext context) {
indicator.onCompleted();
operation.execute(context);
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class ProfilerPresenter method onStartProfiler.
@Handler
public void onStartProfiler() {
dependencyManager_.withProfvis(profilerDependecyUserAction_, new Command() {
@Override
public void execute() {
ProfileOperationRequest request = ProfileOperationRequest.create("");
server_.startProfiling(request, new ServerRequestCallback<ProfileOperationResponse>() {
@Override
public void onResponseReceived(ProfileOperationResponse response) {
if (response.getErrorMessage() != null) {
globalDisplay_.showErrorMessage("Profiler Error", response.getErrorMessage());
return;
}
pSourceWindowManager_.get().ensureVisibleSourcePaneIfNecessary();
response_ = response;
sourceServer_.newDocument(FileTypeRegistry.PROFILER.getTypeId(), null, (JsObject) ProfilerContents.create(response.getFileName(), null, null, true).cast(), new SimpleRequestCallback<SourceDocument>("Show Profiler") {
@Override
public void onResponseReceived(SourceDocument response) {
currentDocId_ = response.getId();
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
}
});
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
globalDisplay_.showErrorMessage("Failed to Stop Profiler", error.getMessage());
}
});
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class ProfilerPresenter method onStopProfiler.
@Handler
public void onStopProfiler() {
ProfileOperationRequest request = ProfileOperationRequest.create(response_ != null ? response_.getFileName() : null);
response_ = null;
server_.stopProfiling(request, new ServerRequestCallback<ProfileOperationResponse>() {
@Override
public void onResponseReceived(ProfileOperationResponse response) {
if (response.getErrorMessage() != null) {
globalDisplay_.showErrorMessage("Profiler Error", response.getErrorMessage());
return;
}
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
globalDisplay_.showErrorMessage("Failed to Stop Profiler", error.getMessage());
}
});
}
Aggregations