Search in sources :

Example 31 with ProgressIndicator

use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.

the class ProjectOpener method showOpenProjectDialog.

public void showOpenProjectDialog(FileSystemContext fsContext, ProjectsServerOperations server, String defaultLocation, int defaultType, boolean showNewSession, final ProgressOperationWithInput<OpenProjectParams> onCompleted) {
    initialize();
    // use the default dialog on desktop mode or single-session mode
    FileDialogs dialogs = RStudioGinjector.INSTANCE.getFileDialogs();
    if (Desktop.isDesktop() || !RStudioGinjector.INSTANCE.getSession().getSessionInfo().getMultiSession()) {
        dialogs.openFile("Open Project", fsContext, FileSystemItem.createDir(defaultLocation), "R Projects (*.Rproj)", true, new ProgressOperationWithInput<FileSystemItem>() {

            @Override
            public void execute(FileSystemItem input, final ProgressIndicator indicator) {
                final CommandWithArg<FileSystemItem> onProjectFileReady = new CommandWithArg<FileSystemItem>() {

                    @Override
                    public void execute(FileSystemItem item) {
                        onCompleted.execute(new OpenProjectParams(item, null, false), indicator);
                    }
                };
                // null return values here imply a cancellation
                if (input == null)
                    return;
                if (input.isDirectory()) {
                    final String rprojPath = input.completePath(input.getName() + ".Rproj");
                    final FileSystemItem rprojFile = FileSystemItem.createFile(rprojPath);
                    server_.createProjectFile(rprojFile.getPath(), new ServerRequestCallback<Boolean>() {

                        @Override
                        public void onResponseReceived(Boolean success) {
                            onProjectFileReady.execute(rprojFile);
                        }

                        @Override
                        public void onError(ServerError error) {
                            Debug.logError(error);
                            onProjectFileReady.execute(rprojFile);
                        }
                    });
                } else {
                    onProjectFileReady.execute(input);
                }
            }
        });
    } else {
        // in multi-session mode, we have a special dialog for opening projects
        WebFileDialogs webDialogs = (WebFileDialogs) dialogs;
        webDialogs.openProject(fsContext, FileSystemItem.createDir(defaultLocation), defaultType, showNewSession, onCompleted);
    }
}
Also used : OpenProjectParams(org.rstudio.studio.client.projects.model.OpenProjectParams) ServerError(org.rstudio.studio.client.server.ServerError) CommandWithArg(org.rstudio.core.client.CommandWithArg) WebFileDialogs(org.rstudio.studio.client.common.impl.WebFileDialogs) FileDialogs(org.rstudio.studio.client.common.FileDialogs) FileSystemItem(org.rstudio.core.client.files.FileSystemItem) WebFileDialogs(org.rstudio.studio.client.common.impl.WebFileDialogs) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback)

Example 32 with ProgressIndicator

use of org.rstudio.core.client.widget.ProgressIndicator 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 33 with ProgressIndicator

use of org.rstudio.core.client.widget.ProgressIndicator 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 34 with ProgressIndicator

use of org.rstudio.core.client.widget.ProgressIndicator 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 35 with ProgressIndicator

use of org.rstudio.core.client.widget.ProgressIndicator 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)

Aggregations

ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)51 ServerError (org.rstudio.studio.client.server.ServerError)26 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)16 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)15 Handler (org.rstudio.core.client.command.Handler)12 GlobalProgressDelayer (org.rstudio.studio.client.common.GlobalProgressDelayer)8 ProgressOperation (org.rstudio.core.client.widget.ProgressOperation)7 Command (com.google.gwt.user.client.Command)6 JsArrayString (com.google.gwt.core.client.JsArrayString)5 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)5 ProgressOperationWithInput (org.rstudio.core.client.widget.ProgressOperationWithInput)5 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 Operation (org.rstudio.core.client.widget.Operation)4 SourceLocation (org.rstudio.studio.client.common.synctex.model.SourceLocation)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 CloseHandler (com.google.gwt.event.logical.shared.CloseHandler)3 JSONString (com.google.gwt.json.client.JSONString)3 NativePreviewHandler (com.google.gwt.user.client.Event.NativePreviewHandler)3