Search in sources :

Example 81 with ServerError

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());
        }
    });
}
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 82 with ServerError

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());
        }
    });
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) DataPreviewResult(org.rstudio.studio.client.workbench.views.environment.model.DataPreviewResult) Token(org.rstudio.core.client.Invalidation.Token)

Example 83 with ServerError

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());
        }
    });
}
Also used : ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) PackageInstallContext(org.rstudio.studio.client.workbench.views.packages.model.PackageInstallContext)

Example 84 with ServerError

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());
                }
            });
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ServerError(org.rstudio.studio.client.server.ServerError) SourceDocument(org.rstudio.studio.client.workbench.views.source.model.SourceDocument) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) ProfileOperationResponse(org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationResponse) ProfileOperationRequest(org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationRequest) Handler(org.rstudio.core.client.command.Handler)

Example 85 with ServerError

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());
        }
    });
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) ProfileOperationResponse(org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationResponse) ProfileOperationRequest(org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationRequest) Handler(org.rstudio.core.client.command.Handler)

Aggregations

ServerError (org.rstudio.studio.client.server.ServerError)109 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)26 JsArrayString (com.google.gwt.core.client.JsArrayString)22 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)20 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)18 Void (org.rstudio.studio.client.server.Void)16 ArrayList (java.util.ArrayList)13 JsArray (com.google.gwt.core.client.JsArray)12 Command (com.google.gwt.user.client.Command)11 GlobalProgressDelayer (org.rstudio.studio.client.common.GlobalProgressDelayer)10 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)9 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)9 Operation (org.rstudio.core.client.widget.Operation)8 Handler (org.rstudio.core.client.command.Handler)7 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)7 JSONString (com.google.gwt.json.client.JSONString)6 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)6 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)6 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)6 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)6