Search in sources :

Example 41 with ServerError

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

the class PackageActionConfirmationDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    FlowPanel flowPanel = new FlowPanel();
    String explanatoryText = getExplanatoryText();
    if (explanatoryText.length() > 0) {
        Label text = new Label(explanatoryText);
        text.setStylePrimaryName(RESOURCES.styles().explanatoryText());
        flowPanel.add(text);
    }
    actionsTable_ = new CellTable<PendingAction>(15, GWT.<PackagesCellTableResources>create(PackagesCellTableResources.class));
    actionsTable_.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    actionsTable_.setSelectionModel(new NoSelectionModel<PendingAction>());
    actionsTable_.setWidth("100%", true);
    ActionColumn actionColumn = new ActionColumn();
    actionsTable_.addColumn(actionColumn);
    actionsTable_.setColumnWidth(actionColumn, 30, Unit.PX);
    addTableColumns(actionsTable_);
    ScrollPanel scrollPanel = new ScrollPanel();
    scrollPanel.setWidget(actionsTable_);
    scrollPanel.setStylePrimaryName(RESOURCES.styles().mainWidget());
    flowPanel.add(scrollPanel);
    // query for updates
    actionsDS_.requestData(new SimpleRequestCallback<JsArray<T>>() {

        @Override
        public void onResponseReceived(JsArray<T> actions) {
            if (actions != null && actions.length() > 0) {
                ArrayList<PendingAction> pendingActions = new ArrayList<PendingAction>();
                for (int i = 0; i < actions.length(); i++) pendingActions.add(new PendingAction(actions.get(i), false));
                actionsTable_.setPageSize(pendingActions.size());
                actionsDataProvider_ = new ListDataProvider<PendingAction>();
                actionsDataProvider_.setList(pendingActions);
                actionsDataProvider_.addDataDisplay(actionsTable_);
                enableCancelButton(true);
                selectAllButton_.setEnabled(true);
                selectNoneButton_.setEnabled(true);
            } else {
                closeDialog();
                showNoActionsRequired();
            }
        }

        @Override
        public void onError(ServerError error) {
            closeDialog();
            super.onError(error);
        }
    });
    return flowPanel;
}
Also used : ListDataProvider(com.google.gwt.view.client.ListDataProvider) JsArray(com.google.gwt.core.client.JsArray) ServerError(org.rstudio.studio.client.server.ServerError) Label(com.google.gwt.user.client.ui.Label) ArrayList(java.util.ArrayList) GWT(com.google.gwt.core.client.GWT) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 42 with ServerError

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

the class ImportFileSettingsDialog method loadData.

