forked from j62/ctbrec
Little bit of code cleanup
This commit is contained in:
parent
628c92cc67
commit
80ce269298
|
@ -546,7 +546,10 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
}
|
||||
|
||||
private void jumpToNextModel(KeyCode code) {
|
||||
if (!table.getItems().isEmpty() && (code.isLetterKey() || code.isDigitKey())) {
|
||||
try {
|
||||
ensureTableIsNotEmpty();
|
||||
ensureKeyCodeIsLetterOrDigit(code);
|
||||
|
||||
// determine where to start looking for the next model
|
||||
int startAt = 0;
|
||||
if (table.getSelectionModel().getSelectedIndex() >= 0) {
|
||||
|
@ -571,6 +574,20 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
i = 0;
|
||||
}
|
||||
} while (i != startAt);
|
||||
} catch (IllegalStateException | IllegalArgumentException e) {
|
||||
// GUI was not in the state to process the user input
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureKeyCodeIsLetterOrDigit(KeyCode code) {
|
||||
if (!(code.isLetterKey() || code.isDigitKey())) {
|
||||
throw new IllegalArgumentException("keycode not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureTableIsNotEmpty() {
|
||||
if (table.getItems().isEmpty()) {
|
||||
throw new IllegalStateException("table is empty");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue