use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class ConnectionsPresenter method disconnectConnection.
private void disconnectConnection(boolean prompt) {
if (exploredConnection_ == null)
return;
// define connect operation
final Operation connectOperation = new Operation() {
@Override
public void execute() {
server_.getDisconnectCode(exploredConnection_.getId(), new SimpleRequestCallback<String>() {
@Override
public void onResponseReceived(String disconnectCode) {
eventBus_.fireEvent(new SendToConsoleEvent(disconnectCode, true));
}
});
}
};
if (prompt) {
StringBuilder builder = new StringBuilder();
builder.append("Are you sure you want to disconnect from Spark?");
globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Disconnect", builder.toString(), connectOperation, true);
} else {
connectOperation.execute();
}
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class RnwWeaveSelectWidget method verifyAvailable.
protected void verifyAvailable(final RnwWeave weave) {
// first check if it was already available at startup
TexCapabilities texCap = session_.getSessionInfo().getTexCapabilities();
if (texCap.isRnwWeaveAvailable(weave))
return;
server_.getTexCapabilities(new ServerRequestCallback<TexCapabilities>() {
@Override
public void onResponseReceived(TexCapabilities capabilities) {
if (!capabilities.isRnwWeaveAvailable(weave)) {
globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Confirm Change", "The " + weave.getPackageName() + " package is required " + "for " + weave.getName() + " weaving, " + "however it is not currently installed. You should " + "ensure that " + weave.getPackageName() + " is installed " + "prior to compiling a PDF." + "\n\nAre you sure you want to change this option?", false, new Operation() {
@Override
public void execute() {
}
}, new Operation() {
@Override
public void execute() {
setValue(rnwWeaveRegistry_.getTypes().get(0).getName());
}
}, false);
}
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
}
});
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class RPubsUploadDialog method createMainWidget.
@Override
protected Widget createMainWidget() {
Styles styles = RESOURCES.styles();
SimplePanel mainPanel = new SimplePanel();
mainPanel.addStyleName(styles.mainWidget());
VerticalPanel verticalPanel = new VerticalPanel();
HorizontalPanel headerPanel = new HorizontalPanel();
headerPanel.addStyleName(styles.headerPanel());
headerPanel.add(new Image(new ImageResource2x(RESOURCES.publishLarge2x())));
Label headerLabel = new Label("Publish to RPubs");
headerLabel.addStyleName(styles.headerLabel());
headerPanel.add(headerLabel);
headerPanel.setCellVerticalAlignment(headerLabel, HasVerticalAlignment.ALIGN_MIDDLE);
verticalPanel.add(headerPanel);
String msg;
if (!isPublished_ && uploadId_.isEmpty()) {
msg = "RPubs is a free service from RStudio for sharing " + "documents on the web. Click Publish to get " + "started.";
} else {
msg = "This document has already been published on RPubs. You can " + "choose to either update the existing RPubs document, or " + "create a new one.";
}
Label descLabel = new Label(msg);
descLabel.addStyleName(styles.descLabel());
verticalPanel.add(descLabel);
// if we have a generator then show title and comment UI
if (htmlGenerator_ != null) {
Label titleLabel = new Label("Title (optional):");
titleLabel.addStyleName(styles.fieldLabel());
verticalPanel.add(titleLabel);
titleTextBox_ = new TextBox();
titleTextBox_.addStyleName(styles.titleTextBox());
titleTextBox_.getElement().setAttribute("spellcheck", "false");
verticalPanel.add(titleTextBox_);
Label commentLabel = new Label("Comment (optional):");
commentLabel.addStyleName(styles.fieldLabel());
verticalPanel.add(commentLabel);
commentTextArea_ = new FixedTextArea(6);
commentTextArea_.addStyleName(styles.commentTextArea());
verticalPanel.add(commentTextArea_);
// not using either for now
titleLabel.setVisible(false);
titleTextBox_.setVisible(false);
commentLabel.setVisible(false);
commentTextArea_.setVisible(false);
previewButton_ = new ThemedButton("Preview");
previewButton_.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
htmlGenerator_.generateStaticHtml(titleTextBox_.getText().trim(), commentTextArea_.getText().trim(), new CommandWithArg<String>() {
@Override
public void execute(String rpubsFile) {
globalDisplay_.showHtmlFile(rpubsFile);
}
});
}
});
addLeftButton(previewButton_);
}
HTML warningLabel = new HTML("<strong>IMPORTANT: All documents published to RPubs are " + "publicly visible.</strong> You should " + "only publish documents that you wish to share publicly.");
warningLabel.addStyleName(styles.warningLabel());
verticalPanel.add(warningLabel);
ThemedButton cancelButton = createCancelButton(new Operation() {
@Override
public void execute() {
// if an upload is in progress then terminate it
if (uploader_.isUploadInProgress()) {
uploader_.terminateUpload();
}
}
});
continueButton_ = new ThemedButton("Publish", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
performUpload(false);
}
});
updateButton_ = new ThemedButton("Update Existing", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
performUpload(true);
}
});
createButton_ = new ThemedButton("Create New", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
performUpload(false);
}
});
if (!isPublished_ && uploadId_.isEmpty()) {
addOkButton(continueButton_);
addCancelButton(cancelButton);
} else {
addOkButton(updateButton_);
addButton(createButton_);
addCancelButton(cancelButton);
}
mainPanel.setWidget(verticalPanel);
return mainPanel;
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class RStudioAPI method showDialog.
private void showDialog(String caption, String message, final String url) {
VerticalPanel verticalPanel = new VerticalPanel();
verticalPanel.addStyleName(RES.styles().textInfoWidget());
SafeHtml safeMsg = DialogHtmlSanitizer.sanitizeHtml(message);
HTML msg = new HTML(safeMsg.asString());
msg.setWidth("100%");
verticalPanel.add(msg);
if (!StringUtil.isNullOrEmpty(url)) {
HyperlinkLabel link = new HyperlinkLabel(url, new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
RStudioGinjector.INSTANCE.getGlobalDisplay().openWindow(url);
}
});
link.addStyleName(RES.styles().installLink());
verticalPanel.add(link);
}
MessageDialog dlg = new MessageDialog(MessageDialog.INFO, caption, verticalPanel);
dlg.addButton("OK", new Operation() {
@Override
public void execute() {
server_.showDialogCompleted(null, false, new SimpleRequestCallback<Void>());
}
}, true, false);
dlg.showModal();
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class DesktopApplicationHeader method respondToUpdateCheck.
private void respondToUpdateCheck(final UpdateCheckResult result, boolean manual) {
boolean ignoredUpdate = false;
if (result.getUpdateVersion().length() > 0) {
JsArrayString ignoredUpdates = ignoredUpdates_.getIgnoredUpdates();
for (int i = 0; i < ignoredUpdates.length(); i++) {
if (ignoredUpdates.get(i).equals(result.getUpdateVersion())) {
ignoredUpdate = true;
}
}
}
if (result.getUpdateVersion().length() > 0 && !ignoredUpdate) {
ArrayList<String> buttonLabels = new ArrayList<String>();
ArrayList<Operation> buttonOperations = new ArrayList<Operation>();
buttonLabels.add("Quit and Download...");
buttonOperations.add(new Operation() {
@Override
public void execute() {
appQuit_.prepareForQuit("Update RStudio", new QuitContext() {
@Override
public void onReadyToQuit(boolean saveChanges) {
Desktop.getFrame().browseUrl(result.getUpdateUrl());
appQuit_.performQuit(saveChanges);
}
});
}
});
buttonLabels.add("Remind Later");
buttonOperations.add(new Operation() {
@Override
public void execute() {
// Don't do anything here; the prompt will re-appear the next
// time we do an update check
}
});
// Only provide the option to ignore the update if it's not urgent.
if (result.getUpdateUrgency() == 0) {
buttonLabels.add("Ignore Update");
buttonOperations.add(new Operation() {
@Override
public void execute() {
ignoredUpdates_.addIgnoredUpdate(result.getUpdateVersion());
ignoredUpdatesDirty_ = true;
}
});
}
globalDisplay_.showGenericDialog(GlobalDisplay.MSG_QUESTION, "Update Available", result.getUpdateMessage(), buttonLabels, buttonOperations, 0);
} else if (manual) {
globalDisplay_.showMessage(GlobalDisplay.MSG_INFO, "No Update Available", "You're using the newest version of RStudio.");
}
}
Aggregations