Class CalendarControl

All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, com.globalmentor.model.MutableValued<Date>, com.globalmentor.model.Valued<Date>, io.clogr.Clogged, Component, CompositeComponent, Control, InputFocusableComponent, LayoutComponent, LayoutControl, ValueControl<Date>, ValuedComponent<Date>, Displayable, Enableable, InfoModel, LabelModel, Model, PresentationModel, ValueModel<Date>, DepictedObject

public class CalendarControl extends AbstractLayoutValueControl<Date>
Control that allows selection of a date. If the model used by the calendar control uses a RangeValidator with a date range of less than 100 years, a drop-down list will be used for the year control. Otherwise, a text input will be used for year selection.
Author:
Garret Wilson
  • Field Details

    • DATE_PROPERTY

      public static final String DATE_PROPERTY
      The visible date bound property.
    • yearPropertyChangeListener

      protected final com.globalmentor.beans.GenericPropertyChangeListener<Integer> yearPropertyChangeListener
      The property change listener that updates the visible dates if the year is different than the last one.
  • Constructor Details

    • CalendarControl

      public CalendarControl()
      Default constructor with a default data model.
    • CalendarControl

      public CalendarControl(ValueModel<Date> valueModel)
      Value model constructor.
      Parameters:
      valueModel - The component value model.
      Throws:
      NullPointerException - if the given value model is null.
  • Method Details

    • getControlContainer

      public Container getControlContainer()
      Returns:
      The container containing the controls.
    • getCalendarContainer

      public Container getCalendarContainer()
      Returns:
      The container containing the calendars.
    • getMonthListControl

      protected ListControl<Date> getMonthListControl()
      Returns:
      The list control containing the months.
    • getYearControl

      protected ValueControl<Integer> getYearControl()
      Returns:
      The control containing the year.
    • getCalendarTables

      protected Iterator<Table> getCalendarTables()
      Returns:
      An iterator to the calendar table components.
    • getDate

      public Date getDate()
      Returns:
      The date being viewed, not necessarily chosen.
    • setDate

      public void setDate(Date newDate)
      Sets the date being viewed. A copy will be made of the date before it is stored. This is a bound property.
      Parameters:
      newDate - The date to be viewed, not necessarily chosen.
      Throws:
      NullPointerException - if the given date is null.
      See Also:
    • updateYearControl

      protected void updateYearControl()
      Updates the year control by removing any old year control from the component and adding a new year control. If the model used by the calendar control uses a RangeValidator with a date range of less than 100 years, a drop-down list will be used for the year control. Otherwise, a text input will be used for year selection.
    • updateDateControls

      protected void updateDateControls()
      Updates the controls representing the date. This implementation updates the calendars on the calendar panel.
    • createDayRepresentationStrategy

      protected Table.CellRepresentationStrategy<Date> createDayRepresentationStrategy()
      Creates a representation strategy for each cell in a calendar. This version returns a new instance of CalendarControl.DayRepresentationStrategy.
      Returns:
      a representation strategy for each cell in a calendar.
      See Also: