Search in sources :

Example 36 with ServerError

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

the class RnwWeaveSelectWidget method verifyAvailable.

protected void verifyAvailable(final RnwWeave weave) {
    // first check if it was already available at startup
    TexCapabilities texCap = session_.getSessionInfo().getTexCapabilities();
    if (texCap.isRnwWeaveAvailable(weave))
        return;
    server_.getTexCapabilities(new ServerRequestCallback<TexCapabilities>() {

        @Override
        public void onResponseReceived(TexCapabilities capabilities) {
            if (!capabilities.isRnwWeaveAvailable(weave)) {
                globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Confirm Change", "The " + weave.getPackageName() + " package is required " + "for " + weave.getName() + " weaving, " + "however it is not currently installed. You should " + "ensure that " + weave.getPackageName() + " is installed " + "prior to compiling a PDF." + "\n\nAre you sure you want to change this option?", false, new Operation() {

                    @Override
                    public void execute() {
                    }
                }, new Operation() {

                    @Override
                    public void execute() {
                        setValue(rnwWeaveRegistry_.getTypes().get(0).getName());
                    }
                }, false);
            }
        }

        @Override
        public void onError(ServerError error) {
            Debug.logError(error);
        }
    });
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) TexCapabilities(org.rstudio.studio.client.workbench.model.TexCapabilities) Operation(org.rstudio.core.client.widget.Operation)

Example 37 with ServerError

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

the class ChooseMirrorDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    // create progress container
    final SimplePanelWithProgress panel = new SimplePanelWithProgress(ProgressImages.createLargeGray());
    panel.setStylePrimaryName(RESOURCES.styles().mainWidget());
    // show progress (with delay)
    panel.showProgress(200);
    // query data source for packages
    mirrorSource_.requestData(new SimpleRequestCallback<JsArray<T>>() {

        @Override
        public void onResponseReceived(JsArray<T> mirrors) {
            // keep internal list of mirrors 
            boolean haveInsecureMirror = false;
            mirrors_ = new ArrayList<T>(mirrors.length());
            // create list box and select default item
            listBox_ = new ListBox();
            listBox_.setMultipleSelect(false);
            // all
            listBox_.setVisibleItemCount(18);
            listBox_.setWidth("100%");
            if (mirrors.length() > 0) {
                for (int i = 0; i < mirrors.length(); i++) {
                    T mirror = mirrors.get(i);
                    if (mirrorSource_.getLabel(mirror).startsWith("0-Cloud"))
                        continue;
                    mirrors_.add(mirror);
                    String item = mirrorSource_.getLabel(mirror);
                    String value = mirrorSource_.getURL(mirror);
                    if (!value.startsWith("https"))
                        haveInsecureMirror = true;
                    listBox_.addItem(item, value);
                }
                listBox_.setSelectedIndex(0);
                enableOkButton(true);
            }
            // set it into the panel
            panel.setWidget(listBox_);
            // set caption
            String protocolQualifer = !haveInsecureMirror ? " HTTPS" : "";
            setText("Choose" + protocolQualifer + " CRAN Mirror");
            // update ok button on changed
            listBox_.addDoubleClickHandler(new DoubleClickHandler() {

                @Override
                public void onDoubleClick(DoubleClickEvent event) {
                    clickOkButton();
                }
            });
            // if the list box is larger than the space we initially allocated
            // then increase the panel height
            final int kDefaultPanelHeight = 285;
            if (listBox_.getOffsetHeight() > kDefaultPanelHeight)
                panel.setHeight(listBox_.getOffsetHeight() + "px");
            // set focus   
            FocusHelper.setFocusDeferred(listBox_);
        }

        @Override
        public void onError(ServerError error) {
            closeDialog();
            super.onError(error);
        }
    });
    return panel;
}
Also used : SimplePanelWithProgress(org.rstudio.core.client.widget.SimplePanelWithProgress) JsArray(com.google.gwt.core.client.JsArray) GWT(com.google.gwt.core.client.GWT) ServerError(org.rstudio.studio.client.server.ServerError) DoubleClickHandler(com.google.gwt.event.dom.client.DoubleClickHandler) ArrayList(java.util.ArrayList) DoubleClickEvent(com.google.gwt.event.dom.client.DoubleClickEvent) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 38 with ServerError

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

the class Synctex method doDesktopInverseSearch.

private void doDesktopInverseSearch(String file, int line, int column) {
    // apply concordance
    final ProgressIndicator indicator = getSyncProgress();
    server_.applyInverseConcordance(SourceLocation.create(file, line, column, true), new ServerRequestCallback<SourceLocation>() {

        @Override
        public void onResponseReceived(SourceLocation sourceLocation) {
            indicator.onCompleted();
            if (sourceLocation != null)
                goToSourceLocation(sourceLocation);
        }

        @Override
        public void onError(ServerError error) {
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : SourceLocation(org.rstudio.studio.client.common.synctex.model.SourceLocation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError)

Example 39 with ServerError

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

the class Synctex method doForwardSearch.

private void doForwardSearch(String rootDocument, JavaScriptObject sourceLocationObject) {
    SourceLocation sourceLocation = sourceLocationObject.cast();
    final ProgressIndicator indicator = getSyncProgress();
    server_.synctexForwardSearch(rootDocument, sourceLocation, new ServerRequestCallback<PdfLocation>() {

        @Override
        public void onResponseReceived(PdfLocation location) {
            indicator.onCompleted();
            if (location != null)
                eventBus_.fireEvent(new SynctexViewPdfEvent(location));
        }

        @Override
        public void onError(ServerError error) {
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : SourceLocation(org.rstudio.studio.client.common.synctex.model.SourceLocation) PdfLocation(org.rstudio.studio.client.common.synctex.model.PdfLocation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) SynctexViewPdfEvent(org.rstudio.studio.client.common.synctex.events.SynctexViewPdfEvent)

Example 40 with ServerError

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

the class FileTypeRegistry method openFile.

public void openFile(final FileSystemItem file, final boolean canUseBrowser) {
    FileType fileType = getTypeForFile(file);
    if (fileType != null) {
        fileType.openFile(file, eventBus_);
    } else {
        // build default command to use if we have an error or the
        // file is not a text file
        final Command defaultCommand = new Command() {

            @Override
            public void execute() {
                if (canUseBrowser) {
                    if (session_.getSessionInfo().getAllowFileDownloads()) {
                        BROWSER.openFile(file, eventBus_);
                    } else {
                        globalDisplay_.showErrorMessage("File Download Error", "Unable to show file because file downloads are " + "restricted on this server.\n");
                    }
                }
            }
        };
        // check with the server to see if this is likely to be a text file
        server_.isTextFile(file.getPath(), new ServerRequestCallback<Boolean>() {

            @Override
            public void onResponseReceived(Boolean isText) {
                if (isText)
                    TEXT.openFile(file, eventBus_);
                else
                    defaultCommand.execute();
            }

            @Override
            public void onError(ServerError error) {
                defaultCommand.execute();
            }
        });
    }
}
Also used : Command(com.google.gwt.user.client.Command) ServerError(org.rstudio.studio.client.server.ServerError)

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