I'm using TableViewEditor a lot and I noticed in my code that for all
TableViewEditor, I have
tableViewRowEditor.getRowEditorListeners().add(new
TableView.RowEditorListener.Adapter() {
private boolean shown = false;
private boolean invalid = false;
@Override
public Vote previewSaveChanges(RowEditor rowEditor, TableView
tableView, int rowIndex, int columnIndex, Dictionary<String, Object>
changes) {
invalid = usernameTI.getText().isEmpty() ||
passwordTI.getText().isEmpty();
String errorMsg = (usernameTI.getText().isEmpty() ?
"Username" : "") +
(passwordTI.getText().isEmpty() ?
"Password" : "") +
" cannot be empty";
if (invalid) {
if (!shown) {
Prompt.prompt(MessageType.ERROR, errorMsg, null,
main.getWindow(),
new SheetCloseListener() {
public void sheetClosed(Sheet sheet) {
shown = false;
}
});
shown = true;
}
return Vote.DENY;
}
return Vote.APPROVE;
}});
I'm thinking maybe I could just add validation to TableViewEditor. Something
like
tableViewRowEditor.getValidators().add(
org.apache.pivot.wtk.text.validation.Validator )