Search in sources :

Example 26 with ProgressIndicator

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

the class EnvironmentPresenter method onClearWorkspace.

void onClearWorkspace() {
    view_.bringToFront();
    final List<String> objectNames = view_.getSelectedObjects();
    new ClearAllDialog(objectNames.size(), new ProgressOperationWithInput<Boolean>() {

        @Override
        public void execute(Boolean includeHidden, ProgressIndicator indicator) {
            indicator.onProgress("Removing objects...");
            if (objectNames.size() == 0) {
                server_.removeAllObjects(includeHidden, new VoidServerRequestCallback(indicator) {

                    @Override
                    public void onSuccess() {
                        view_.clearSelection();
                        view_.clearObjects();
                    }
                });
            } else {
                server_.removeObjects(objectNames, new VoidServerRequestCallback(indicator) {

                    @Override
                    public void onSuccess() {
                        view_.clearSelection();
                        for (String obj : objectNames) {
                            view_.removeObject(obj);
                        }
                    }
                });
            }
        }
    }).showModal();
}
Also used : ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) JsArrayString(com.google.gwt.core.client.JsArrayString) ProgressOperationWithInput(org.rstudio.core.client.widget.ProgressOperationWithInput)

Example 27 with ProgressIndicator

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

the class PathBreadcrumbWidget method browse.

private void browse() {
    if (Desktop.isDesktop()) {
        FileSystemContext tempContext = RStudioGinjector.INSTANCE.getRemoteFileSystemContext();
        RStudioGinjector.INSTANCE.getFileDialogs().chooseFolder("Go To Folder", tempContext, null, new ProgressOperationWithInput<FileSystemItem>() {

            public void execute(FileSystemItem input, ProgressIndicator indicator) {
                if (input == null)
                    return;
                context_.cd(input.getPath());
                indicator.onCompleted();
            }
        });
    } else {
        context_.messageDisplay().promptForText("Go To Folder", "Path to folder (use ~ for home directory):", "", new OperationWithInput<String>() {

            @Override
            public void execute(String input) {
                if (input == null)
                    return;
                context_.cd(input);
            }
        });
    }
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) FileSystemContext(org.rstudio.core.client.files.FileSystemContext)

Example 28 with ProgressIndicator

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

the class DependencyManager method processDependencyRequest.

