Little bit of code cleanup

This commit is contained in:
0xb00bface 2020-11-21 20:47:19 +01:00
parent 628c92cc67
commit 80ce269298
1 changed files with 18 additions and 1 deletions

View File

@ -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");
}
}