use of org.rstudio.core.client.widget.TextEntryModalDialog in project rstudio by rstudio.
the class WebTextInput method promptForTextWithOption.
@Override
public void promptForTextWithOption(String title, String label, String initialValue, final boolean usePasswordMask, String extraOptionPrompt, boolean extraOptionDefault, int selectionStart, int selectionLength, String okButtonCaption, final ProgressOperationWithInput<PromptWithOptionResult> okOperation, Operation cancelOperation) {
// This variable introduces a level of pointer indirection that lets us
// get around passing TextEntryModalDialog a reference to itself in its
// own constructor.
final Value<TextEntryModalDialog> pDialog = new Value<TextEntryModalDialog>(null);
final TextEntryModalDialog dialog = new TextEntryModalDialog(title, label, initialValue, usePasswordMask, extraOptionPrompt, extraOptionDefault, false, selectionStart, selectionLength, okButtonCaption, 300, new ProgressOperationWithInput<String>() {
@Override
public void execute(String input, ProgressIndicator indicator) {
PromptWithOptionResult result = new PromptWithOptionResult();
result.input = input;
result.extraOption = pDialog.getValue().getExtraOption();
okOperation.execute(result, indicator);
}
}, cancelOperation) {
@Override
protected void positionAndShowDialog(final Command onCompleted) {
setPopupPositionAndShow(new PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
int left = (Window.getClientWidth() / 2) - (offsetWidth / 2);
int top = (Window.getClientHeight() / 2) - (offsetHeight / 2);
if (usePasswordMask)
top = 50;
setPopupPosition(left, top);
onCompleted.execute();
}
});
}
};
pDialog.setValue(dialog, false);
dialog.showModal();
}
Aggregations