Skip to content

Commit

Permalink
Enforce DATE_RANGE mode in DateRangeView selection model.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
leewyatt committed Dec 12, 2024
1 parent 237cdb9 commit 35889b3
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 35889b3

Please sign in to comment.