Interface DateSelectionModel
- All Known Implementing Classes:
AbstractDateSelectionModel
,DaySelectionModel
,DefaultDateSelectionModel
,SingleDaySelectionModel
- Author:
- Joshua Outwater
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Selection Modes -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the specified listener to this model.void
addSelectionInterval
(Date startDate, Date endDate) Adds the specified selection interval to the selection model.void
Clears any selection from the selection model.Returns a clone of the calendar used by this model.int
Gets what the first day of the week is; e.g.,Calendar.SUNDAY
in the U.S.,Calendar.MONDAY
in France.Returns the earliest date in the selection or null if the selection is empty.Returns the latest date in the selection or null if the selection is empty.Returns the Locale of this model's calendar.Return the lower bound date that is allowed to be selected for this model.int
Gets the minimal number of days in the first week of the year.getNormalizedDate
(Date date) Returns a normalized Date as used by the implementation, if any.Returns the current selection.Get the selection mode.Returns the TimeZone of this model.Returns aSortedSet
ofDate
s that are unselectable.Return the upper bound date that is allowed to be selected for this model.boolean
Returns the property to decide whether the selection is intermediate or final.boolean
isSelected
(Date date) Returns true if the date specified is selected, false otherwise.boolean
Returns true if the selection is empty, false otherwise.boolean
isUnselectableDate
(Date unselectableDate) Returns true is the specified date is unselectable.void
Remove the specified listener to this model.void
removeSelectionInterval
(Date startDate, 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
Sets the Locale of this model's calendar.void
setLowerBound
(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
(Date startDate, Date endDate) Sest the specified selection interval to the selection model.void
Set the selection mode.void
setTimeZone
(TimeZone timeZone) Sets the TimeZone of this model.void
setUnselectableDates
(SortedSet<Date> unselectableDates) Sets a collection of dates which are not selectable.void
setUpperBound
(Date upperBound) Set the upper bound date that is allowed to be selected for this model.
-
Method Details
-
getSelectionMode
DateSelectionModel.SelectionMode getSelectionMode()Get the selection mode.- Returns:
- return the current selection mode
-
setSelectionMode
Set the selection mode.- Parameters:
mode
- new selection mode
-
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 isWEEK_INTERVAL_SELECTION
. PENDING JW: move week-interval selection from JXMonthView into the model.- Returns:
- int The first day of the week.
- See Also:
-
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:
-
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:
-
getTimeZone
TimeZone getTimeZone()Returns the TimeZone of this model.- Returns:
- the TimeZone of this model.
- See Also:
-
setTimeZone
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:
-
getLocale
Locale getLocale()Returns the Locale of this model's calendar.- Returns:
- the Locale of this model's calendar.
-
setLocale
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
Adds the specified selection interval to the selection model.- Parameters:
startDate
- interval start date, must not be nullendDate
- interval end date >= start date, must not be null- Throws:
NullPointerException
- if any of the dates is null
-
setSelectionInterval
Sest the specified selection interval to the selection model.- Parameters:
startDate
- interval start date, must not be nullendDate
- interval end date >= start date, must not be null- Throws:
NullPointerException
- if any of the dates is null
-
removeSelectionInterval
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 nullendDate
- 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
Returns the current selection.- Returns:
- sorted set of selected dates, guaranteed to be never null.
-
getFirstSelectionDate
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
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:
-
isSelected
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
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(); }
- Parameters:
date
- date to normalize- 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
Returns aSortedSet
ofDate
s that are unselectable.- Returns:
- sorted set of dates
-
setUnselectableDates
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
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
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
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
Add the specified listener to this model.- Parameters:
listener
- listener to add to this model
-
removeDateSelectionListener
Remove the specified listener to this model.- Parameters:
listener
- listener to remove from this model
-