Search in sources :

Example 31 with VoidServerRequestCallback

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

the class ConnectionsPresenter method onViewConnectionDataset.

@Override
public void onViewConnectionDataset(ViewConnectionDatasetEvent event) {
    if (exploredConnection_ == null)
        return;
    GlobalProgressDelayer progress = new GlobalProgressDelayer(globalDisplay_, 100, "Previewing table...");
    server_.connectionPreviewTable(exploredConnection_.getId(), event.getDataset(), new VoidServerRequestCallback(progress.getIndicator()));
}
Also used : GlobalProgressDelayer(org.rstudio.studio.client.common.GlobalProgressDelayer) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback)

Example 32 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback 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 33 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback 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 34 with VoidServerRequestCallback

use of org.rstudio.studio.client.server.VoidServerRequestCallback 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 35 with VoidServerRequestCallback

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

the class CompilePdfOutputPresenter method confirmClose.

public void confirmClose(Command onConfirmed) {
    // wrap the onConfirmed in another command which notifies the server
    // that we've closed the tab
    final Command confirmedCommand = CommandUtil.join(onConfirmed, new Command() {

        @Override
        public void execute() {
            server_.compilePdfClosed(new VoidServerRequestCallback());
        }
    });
    server_.isCompilePdfRunning(new DelayedProgressRequestCallback<Boolean>("Closing Compile PDF...") {

        @Override
        public void onSuccess(Boolean isRunning) {
            if (isRunning) {
                confirmTerminateRunningCompile("close the Compile PDF tab", confirmedCommand);
            } else {
                confirmedCommand.execute();
            }
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback)

Aggregations

VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)44 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)14 Handler (org.rstudio.core.client.command.Handler)8 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)7 ServerError (org.rstudio.studio.client.server.ServerError)7 Command (com.google.gwt.user.client.Command)6 Operation (org.rstudio.core.client.widget.Operation)4 ProgressOperation (org.rstudio.core.client.widget.ProgressOperation)4 Void (org.rstudio.studio.client.server.Void)4 JsArrayString (com.google.gwt.core.client.JsArrayString)3 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)3 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)3 ArrayList (java.util.ArrayList)3 AppCommand (org.rstudio.core.client.command.AppCommand)3 ProgressOperationWithInput (org.rstudio.core.client.widget.ProgressOperationWithInput)3 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)3 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)3 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)3 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)3 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)2