Search in sources :

Example 66 with ServerError

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

the class ProjectPackratPreferencesPane method verifyPrerequisites.

private void verifyPrerequisites() {
    final ProgressIndicator indicator = getProgressIndicator();
    indicator.onProgress("Verifying prequisites...");
    server_.getPackratPrerequisites(new ServerRequestCallback<PackratPrerequisites>() {

        @Override
        public void onResponseReceived(PackratPrerequisites prereqs) {
            indicator.onCompleted();
            if (prereqs.getBuildToolsAvailable()) {
                if (prereqs.getPackageAvailable()) {
                    setUsePackrat(true);
                } else {
                    setUsePackrat(false);
                    // install packrat (with short delay to allow
                    // the progress indicator to clear)
                    new Timer() {

                        @Override
                        public void run() {
                            dependencyManager_.withPackrat("Managing packages with packrat", new Command() {

                                @Override
                                public void execute() {
                                    setUsePackrat(true);
                                }
                            });
                        }
                    }.schedule(250);
                }
            } else {
                setUsePackrat(false);
                // install build tools (with short delay to allow
                // the progress indicator to clear)
                new Timer() {

                    @Override
                    public void run() {
                        server_.installBuildTools("Managing packages with Packrat", new SimpleRequestCallback<Boolean>() {
                        });
                    }
                }.schedule(250);
            }
        }

        @Override
        public void onError(ServerError error) {
            setUsePackrat(false);
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : PackratPrerequisites(org.rstudio.studio.client.packrat.model.PackratPrerequisites) Timer(com.google.gwt.user.client.Timer) Command(com.google.gwt.user.client.Command) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError)

Example 67 with ServerError

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

the class ProjectSourceControlPreferencesPane method confirmGitRepo.

private void confirmGitRepo(final Command onConfirmed) {
    final ProgressIndicator indicator = getProgressIndicator();
    indicator.onProgress("Checking for git repository...");
    final String projDir = session_.getSessionInfo().getActiveProjectDir().getPath();
    server_.gitHasRepo(projDir, new ServerRequestCallback<Boolean>() {

        @Override
        public void onResponseReceived(Boolean result) {
            indicator.onCompleted();
            if (result) {
                onConfirmed.execute();
            } else {
                globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Confirm New Git Repository", "Do you want to initialize a new git repository " + "for this project?", false, new Operation() {

                    @Override
                    public void execute() {
                        server_.gitInitRepo(projDir, new VoidServerRequestCallback(indicator) {

                            @Override
                            public void onSuccess() {
                                onConfirmed.execute();
                            }

                            @Override
                            public void onFailure() {
                                setVcsSelection(VCSConstants.NO_ID);
                            }
                        });
                    }
                }, new Operation() {

                    @Override
                    public void execute() {
                        setVcsSelection(VCSConstants.NO_ID);
                        indicator.onCompleted();
                    }
                }, true);
            }
        }

        @Override
        public void onError(ServerError error) {
            setVcsSelection(VCSConstants.NO_ID);
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) JsArrayString(com.google.gwt.core.client.JsArrayString) Operation(org.rstudio.core.client.widget.Operation)

Example 68 with ServerError

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

the class Ignore method showDialog.

public void showDialog(final IgnoreList ignoreList, final Strategy strategy) {
    // show progress
    final ProgressIndicator globalIndicator = new GlobalProgressDelayer(globalDisplay_, 500, "Getting ignored files for path...").getIndicator();
    // get existing ignores
    final String fullPath = projPathToFullPath(ignoreList.getPath());
    strategy.getIgnores(fullPath, new ServerRequestCallback<ProcessResult>() {

        @Override
        public void onResponseReceived(final ProcessResult result) {
            globalIndicator.onCompleted();
            if (checkForProcessError(strategy.getDialogCaption(), result))
                return;
            // show the ignore dialog
            String ignored = getIgnored(ignoreList, result.getOutput());
            showDialog(fullPath, ignored, strategy);
        }

        @Override
        public void onError(ServerError error) {
            globalIndicator.onError(error.getUserMessage());
        }
    });
}
Also used : ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) GlobalProgressDelayer(org.rstudio.studio.client.common.GlobalProgressDelayer) ProcessResult(org.rstudio.studio.client.common.vcs.ProcessResult)

Example 69 with ServerError

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

the class Ignore method showDialog.

private void showDialog(final String initialPath, String ignores, final Strategy strategy) {
    final Display display = pDisplay_.get();
    final ProgressIndicator indicator = display.progressIndicator();
    display.setDialogCaption(strategy.getDialogCaption());
    display.setIgnoresCaption(strategy.getIgnoresCaption());
    display.setHelpLinkName(strategy.getHelpLinkName());
    display.setCurrentPath(initialPath);
    display.setIgnored(ignores);
    display.scrollToBottom();
    display.addPathChangedHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            display.setIgnored("");
            indicator.onProgress("Getting ignored files for path...");
            strategy.getIgnores(display.getCurrentPath(), new ServerRequestCallback<ProcessResult>() {

                @Override
                public void onResponseReceived(final ProcessResult result) {
                    indicator.clearProgress();
                    if (checkForProcessError(strategy.getDialogCaption(), result))
                        return;
                    display.setIgnored(result.getOutput());
                    display.focusIgnored();
                }

                @Override
                public void onError(ServerError error) {
                    indicator.onError(error.getUserMessage());
                }
            });
        }
    });
    display.saveButton().addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            indicator.onProgress("Setting ignored files for path...");
            strategy.setIgnores(display.getCurrentPath(), display.getIgnored(), new ServerRequestCallback<ProcessResult>() {

                @Override
                public void onResponseReceived(ProcessResult result) {
                    indicator.onCompleted();
                    checkForProcessError(strategy.getDialogCaption(), result);
                }

                @Override
                public void onError(ServerError error) {
                    indicator.onError(error.getUserMessage());
                }
            });
        }
    });
    display.showModal();
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ProcessResult(org.rstudio.studio.client.common.vcs.ProcessResult) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) GlobalDisplay(org.rstudio.studio.client.common.GlobalDisplay)

Example 70 with ServerError

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

the class NewRSConnectAuthPage method pollForAuthCompleted.

private void pollForAuthCompleted() {
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            // don't keep polling once auth is complete or window is closed
            if (!waitingForAuth_.getValue())
                return false;
            // returned for some reason, just wait for it to finish
            if (runningAuthCompleteCheck_)
                return true;
            runningAuthCompleteCheck_ = true;
            server_.getUserFromToken(result_.getServerInfo().getUrl(), result_.getPreAuthToken(), new ServerRequestCallback<RSConnectAuthUser>() {

                @Override
                public void onResponseReceived(RSConnectAuthUser user) {
                    runningAuthCompleteCheck_ = false;
                    // just wait and try again
                    if (!user.isValidUser())
                        return;
                    // user is valid--cache account info and close the
                    // window
                    result_.setAuthUser(user);
                    waitingForAuth_.setValue(false, true);
                    if (Desktop.isDesktop()) {
                        // on the desktop, we can close the window by name
                        Desktop.getFrame().closeNamedWindow(AUTH_WINDOW_NAME);
                    }
                    onUserAuthVerified();
                }

                @Override
                public void onError(ServerError error) {
                    // ignore this error
                    runningAuthCompleteCheck_ = false;
                }
            });
            return true;
        }
    }, 1000);
}
Also used : RSConnectAuthUser(org.rstudio.studio.client.rsconnect.model.RSConnectAuthUser) ServerError(org.rstudio.studio.client.server.ServerError) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback)

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