Interface DateSelectionModel

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addDateSelectionListener​(DateSelectionListener listener)
      Add the specified listener to this model.
      void addSelectionInterval​(java.util.Date startDate, java.util.Date endDate)
      Adds the specified selection interval to the selection model.
      void clearSelection()
      Clears any selection from the selection model.
      java.util.Calendar getCalendar()
      Returns a clone of the calendar used by this model.
      int getFirstDayOfWeek()
      Gets what the first day of the week is; e.g., Calendar.SUNDAY in the U.S., Calendar.MONDAY in France.
      java.util.Date getFirstSelectionDate()
      Returns the earliest date in the selection or null if the selection is empty.
      java.util.Date getLastSelectionDate()
      Returns the latest date in the selection or null if the selection is empty.
      java.util.Locale getLocale()
      Returns the Locale of this model's calendar.
      java.util.Date getLowerBound()
      Return the lower bound date that is allowed to be selected for this model.
      int getMinimalDaysInFirstWeek()
      Gets the minimal number of days in the first week of the year.
      java.util.Date getNormalizedDate​(java.util.Date date)
      Returns a normalized Date as used by the implementation, if any.
      java.util.SortedSet<java.util.Date> getSelection()
      Returns the current selection.
      DateSelectionModel.SelectionMode getSelectionMode()
      Get the selection mode.
      java.util.TimeZone getTimeZone()
      Returns the TimeZone of this model.
      java.util.SortedSet<java.util.Date> getUnselectableDates()
      Returns a SortedSet of Dates that are unselectable.
      java.util.Date getUpperBound()
      Return the upper bound date that is allowed to be selected for this model.
      boolean isAdjusting()
      Returns the property to decide whether the selection is intermediate or final.
      boolean isSelected​(java.util.Date date)
      Returns true if the date specified is selected, false otherwise.
      boolean isSelectionEmpty()
      Returns true if the selection is empty, false otherwise.
      boolean isUnselectableDate​(java.util.Date unselectableDate)
      Returns true is the specified date is unselectable.
      void removeDateSelectionListener​(DateSelectionListener listener)
      Remove the specified listener to this model.
      void removeSelectionInterval​(java.util.Date startDate, java.util.Date endDate)
      Removes the specifed selection interval from the selection model.
      void setAdjusting​(boolean adjusting)
      Set the property to mark upcoming selections as intermediate/ final.
      void setFirstDayOfWeek​(int firstDayOfWeek)
      Sets what the first day of the week is.
      void setLocale​(java.util.Locale locale)
      Sets the Locale of this model's calendar.
      void setLowerBound​(java.util.Date lowerBound)
      Set the lower bound date that is allowed to be selected for this model.
      void setMinimalDaysInFirstWeek​(int minimalDays)
      Sets the minimal number of days in the first week of the year.
      void setSelectionInterval​(java.util.Date startDate, java.util.Date endDate)
      Sest the specified selection interval to the selection model.
      void setSelectionMode​(DateSelectionModel.SelectionMode mode)
      Set the selection mode.
      void setTimeZone​(java.util.TimeZone timeZone)
      Sets the TimeZone of this model.
      void setUnselectableDates​(java.util.SortedSet<java.util.Date> unselectableDates)
      Sets a collection of dates which are not selectable.
      void setUpperBound​(java.util.Date upperBound)
      Set the upper bound date that is allowed to be selected for this model.
    • Method Detail

      • getCalendar

        java.util.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
      • getTimeZone

        java.util.TimeZone getTimeZone()
        Returns the TimeZone of this model.
        Returns:
        the TimeZone of this model.
        See Also:
        setTimeZone(TimeZone)
      • setTimeZone

        void setTimeZone​(java.util.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

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

        void setLocale​(java.util.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​(java.util.Date startDate,
                                  java.util.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:
        java.lang.NullPointerException - if any of the dates is null
      • setSelectionInterval

        void setSelectionInterval​(java.util.Date startDate,
                                  java.util.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:
        java.lang.NullPointerException - if any of the dates is null
      • removeSelectionInterval

        void removeSelectionInterval​(java.util.Date startDate,
                                     java.util.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:
        java.lang.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

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

        java.util.Date getFirstSelectionDate()
        Returns the earliest date in the selection or null if the selection is empty.
        Returns:
        the earliest date in the selection, or null if isSelectionEmpty.
        See Also:
        getLastSelectionDate(), getSelection(), isSelectionEmpty()
      • getLastSelectionDate

        java.util.Date getLastSelectionDate()
        Returns the latest date in the selection or null if the selection is empty.
        Returns:
        the lastest date in the selection, or null if isSelectionEmpty.
        See Also:
        getFirstSelectionDate(), getSelection(), isSelectionEmpty()
      • isSelected

        boolean isSelected​(java.util.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:
        java.lang.NullPointerException - if the date is null
      • getNormalizedDate

        java.util.Date getNormalizedDate​(java.util.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:
        java.lang.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

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

        void setUnselectableDates​(java.util.SortedSet<java.util.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​(java.util.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

        java.util.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​(java.util.Date upperBound)
        Set the upper bound date that is allowed to be selected for this model.
        Parameters:
        upperBound - upper bound
      • getLowerBound

        java.util.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​(java.util.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