* @return False if the selection is invalid. Otherwise,
* return whatever super.stopCellEditing() returns.
*/
public boolean stopCellEditing() {
// FIXME: do we need to get jTextField like this each time?
JFormattedTextField jFormattedTextField = (JFormattedTextField) getComponent();
if (jFormattedTextField.getText() == null) {
// FIXME: why does the selected item get set to null sometimes?
jFormattedTextField.setText("");
}
boolean valid = true;
if (_validator != null) {
valid = _validator.isValid(jFormattedTextField.getText());
}
if (!valid) {
if (_userWantsToEdit) {
// User already selected edit, don't ask twice.
_userWantsToEdit = false;
return false;
} else {
if (!userSaysRevert(jFormattedTextField.getText())) {
_userWantsToEdit = true;
return false; //don't let the editor go away
}
}
}