return rr >= lines.length; // DONE
}
}
private void dispatchImportAction() {
final MyDialog popup = new MyDialog(null) {
public boolean onKeyUpPreview(char key, int modifiers) {
// avoid ENTER close the popup
if ( key == KeyboardListener.KEY_ESCAPE ) {
hide();
return false;
}
return true;
}
};
popup.setText("Import terms");
final TextArea textArea = popup.addTextArea(null);
textArea.setReadOnly(false);
textArea.setSize("800", "270");
VerticalPanel vp = new VerticalPanel();
vp.setSpacing(10);
popup.getDockPanel().add(vp, DockPanel.NORTH);
vp.add(new HTML(
"Select the separator character, insert the new contents into the text area, " +
"and click the \"Import\" button to update the table."
)
);
final SeparatorPanel separatorPanel = new SeparatorPanel();
vp.add(separatorPanel);
final HTML status = new HTML("");
textArea.addKeyboardListener(new KeyboardListenerAdapter(){
public void onKeyUp(Widget sender, char keyCode, int modifiers) {
status.setText("");
}
});
PushButton importButton = new PushButton("Import", new ClickListener() {
public void onClick(Widget sender) {
final String text = textArea.getText().trim();
if ( text.length() == 0 ) {
status.setHTML("<font color=\"red\">Empty contents</font>");
return;
}
if ( ! Window.confirm("This action will update the term table. (Previous contents will be discarded.)") ) {
return;
}
popup.hide();
importContents(separatorPanel.getSelectedSeparator().charAt(0), text);
}
});
popup.getButtonsPanel().insert(importButton, 0);
popup.getButtonsPanel().insert(status, 0);
popup.center();
popup.show();
}