Search in sources :

Example 76 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class HelpStrategy method showPackageHelp.

private void showPackageHelp(final QualifiedName selectedItem, final CompletionPopupDisplay display) {
    ParsedInfo cachedHelp = cache_.get(selectedItem);
    if (cachedHelp != null) {
        doShowPackageHelp(cachedHelp, display);
        return;
    }
    final String packageName = selectedItem.name;
    server_.getHelp(packageName, null, selectedItem.type, new ServerRequestCallback<HelpInfo>() {

        @Override
        public void onError(ServerError error) {
            display.clearHelp(false);
        }

        @Override
        public void onResponseReceived(HelpInfo response) {
            if (response != null) {
                ParsedInfo info = response.parse(packageName);
                cache_.put(selectedItem, info);
                doShowPackageHelp(info, display);
            } else {
                display.setHelpVisible(false);
                display.clearHelp(false);
            }
        }
    });
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) HelpInfo(org.rstudio.studio.client.workbench.views.help.model.HelpInfo) ParsedInfo(org.rstudio.studio.client.workbench.views.help.model.HelpInfo.ParsedInfo)

Example 77 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class OptionsLoader method showOptions.

public void showOptions(final Class<?> paneClass) {
    final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error Reading Options");
    indicator.onProgress("Reading options...");
    server_.getRPrefs(new SimpleRequestCallback<RPrefs>() {

        @Override
        public void onResponseReceived(RPrefs rPrefs) {
            indicator.onCompleted();
            PreferencesDialog prefDialog = pPrefDialog_.get();
            prefDialog.initialize(rPrefs);
            if (paneClass != null)
                prefDialog.activatePane(paneClass);
            prefDialog.showModal();
            // if the user changes global sweave or latex options notify
            // them if this results in the current project being out
            // of sync with the global settings
            new SweaveProjectOptionsNotifier(prefDialog);
            // the mac you can actually show prefs from a satellite window)
            if (Desktop.isDesktop())
                Desktop.getFrame().bringMainFrameToFront();
        }

        @Override
        public void onError(ServerError error) {
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : RPrefs(org.rstudio.studio.client.workbench.prefs.model.RPrefs) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) PreferencesDialog(org.rstudio.studio.client.workbench.prefs.views.PreferencesDialog)

Example 78 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class BuildPresenter method executeBuild.

private void executeBuild(final String type, final String subType) {
    // attempt to start a build (this will be a silent no-op if there
    // is already a build running)
    workbenchContext_.setBuildInProgress(true);
    sourceBuildHelper_.withSaveFilesBeforeCommand(new Command() {

        @Override
        public void execute() {
            server_.startBuild(type, subType, new SimpleRequestCallback<Boolean>() {

                @Override
                public void onResponseReceived(Boolean response) {
                }

                @Override
                public void onError(ServerError error) {
                    super.onError(error);
                    workbenchContext_.setBuildInProgress(false);
                }
            });
        }
    }, "Build");
}
Also used : Command(com.google.gwt.user.client.Command) ServerError(org.rstudio.studio.client.server.ServerError) SimpleRequestCallback(org.rstudio.studio.client.common.SimpleRequestCallback)

Example 79 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class DataImport method previewDataImport.

private void previewDataImport() {
    Operation previewDataImportOperation = new Operation() {

        @Override
        public void execute() {
            DataImportOptions previewImportOptions = getOptions();
            if (dataImportFileChooser_.getText() == "") {
                gridViewer_.setData(null);
                return;
            }
            previewImportOptions.setMaxRows(maxRows_);
            progressIndicator_.onProgress("Retrieving preview data...", new Operation() {

                @Override
                public void execute() {
                    progressIndicator_.clearProgress();
                    cleanPreviewResources();
                    server_.previewDataImportAsyncAbort(new ServerRequestCallback<Void>() {

                        @Override
                        public void onResponseReceived(Void empty) {
                        }

                        @Override
                        public void onError(ServerError error) {
                            Debug.logError(error);
                            progressIndicator_.onError(error.getMessage());
                        }
                    });
                }
            });
            server_.previewDataImportAsync(previewImportOptions, maxCols_, maxFactors_, new ServerRequestCallback<DataImportPreviewResponse>() {

                @Override
                public void onResponseReceived(DataImportPreviewResponse response) {
                    if (response == null || response.getErrorMessage() != null) {
                        if (response != null) {
                            setGridViewerData(response);
                            response.setColumnDefinitions(lastSuccessfulResponse_);
                            progressIndicator_.onError(enhancePreviewErrorMessage(response.getErrorMessage()));
                        }
                        return;
                    }
                    // Set the column definitions to allow subsequent calls to assemble
                    // generate preview code based on data.
                    importOptions_.setBaseColumnDefinitions(response);
                    lastSuccessfulResponse_ = response;
                    dataImportOptionsUi_.setPreviewResponse(response);
                    if (response.getLocalFiles() != null) {
                        localFiles_ = response.getLocalFiles();
                    }
                    gridViewer_.setOption("status", "Previewing first " + toLocaleString(maxRows_) + " entries. " + (response.getParsingErrors() > 0 ? Integer.toString(response.getParsingErrors()) + " parsing errors." : ""));
                    assignColumnDefinitions(response, importOptions_.getColumnDefinitions());
                    setGridViewerData(response);
                    progressIndicator_.onCompleted();
                }

                @Override
                public void onError(ServerError error) {
                    Debug.logError(error);
                    cleanPreviewResources();
                    gridViewer_.setData(null);
                    progressIndicator_.onError(error.getMessage());
                }
            });
        }
    };
    assembleDataImport(previewDataImportOperation);
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) Operation(org.rstudio.core.client.widget.Operation) DataImportPreviewResponse(org.rstudio.studio.client.workbench.views.environment.dataimport.model.DataImportPreviewResponse) Void(org.rstudio.studio.client.server.Void)

Example 80 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class HelpSearchOracle method requestSuggestions.

@Override
public void requestSuggestions(final Request request, final Callback callback) {
    String query = request.getQuery();
    server_.suggestTopics(query, new ServerRequestCallback<JsArrayString>() {

        @Override
        public void onError(ServerError error) {
        }

        @Override
        public void onResponseReceived(JsArrayString suggestions) {
            int maxCount = Math.min(suggestions.length(), request.getLimit());
            ArrayList<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
            for (int i = 0; i < maxCount; i++) results.add(new SearchSuggestion(suggestions.get(i)));
            callback.onSuggestionsReady(request, new Response(results));
        }
    });
    ;
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) ArrayList(java.util.ArrayList) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString)

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