Search in sources :

Example 16 with Operation

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

the class CreateBranchToolbarButton method promptUserRegardingRemoteBranchOfSameName.

private boolean promptUserRegardingRemoteBranchOfSameName(final CreateBranchDialog.Input input, final BranchesInfo branchesInfo) {
    final String targetBranch = "remotes/" + input.getRemote() + "/" + input.getBranch();
    final String remoteBranch = Functional.find(branchesInfo.getBranches(), new Functional.Predicate<String>() {

        @Override
        public boolean test(String branch) {
            return branch.equals(targetBranch);
        }
    });
    if (remoteBranch != null) {
        String message = "A remote branch named '" + input.getBranch() + "' already exists " + "on the remote repository '" + input.getRemote() + "'. Would you like " + "to check out that branch?";
        List<String> labels = new ArrayList<String>();
        labels.add("Checkout");
        labels.add("Cancel");
        List<Operation> operations = new ArrayList<Operation>();
        operations.add(new Operation() {

            @Override
            public void execute() {
                onCheckoutRemote(input);
            }
        });
        operations.add(new Operation() {

            @Override
            public void execute() {
            // no-op
            }
        });
        globalDisplay_.showGenericDialog(MessageDialog.INFO, "Remote Branch Already Exists", message, labels, operations, 1);
    }
    return remoteBranch != null;
}
Also used : Functional(org.rstudio.core.client.Functional) ArrayList(java.util.ArrayList) Operation(org.rstudio.core.client.widget.Operation)

Example 17 with Operation

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

the class TextEditingTargetNotebook method changeOutputMode.

private void changeOutputMode(String mode) {
    docDisplay_.setShowChunkOutputInline(mode == CHUNK_OUTPUT_INLINE);
    // manage commands
    manageCommands();
    // if we don't have any inline output, we're done
    if (outputs_.size() == 0 || mode != CHUNK_OUTPUT_CONSOLE)
        return;
    // if we do have inline output, offer to clean it up
    RStudioGinjector.INSTANCE.getGlobalDisplay().showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Remove Inline Chunk Output", "Do you want to clear all the existing chunk output from your " + "notebook?", false, new Operation() {

        @Override
        public void execute() {
            removeAllChunks();
        }
    }, new Operation() {

        @Override
        public void execute() {
        // no action necessary
        }
    }, null, "Remove Output", "Keep Output", false);
}
Also used : Operation(org.rstudio.core.client.widget.Operation)

Example 18 with Operation

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

the class DocUpdateSentinel method saveWithSuspendedAutoSave.

private void saveWithSuspendedAutoSave(String path, String fileType, String encoding, final ProgressIndicator progress) {
    autosaver_.suspend();
    doSave(path, fileType, encoding, new ProgressIndicator() {

        public void onProgress(String message) {
            onProgress(message, null);
        }

        public void onProgress(String message, Operation onCancel) {
            if (progress != null)
                progress.onProgress(message, onCancel);
        }

        public void clearProgress() {
            autosaver_.resume();
            if (progress != null)
                progress.clearProgress();
        }

        public void onCompleted() {
            autosaver_.resume();
            if (progress != null)
                progress.onCompleted();
        }

        public void onError(String message) {
            autosaver_.resume();
            if (progress != null)
                progress.onError(message);
        }
    });
}
Also used : ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) Operation(org.rstudio.core.client.widget.Operation)

Example 19 with Operation

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

the class Application method verifyAgreement.

private void verifyAgreement(SessionInfo sessionInfo, final Operation verifiedOperation) {
    // get the agreement (if any)
    final Agreement agreement = sessionInfo.pendingAgreement();
    // execute the verifiedOperation immediately)
    if (agreement != null) {
        // append updated to the title if necessary
        String title = agreement.getTitle();
        if (agreement.getUpdated())
            title += " (Updated)";
        view_.showApplicationAgreement(// title and contents   
        title, agreement.getContents(), // bail to sign in page if the user doesn't confirm
        new Operation() {

            public void execute() {
                if (Desktop.isDesktop()) {
                    Desktop.getFrame().setPendingQuit(DesktopFrame.PENDING_QUIT_AND_EXIT);
                    server_.quitSession(false, null, null, GWT.getHostPageBaseURL(), new SimpleRequestCallback<Boolean>());
                } else
                    navigateToSignIn();
            }
        }, // user confirmed
        new Operation() {

            public void execute() {
                // call verified operation
                verifiedOperation.execute();
                // record agreement on server
                server_.acceptAgreement(agreement, new VoidServerRequestCallback());
            }
        });
    } else {
        // no agreement pending
        verifiedOperation.execute();
    }
}
Also used : Agreement(org.rstudio.studio.client.workbench.model.Agreement) Operation(org.rstudio.core.client.widget.Operation) SimpleRequestCallback(org.rstudio.studio.client.common.SimpleRequestCallback)

Example 20 with Operation

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

the class ApplicationQuit method prepareForQuit.

public void prepareForQuit(final String caption, final boolean forceSaveAll, final QuitContext quitContext) {
    boolean busy = workbenchContext_.isServerBusy() || workbenchContext_.isTerminalBusy();
    String msg = null;
    if (busy) {
        if (workbenchContext_.isServerBusy() && !workbenchContext_.isTerminalBusy())
            msg = "The R session is currently busy.";
        else if (workbenchContext_.isServerBusy() && workbenchContext_.isTerminalBusy())
            msg = "The R session and the terminal are currently busy.";
        else
            msg = "The terminal is currently busy.";
    }
    eventBus_.fireEvent(new QuitInitiatedEvent());
    if (busy && !forceSaveAll) {
        globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, caption, msg + " Are you sure you want to quit?", new Operation() {

            @Override
            public void execute() {
                handleUnsavedChanges(caption, forceSaveAll, quitContext);
            }
        }, true);
    } else {
        // if we aren't restoring source documents then close them all now
        if (!pUiPrefs_.get().restoreSourceDocuments().getValue()) {
            sourceShim_.closeAllSourceDocs(caption, new Command() {

                @Override
                public void execute() {
                    handleUnsavedChanges(caption, forceSaveAll, quitContext);
                }
            });
        } else {
            handleUnsavedChanges(caption, forceSaveAll, quitContext);
        }
    }
}
Also used : Command(com.google.gwt.user.client.Command) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) QuitInitiatedEvent(org.rstudio.studio.client.application.events.QuitInitiatedEvent) Operation(org.rstudio.core.client.widget.Operation)

Aggregations

Operation (org.rstudio.core.client.widget.Operation)47 ServerError (org.rstudio.studio.client.server.ServerError)8 Command (com.google.gwt.user.client.Command)7 ArrayList (java.util.ArrayList)6 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)5 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)5 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)4 SimpleRequestCallback (org.rstudio.studio.client.common.SimpleRequestCallback)4 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)4 JsArrayString (com.google.gwt.core.client.JsArrayString)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)3 ProgressOperation (org.rstudio.core.client.widget.ProgressOperation)3 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 Timer (com.google.gwt.user.client.Timer)2 HTML (com.google.gwt.user.client.ui.HTML)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2 WindowEx (org.rstudio.core.client.dom.WindowEx)2 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)2