From 35889b3c192beaa997aa46a17aa75c5d1582c1e8 Mon Sep 17 00:00:00 2001 From: leewyatt Date: Fri, 13 Dec 2024 02:28:29 +0900 Subject: [PATCH] Enforce DATE_RANGE mode in DateRangeView selection model. Added a listener to ensure only DATE_RANGE mode is supported in the selection model. Throwing an exception for unsupported modes to prevent invalid configurations and potential misuse. --- .../main/java/com/dlsc/gemsfx/daterange/DateRangeView.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gemsfx/src/main/java/com/dlsc/gemsfx/daterange/DateRangeView.java b/gemsfx/src/main/java/com/dlsc/gemsfx/daterange/DateRangeView.java index 290488a4..6003333e 100644 --- a/gemsfx/src/main/java/com/dlsc/gemsfx/daterange/DateRangeView.java +++ b/gemsfx/src/main/java/com/dlsc/gemsfx/daterange/DateRangeView.java @@ -40,6 +40,11 @@ public DateRangeView() { selectionModel = new SelectionModel(); selectionModel.setSelectionMode(SelectionModel.SelectionMode.DATE_RANGE); + selectionModel.selectionModeProperty().addListener(it -> { + if (selectionModel.getSelectionMode() != SelectionModel.SelectionMode.DATE_RANGE) { + throw new UnsupportedOperationException("SINGLE_DATE and MULTIPLE_DATES modes are not supported"); + } + }); startCalendarView = getStartCalendarView(); startCalendarView.setSelectionModel(selectionModel);