Interface DateSelectionModel

    • Method Detail

      • getCalendar

        Calendar getCalendar()
        Returns a clone of the calendar used by this model. It's date is unspecified.
        Returns:
        a clone of the calendar used by this model.
      • getFirstDayOfWeek

        int getFirstDayOfWeek()
        Gets what the first day of the week is; e.g., Calendar.SUNDAY in the U.S., Calendar.MONDAY in France. This is needed when the model selection mode is WEEK_INTERVAL_SELECTION. PENDING JW: move week-interval selection from JXMonthView into the model.
        Returns:
        int The first day of the week.
        See Also:
        setFirstDayOfWeek(int)
      • setFirstDayOfWeek

        void setFirstDayOfWeek​(int firstDayOfWeek)
        Sets what the first day of the week is. E.g., Calendar.SUNDAY in US, Calendar.MONDAY in France. Fires a DateSelectionEvent of type CALENDAR_CHANGED, if the value is different from the old.

        The default value depends on the Calendar's default. PENDING JW: actually, it's a bound property. Use a propertyChangeListener?

        Parameters:
        firstDayOfWeek - The first day of the week.
        See Also:
        getFirstDayOfWeek(), Calendar
      • getMinimalDaysInFirstWeek

        int getMinimalDaysInFirstWeek()
        Gets the minimal number of days in the first week of the year.
        Returns:
        int the minimal number of days in the first week of the year.
      • setMinimalDaysInFirstWeek

        void setMinimalDaysInFirstWeek​(int minimalDays)
        Sets the minimal number of days in the first week of the year. Fires a DateSelectionEvent of type CALENDAR_CHANGED, if the value is different from the old. The default value depends on the Calendar's default. PENDING JW: actually, it's a bound property. Use a propertyChangeListener?
        Parameters:
        minimalDays - the minimal number of days in the first week of the year.
        See Also:
        getMinimalDaysInFirstWeek(), Calendar
      • setTimeZone

        void setTimeZone​(TimeZone timeZone)
        Sets the TimeZone of this model. Fires a DateSelectionEvent of type CALENDAR_CHANGED if the new value is different from the old. The default value depends on the Calendar's default. PENDING JW: actually, it's a bound property. Use a propertyChangeListener?
        Parameters:
        timeZone - the TimeZone to use in this model, must not be null.
        See Also:
        getTimeZone()
      • getLocale

        Locale getLocale()
        Returns the Locale of this model's calendar.
        Returns:
        the Locale of this model's calendar.
      • setLocale

        void setLocale​(Locale locale)
        Sets the Locale of this model's calendar. Fires a DateSelectionEvent of type CALENDAR_CHANGED if the new value is different from the old.

        The default value is Locale.default().

        PENDING JW: fall back to JComponent.getDefaultLocale instead? We use this with components anyway?

        PENDING JW: actually, it's a bound property. Use a propertyChangeListener?

        Parameters:
        locale - the Locale to use. If null, the default Locale is used.
      • addSelectionInterval

        void addSelectionInterval​(Date startDate,
                                  Date endDate)
        Adds the specified selection interval to the selection model.
        Parameters:
        startDate - interval start date, must not be null
        endDate - interval end date >= start date, must not be null
        Throws:
        NullPointerException - if any of the dates is null
      • setSelectionInterval

        void setSelectionInterval​(Date startDate,
                                  Date endDate)
        Sest the specified selection interval to the selection model.
        Parameters:
        startDate - interval start date, must not be null
        endDate - interval end date >= start date, must not be null
        Throws:
        NullPointerException - if any of the dates is null
      • removeSelectionInterval

        void removeSelectionInterval​(Date startDate,
                                     Date endDate)
        Removes the specifed selection interval from the selection model. If the selection is changed by this method, it fires a DateSelectionEvent of type DATES_REMOVED.
        Parameters:
        startDate - interval start date, must not be null
        endDate - interval end date >= start date, must not be null
        Throws:
        NullPointerException - if any of the dates is null
      • clearSelection

        void clearSelection()
        Clears any selection from the selection model. Fires an Event of type SELECTION_CLEARED if there had been a selection, does nothing otherwise.
      • getSelection

        SortedSet<Date> getSelection()
        Returns the current selection.
        Returns:
        sorted set of selected dates, guaranteed to be never null.
      • isSelected

        boolean isSelected​(Date date)
        Returns true if the date specified is selected, false otherwise.

        Note: it is up to implementations to define the exact notion of selected. It does not imply the exact date as given is contained the set returned from getSelection().

        Parameters:
        date - date to check for selection, must not be null
        Returns:
        true if the date is selected, false otherwise
        Throws:
        NullPointerException - if the date is null
      • getNormalizedDate

        Date getNormalizedDate​(Date date)
        Returns a normalized Date as used by the implementation, if any. F.i. DaySelectionModel returns the start of the day in the model's calendar. If no normalization is applied, a clone of the Date itself is returned. The given Date is never changed.

        The overall contract:

        
         if ((date != null) && isSelectable(date)) {
             setSelectionInterval(date, date);
             assertEquals(getNormalized(date), getFirstSelectionDate();
         }
         
        Returns:
        the date as it would be normalized before used in the model, must not be null.
        Throws:
        NullPointerException - if given date is null.
      • isSelectionEmpty

        boolean isSelectionEmpty()
        Returns true if the selection is empty, false otherwise.
        Returns:
        true if the selection is empty, false otherwise
      • getUnselectableDates

        SortedSet<Date> getUnselectableDates()
        Returns a SortedSet of Dates that are unselectable.
        Returns:
        sorted set of dates
      • setUnselectableDates

        void setUnselectableDates​(SortedSet<Date> unselectableDates)
        Sets a collection of dates which are not selectable.

        Note: it is up to implementations to define the exact notion of unselectableDate. It does not imply the only the exact date as given is unselectable, it might have a period like "all dates on the same day". PENDING JW: any collection would do - why insist on a SortedSet?

        Parameters:
        unselectableDates - dates that are unselectable, must not be null and must not contain null dates.
      • isUnselectableDate

        boolean isUnselectableDate​(Date unselectableDate)
        Returns true is the specified date is unselectable.
        Parameters:
        unselectableDate - the date to check for unselectability, must not be null.
        Returns:
        true is the date is unselectable, false otherwise
      • getUpperBound

        Date getUpperBound()
        Return the upper bound date that is allowed to be selected for this model.
        Returns:
        upper bound date or null if not set
      • setUpperBound

        void setUpperBound​(Date upperBound)
        Set the upper bound date that is allowed to be selected for this model.
        Parameters:
        upperBound - upper bound
      • getLowerBound

        Date getLowerBound()
        Return the lower bound date that is allowed to be selected for this model.
        Returns:
        lower bound date or null if not set
      • setLowerBound

        void setLowerBound​(Date lowerBound)
        Set the lower bound date that is allowed to be selected for this model.
        Parameters:
        lowerBound - lower bound date or null if not set
      • setAdjusting

        void setAdjusting​(boolean adjusting)
        Set the property to mark upcoming selections as intermediate/ final. This will fire a event of type adjusting_start/stop. The default value is false. Note: Client code marking as intermediate must take care of finalizing again.
        Parameters:
        adjusting - a flag to turn the adjusting property on/off.
      • isAdjusting

        boolean isAdjusting()
        Returns the property to decide whether the selection is intermediate or final.
        Returns:
        the adjusting property.
      • addDateSelectionListener

        void addDateSelectionListener​(DateSelectionListener listener)
        Add the specified listener to this model.
        Parameters:
        listener - listener to add to this model
      • removeDateSelectionListener

        void removeDateSelectionListener​(DateSelectionListener listener)
        Remove the specified listener to this model.
        Parameters:
        listener - listener to remove from this model