dlsc-software-consulting-gmbh / GemsFX

A collection of JavaFX controls and utilities.
Apache License 2.0
436 stars 51 forks source link

Proposal to Evaluate and Refine Properties in CalendarView #143

Closed leewyatt closed 1 month ago

leewyatt commented 1 month ago

This proposal addresses several issue in the CalendarView component. Our aim is to streamline the component and enhance clarity for developers.

Redundant Property Usage:

The disableMonthDropdownButtonProperty and disableYearDropdownButtonProperty are redundant as their functionality is effectively managed by other properties like monthSelectionViewEnabledProperty.

image

Unnecessary Binding Dependencies:

The binding of yearSpinnerBox.visibleProperty() to showYearDropdownProperty is unnecessary because dropdown visibility is controllable through view.setShowMonthDropdown(false), and customization options allow the monthDropdownArrowButton to diverge from being a typical arrow button. This dependency could be removed to simplify component behavior.

image

Redundant Mouse Click Event Handlers:

The button used as the graphic in dateLabel has its own setOnMouseClick event handler, which is redundant because dateLabel already handles mouse clicks with similar logic. This redundancy can be removed to streamline interactions and reduce code complexity.

yearDropdownArrowButton.setOnMouseClicked(evt -> viewMode.set(ViewMode.YEAR));

yearLabel.setGraphic(yearDropdownArrowButton);

 yearLabel.setOnMouseClicked(evt -> {
            if (view.isYearSelectionViewEnabled()) {
                viewMode.set(ViewMode.YEAR);
            }
        });

// mothLabel & monthDropdownArrowButton also has the same problem
dlemmermann commented 1 month ago

The two properties "show month dropdown" and "enable month selection view" are not redundant as the first one shows or hides the dropdown arrow while the second one enables the month selection view in general. If NO dropdown is shown the user can still click on the month to bring up the month selection view.

dlemmermann commented 1 month ago

The properties "year spinner" vs. "year dropdown" could be replaced with an enum:

Similar for the month:

dlemmermann commented 1 month ago

Redundant listeners for mouse clicks can be removed.