guard controller from NPE

Signed-off-by: Armin Schrenk <armin.schrenk@skymatic.de>
This commit is contained in:
Armin Schrenk
2025-12-05 16:43:39 +01:00
parent 8a834fe71c
commit 5c2954de03

View File

@@ -41,7 +41,11 @@ public class NotificationController implements FxController {
this.notificationsProp = new SimpleListProperty<>(notificationRadar.getEventsRequiringNotification());
this.selectionIndex = new SimpleIntegerProperty(0);
this.selectedEvent = new SimpleObjectProperty<>();
selectionIndex.addListener((_, _, n) -> selectedEvent.setValue(notificationsProp.get(n.intValue())));
selectionIndex.addListener((_, _, n) -> {
if (! notificationsProp.isEmpty()) {
selectedEvent.setValue(notificationsProp.get(n.intValue()));
}
});
selectedEvent.addListener(this::adjustTexts);
this.paging = Bindings.createStringBinding(() -> selectionIndex.get() + 1 + "/" + notificationsProp.size(), selectionIndex, notificationsProp);
this.message = new SimpleStringProperty();