private void loadData() {
    final Token invalidationToken = updateRequest_.getInvalidationToken();
    progress_.onProgress("Detecting data format");
    server_.getDataPreview(dataFile_.getPath(), new ServerRequestCallback<DataPreviewResult>() {

        @Override
        public void onResponseReceived(DataPreviewResult response) {
            input_.setHTML(toInputHtml(response));
            if (invalidationToken.isInvalid())
                return;
            progress_.onProgress(null);
            populateOutput(response);
            if (response.hasHeader())
                headingYes_.setValue(true);
            else
                headingNo_.setValue(true);
            selectByValue(separator_, response.getSeparator());
            selectByValue(decimal_, response.getDecimal());
            selectByValue(quote_, response.getQuote());
            selectByValue(comment_, response.getComment());
            defaultStringsAsFactors_ = response.getDefaultStringsAsFactors();
            stringsAsFactors_.setValue(defaultStringsAsFactors_);
        }

        @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 43 with ServerError

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

the class LintManager method performCppLintServerRequest.

private void performCppLintServerRequest(final LintContext context) {
    cppCompletionContext_.cppCompletionOperation(new CppCompletionOperation() {

        @Override
        public void execute(String docPath, int line, int column) {
            server_.getCppDiagnostics(target_.getPath(), new ServerRequestCallback<JsArray<CppDiagnostic>>() {

                @Override
                public void onResponseReceived(JsArray<CppDiagnostic> diag) {
                    if (context.token.isInvalid())
                        return;
                    final JsArray<LintItem> cppLint = CppCompletionRequest.asLintArray(diag);
                    server_.lintRSourceDocument(target_.getId(), target_.getPath(), context.showMarkers, context.explicit, new ServerRequestCallback<JsArray<LintItem>>() {

                        @Override
                        public void onResponseReceived(JsArray<LintItem> rLint) {
                            if (context.token.isInvalid())
                                return;
                            JsArray<LintItem> allLint = JsArray.createArray().cast();
                            for (int i = 0; i < cppLint.length(); i++) allLint.push(cppLint.get(i));
                            for (int i = 0; i < rLint.length(); i++) allLint.push(rLint.get(i));
                            showLint(context, allLint);
                        }

                        @Override
                        public void onError(ServerError error) {
                            Debug.logError(error);
                        }
                    });
                }

                @Override
                public void onError(ServerError error) {
                    Debug.logError(error);
                }
            });
        }
    });
}
Also used : CppCompletionOperation(org.rstudio.studio.client.workbench.views.source.editors.text.cpp.CppCompletionOperation) JsArray(com.google.gwt.core.client.JsArray) LintItem(org.rstudio.studio.client.workbench.views.output.lint.model.LintItem) CppDiagnostic(org.rstudio.studio.client.workbench.views.source.model.CppDiagnostic) ServerError(org.rstudio.studio.client.server.ServerError) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback)

Example 44 with ServerError

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

the class FilesUpload method completeFileUploadOperation.

private Operation completeFileUploadOperation(final FileUploadToken token, final boolean commit) {
    return new Operation() {

        public void execute() {
            String msg = (commit ? "Completing" : "Cancelling") + " file upload...";
            final Command dismissProgress = globalDisplay_.showProgress(msg);
            server_.completeUpload(token, commit, new ServerRequestCallback<Void>() {

                @Override
                public void onResponseReceived(Void response) {
                    dismissProgress.execute();
                }

                @Override
                public void onError(ServerError error) {
                    dismissProgress.execute();
                    globalDisplay_.showErrorMessage("File Upload Error", error.getUserMessage());
                }
            });
        }
    };
}
Also used : Command(com.google.gwt.user.client.Command) ServerError(org.rstudio.studio.client.server.ServerError) Operation(org.rstudio.core.client.widget.Operation) Void(org.rstudio.studio.client.server.Void)

Example 45 with ServerError

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

the class RSConnectDeploy method populateDeploymentFiles.

private void populateDeploymentFiles(final ProgressIndicator indicator) {
    if (source_ == null)
        return;
    // dependencies; just inject it directly into the list.
    if (source_.isSelfContained() && source_.isStatic() && !source_.isWebsiteRmd()) {
        ArrayList<String> files = new ArrayList<String>();
        FileSystemItem selfContained = FileSystemItem.createFile(source_.getDeployFile());
        files.add(selfContained.getName());
        setFileList(files, null, null);
        setPrimaryFile(selfContained.getName());
        return;
    }
    // ternery operator maps to appropriate files to list for deployment:
    // website code    - website code directory 
    // static website  - website build directory
    // document        - R Markdown document
    // non-document    - Shiny app directory
    final String fileSource = source_.isDocument() ? source_.isWebsiteRmd() ? source_.isStatic() ? source_.getDeployDir() : source_.getWebsiteDir() : source_.getDeployFile() : source_.getDeployDir();
    indicator.onProgress("Collecting files...");
    server_.getDeploymentFiles(fileSource, asMultipleRmd_, new ServerRequestCallback<RSConnectDeploymentFiles>() {

        @Override
        public void onResponseReceived(RSConnectDeploymentFiles files) {
            if (files.getDirSize() > files.getMaxSize()) {
                indicator.onError("The item to be deployed (" + fileSource + ") " + "exceeds the maximum deployment size, which is " + StringUtil.formatFileSize(files.getMaxSize()) + "." + " Consider creating a new directory containing " + "only the content you wish to deploy.");
            } else {
                if (files.getDirList() == null || files.getDirList().length() == 0) {
                    indicator.onError("Could not determine the list of " + "files to deploy.");
                    indicator.onCompleted();
                }
                setFileList(JsArrayUtil.fromJsArrayString(files.getDirList()), fromPrevious_ != null ? fromPrevious_.getAdditionalFiles() : null, fromPrevious_ != null ? fromPrevious_.getIgnoredFiles() : null);
                if (!source_.isWebsiteRmd())
                    setPrimaryFile(FileSystemItem.createFile(source_.getDeployFile()).getName());
            }
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    indicator.clearProgress();
                }
            });
        }

        @Override
        public void onError(ServerError error) {
            // we need to have a list of files to deploy to proceed
            indicator.onError("Could not find files to deploy: \n\n" + error.getMessage());
            indicator.onCompleted();
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ServerError(org.rstudio.studio.client.server.ServerError) ArrayList(java.util.ArrayList) RSConnectDeploymentFiles(org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentFiles)

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