Search in sources :

Example 41 with ProgressIndicator

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

the class Packages method withPackageInstallContext.

private void withPackageInstallContext(final OperationWithInput<PackageInstallContext> operation) {
    final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error");
    indicator.onProgress("Retrieving package installation context...");
    server_.getPackageInstallContext(new SimpleRequestCallback<PackageInstallContext>() {

        @Override
        public void onResponseReceived(PackageInstallContext context) {
            indicator.onCompleted();
            operation.execute(context);
        }

        @Override
        public void onError(ServerError error) {
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) PackageInstallContext(org.rstudio.studio.client.workbench.views.packages.model.PackageInstallContext)

Example 42 with ProgressIndicator

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

the class Packages method onInstallPackage.

void onInstallPackage() {
    withPackageInstallContext(new OperationWithInput<PackageInstallContext>() {

        @Override
        public void execute(final PackageInstallContext installContext) {
            if (installContext.isDefaultLibraryWriteable()) {
                continueInstallPackage(installContext);
            } else {
                globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Create Package Library", "Would you like to create a personal library '" + installContext.getDefaultUserLibraryPath() + "' " + "to install packages into?", false, new // Yes operation
                Operation() {

                    @Override
                    public void execute() {
                        ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error Creating Library");
                        server_.initDefaultUserLibrary(new VoidServerRequestCallback(indicator) {

                            @Override
                            protected void onSuccess() {
                                // call this function back recursively
                                // so we can retrieve the updated 
                                // PackageInstallContext from the server
                                onInstallPackage();
                            }
                        });
                    }
                }, new // No operation
                Operation() {

                    @Override
                    public void execute() {
                        globalDisplay_.showMessage(MessageDialog.WARNING, "Install Packages", "Unable to install packages (default library '" + installContext.getDefaultLibraryPath() + "' is " + "not writeable)");
                    }
                }, true);
            }
        }
    });
}
Also used : ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) Operation(org.rstudio.core.client.widget.Operation) PackageInstallContext(org.rstudio.studio.client.workbench.views.packages.model.PackageInstallContext)

Example 43 with ProgressIndicator

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

the class FilesCopy method copyNextFile.

private void copyNextFile(final ArrayList<FileSystemItem> filesQueue, final FileSystemItem targetDirectory, final Command completedCommand) {
    // terminate if there are no files left
    if (filesQueue.size() == 0) {
        if (completedCommand != null)
            completedCommand.execute();
        return;
    }
    // remove the first file from the list
    final FileSystemItem sourceFile = filesQueue.remove(0);
    // determine the default name and default selection
    final String COPY_PREFIX = "CopyOf";
    String defaultName = COPY_PREFIX + sourceFile.getName();
    int defaultSelectionLength = COPY_PREFIX.length() + sourceFile.getStem().length();
    // show prompt for new filename
    final String objectName = sourceFile.isDirectory() ? "Folder" : "File";
    globalDisplay_.promptForText("Copy " + objectName, "Enter a name for the copy of '" + sourceFile.getName() + "':", defaultName, 0, defaultSelectionLength, null, new ProgressOperationWithInput<String>() {

        public void execute(String input, ProgressIndicator progress) {
            progress.onProgress("Copying " + objectName.toLowerCase() + "...");
            String targetFilePath = targetDirectory.completePath(input);
            final FileSystemItem targetFile = FileSystemItem.createFile(targetFilePath);
            server_.copyFile(sourceFile, targetFile, false, new VoidServerRequestCallback(progress) {

                @Override
                protected void onSuccess() {
                    // copy the next file in the queue
                    copyNextFile(filesQueue, targetDirectory, completedCommand);
                }
            });
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback)

Example 44 with ProgressIndicator

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

the class History method onClearHistory.

@Handler
void onClearHistory() {
    view_.bringToFront();
    globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_WARNING, "Confirm Clear History", "Are you sure you want to clear all history entries?", new ProgressOperation() {

        public void execute(final ProgressIndicator indicator) {
            indicator.onProgress("Clearing history...");
            server_.clearHistory(new VoidServerRequestCallback(indicator));
        }
    }, true);
}
Also used : ProgressOperation(org.rstudio.core.client.widget.ProgressOperation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ConsoleResetHistoryHandler(org.rstudio.studio.client.workbench.views.console.events.ConsoleResetHistoryHandler) SelectionCommitHandler(org.rstudio.core.client.events.SelectionCommitHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) HistoryEntriesAddedHandler(org.rstudio.studio.client.workbench.views.history.events.HistoryEntriesAddedHandler) FetchCommandsHandler(org.rstudio.studio.client.workbench.views.history.events.FetchCommandsHandler) Handler(org.rstudio.core.client.command.Handler)

Example 45 with ProgressIndicator

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

the class Source method onNewSweaveDoc.

@Handler
public void onNewSweaveDoc() {
    // set concordance value if we need to
    String concordance = new String();
    if (uiPrefs_.alwaysEnableRnwConcordance().getValue()) {
        RnwWeave activeWeave = rnwWeaveRegistry_.findTypeIgnoreCase(uiPrefs_.defaultSweaveEngine().getValue());
        if (activeWeave.getInjectConcordance())
            concordance = "\\SweaveOpts{concordance=TRUE}\n";
    }
    final String concordanceValue = concordance;
    // show progress
    final ProgressIndicator indicator = new GlobalProgressDelayer(globalDisplay_, 500, "Creating new document...").getIndicator();
    // get the template
    server_.getSourceTemplate("", "sweave.Rnw", new ServerRequestCallback<String>() {

        @Override
        public void onResponseReceived(String templateContents) {
            indicator.onCompleted();
            // add in concordance if necessary
            final boolean hasConcordance = concordanceValue.length() > 0;
            if (hasConcordance) {
                String beginDoc = "\\begin{document}\n";
                templateContents = templateContents.replace(beginDoc, beginDoc + concordanceValue);
            }
            newDoc(FileTypeRegistry.SWEAVE, templateContents, new ResultCallback<EditingTarget, ServerError>() {

                @Override
                public void onSuccess(EditingTarget target) {
                    int startRow = 4 + (hasConcordance ? 1 : 0);
                    target.setCursorPosition(Position.create(startRow, 0));
                }
            });
        }

        @Override
        public void onError(ServerError error) {
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : RnwWeave(org.rstudio.studio.client.common.rnw.RnwWeave) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) GlobalProgressDelayer(org.rstudio.studio.client.common.GlobalProgressDelayer) TextEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget) EditingTarget(org.rstudio.studio.client.workbench.views.source.editors.EditingTarget) DataEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget) CodeBrowserEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget) JSONString(com.google.gwt.json.client.JSONString) JsArrayString(com.google.gwt.core.client.JsArrayString) NativePreviewHandler(com.google.gwt.user.client.Event.NativePreviewHandler) FileTypeChangedHandler(org.rstudio.studio.client.workbench.views.source.editors.text.events.FileTypeChangedHandler) Handler(org.rstudio.core.client.command.Handler) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) SelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler) CloseHandler(com.google.gwt.event.logical.shared.CloseHandler) ViewDataHandler(org.rstudio.studio.client.workbench.views.data.events.ViewDataHandler) SourceOnSaveChangedHandler(org.rstudio.studio.client.workbench.views.source.editors.text.events.SourceOnSaveChangedHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) OpenSourceFileHandler(org.rstudio.studio.client.common.filetypes.events.OpenSourceFileHandler)

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