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;
}
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);
}
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);
}
});
}
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();
}
}
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);
}
}
}
Aggregations