private void processDependencyRequest(final DependencyRequest req) {
    // convert dependencies to JsArray, excluding satisfied dependencies
    final JsArray<Dependency> deps = JsArray.createArray().cast();
    for (int i = 0; i < req.dependencies.length; i++) {
        boolean satisfied = false;
        for (Dependency d : satisfied_) {
            if (req.dependencies[i].isEqualTo(d)) {
                satisfied = true;
                break;
            }
        }
        if (!satisfied)
            deps.push(req.dependencies[i]);
    }
    // if no unsatisfied dependencies were found, we're done already
    if (deps.length() == 0) {
        req.onComplete.execute(true);
        return;
    }
    // create progress indicator
    final ProgressIndicator progress = new GlobalProgressDelayer(globalDisplay_, 250, req.progressCaption + "...").getIndicator();
    // query for unsatisfied dependencies
    server_.unsatisfiedDependencies(deps, req.silentEmbeddedUpdate, new ServerRequestCallback<JsArray<Dependency>>() {

        @Override
        public void onResponseReceived(final JsArray<Dependency> unsatisfiedDeps) {
            progress.onCompleted();
            updateSatisfied(deps, unsatisfiedDeps);
            // if we've satisfied all dependencies then execute the command
            if (unsatisfiedDeps.length() == 0) {
                req.onComplete.execute(true);
                return;
            }
            // check to see if we can satisfy the version requirement for all
            // dependencies
            String unsatisfiedVersions = "";
            for (int i = 0; i < unsatisfiedDeps.length(); i++) {
                if (!unsatisfiedDeps.get(i).getVersionSatisfied()) {
                    unsatisfiedVersions += unsatisfiedDeps.get(i).getName() + " " + unsatisfiedDeps.get(i).getVersion();
                    String version = unsatisfiedDeps.get(i).getAvailableVersion();
                    if (version.isEmpty())
                        unsatisfiedVersions += " is not available\n";
                    else
                        unsatisfiedVersions += " is required but " + version + " is available\n";
                }
            }
            if (!unsatisfiedVersions.isEmpty()) {
                // error if we can't satisfy requirements
                globalDisplay_.showErrorMessage(StringUtil.isNullOrEmpty(req.userAction) ? "Packages Not Found" : req.userAction, "Required package versions could not be found:\n\n" + unsatisfiedVersions + "\n" + "Check that getOption(\"repos\") refers to a CRAN " + "repository that contains the needed package versions.");
                req.onComplete.execute(false);
            } else {
                // otherwise ask the user if they want to install the 
                // unsatisifed dependencies
                final CommandWithArg<Boolean> installCommand = new CommandWithArg<Boolean>() {

                    @Override
                    public void execute(Boolean confirmed) {
                        // bail if user didn't confirm
                        if (!confirmed) {
                            req.onComplete.execute(false);
                            return;
                        }
                        // the incoming JsArray from the server may not serialize
                        // as expected when this code is executed from a satellite
                        // (see RemoteServer.sendRequestViaMainWorkbench), so we
                        // clone it before passing to the dependency installer
                        JsArray<Dependency> newArray = JsArray.createArray().cast();
                        newArray.setLength(unsatisfiedDeps.length());
                        for (int i = 0; i < unsatisfiedDeps.length(); i++) {
                            newArray.set(i, unsatisfiedDeps.get(i));
                        }
                        installDependencies(newArray, req.silentEmbeddedUpdate, req.onComplete);
                    }
                };
                if (req.userPrompt != null) {
                    req.userPrompt.execute(describeDepPkgs(unsatisfiedDeps), new Command() {

                        @Override
                        public void execute() {
                            installCommand.execute(true);
                        }
                    });
                } else {
                    confirmPackageInstallation(req.userAction, unsatisfiedDeps, installCommand);
                }
            }
        }

        @Override
        public void onError(ServerError error) {
            progress.onError(error.getUserMessage());
            req.onComplete.execute(false);
        }
    });
}
Also used : JsArray(com.google.gwt.core.client.JsArray) ServerError(org.rstudio.studio.client.server.ServerError) GlobalProgressDelayer(org.rstudio.studio.client.common.GlobalProgressDelayer) Dependency(org.rstudio.studio.client.common.dependencies.model.Dependency) CommandWithArg(org.rstudio.core.client.CommandWithArg) Command(com.google.gwt.user.client.Command) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator)

Example 29 with ProgressIndicator

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

the class Synctex method doInverseSearch.

private void doInverseSearch(JavaScriptObject pdfLocationObject) {
    PdfLocation pdfLocation = pdfLocationObject.cast();
    final ProgressIndicator indicator = getSyncProgress();
    server_.synctexInverseSearch(pdfLocation, new ServerRequestCallback<SourceLocation>() {

        @Override
        public void onResponseReceived(SourceLocation location) {
            indicator.onCompleted();
            if (location != null)
                goToSourceLocation(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)

Example 30 with ProgressIndicator

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

the class Synctex method forwardSearch.

// NOTE: the original design was for a single internal pdf viewer. for
// that configuration we could keep a global pdfPath_ around and be
// confident that it was always correct. we were also globally managing
// the state of the synctex command based on any external viewer closing.
// now that we optionally support desktop viewers for synctex this 
// assumption may not hold -- specfically there might be multiple active
// PDF viewers for different document or we might not know that the 
// external viewer has closed . we have explicitly chosen to 
// avoid the complexity of tracking distinct viewer states. if we want
// to do this we probably should do the following:
//
//    - always keep the the syncex command available in all editors
//      so long as there is at least one preview window alive; OR
//
//    - for cases where we do know whether the window is still alive
//      editors could dynamically show/hide their synctex button
//      based on that more granular state
//
public boolean forwardSearch(final String pdfFile, SourceLocation sourceLocation) {
    if (handleDesktopSynctex()) {
        // apply concordane
        final ProgressIndicator indicator = getSyncProgress();
        server_.applyForwardConcordance(pdfFile, sourceLocation, new ServerRequestCallback<SourceLocation>() {

            @Override
            public void onResponseReceived(SourceLocation sourceLocation) {
                indicator.onCompleted();
                if (sourceLocation != null) {
                    Desktop.getFrame().externalSynctexView(pdfFile, sourceLocation.getFile(), sourceLocation.getLine(), sourceLocation.getColumn());
                }
            }

            @Override
            public void onError(ServerError error) {
                indicator.onError(error.getUserMessage());
            }
        });
        return true;
    } else // use internal viewer
    {
        doForwardSearch(targetFile_, sourceLocation);
        return true;
    }
}
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)

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