/** displays a popup to prompt the user for the URI or revert to default assignment
* @param left
* @param top
*/
void promptUserUri(int left, int top) {
final TextBoxBase textBox = new TextBox();
final MyDialog popup = new MyDialog(textBox) {
public boolean onKeyUpPreview(char key, int modifiers) {
// avoid ENTER from closing the popup without proper reaction
if ( key == KeyboardListener.KEY_ESCAPE ) {
hide(); // only ESCAPE keystroke closes the popup
return false;
}
if ( key == KeyboardListener.KEY_ENTER ) {
String str = textBox.getText().trim();
_processAccept(str, this);
}
return true;
}
};
popup.setText("Specify the namespace root for the ontology URI");
textBox.setWidth("300");
if ( namespaceRoot != null ) {
textBox.setText(namespaceRoot);
}
popup.getButtonsPanel().insert(
new PushButton("OK", new ClickListener() {
public void onClick(Widget sender) {
String str = textBox.getText().trim();
_processAccept(str, popup);
}
})
, 0
);
if ( userGiven ) {
popup.getButtonsPanel().insert(
new PushButton("Revert to default", new ClickListener() {
public void onClick(Widget sender) {
userGiven = false;
namespaceRoot = defaultNameSpace;
update();
popup.hide();
}
})
, 0
);
}
popup.setPopupPosition(left, top + 20);
new Timer() { @Override
public void run() {
textBox.setFocus(true);
}
}.schedule(180);
popup.show();