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