DateSelectionModel
DaySelectionModel
, DefaultDateSelectionModel
, SingleDaySelectionModel
public abstract class AbstractDateSelectionModel extends java.lang.Object implements DateSelectionModel
DateSelectionModel.SelectionMode
Modifier and Type | Field | Description |
---|---|---|
protected boolean |
adjusting |
|
protected java.util.Calendar |
calendar |
|
static java.util.SortedSet<java.util.Date> |
EMPTY_DATES |
|
protected EventListenerMap |
listenerMap |
|
protected java.util.Locale |
locale |
the locale used by the calendar.
|
protected java.util.Date |
lowerBound |
|
protected java.util.Date |
upperBound |
Constructor | Description |
---|---|
AbstractDateSelectionModel() |
Instantiates a DateSelectionModel with default locale.
|
AbstractDateSelectionModel(java.util.Locale locale) |
Instantiates a DateSelectionModel with the given locale.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addDateSelectionListener(DateSelectionListener l) |
Add the specified listener to this model.
|
protected void |
adjustDatesToTimeZone(java.util.TimeZone oldTimeZone) |
Adjusts all stored dates to a new time zone.
|
protected java.util.Date |
endOfDay(java.util.Date date) |
Returns the end of the day of the given date in this model's calendar.
|
protected void |
fireValueChanged(DateSelectionEvent.EventType eventType) |
|
java.util.Calendar |
getCalendar() |
Returns a clone of the calendar used by this model.
|
java.util.List<DateSelectionListener> |
getDateSelectionListeners() |
|
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.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.TimeZone |
getTimeZone() |
Returns the TimeZone of this model.
|
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.
|
protected boolean |
isSameDay(java.util.Date selected,
java.util.Date compare) |
Returns a boolean indicating whether the given dates are on the same day in
the coordinates of the model's calendar.
|
void |
removeDateSelectionListener(DateSelectionListener l) |
Remove the specified listener to this 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 |
setTimeZone(java.util.TimeZone timeZone) |
Sets the TimeZone of this model.
|
void |
setUpperBound(java.util.Date upperBound) |
Set the upper bound date that is allowed to be selected for this model.
|
protected java.util.Date |
startOfDay(java.util.Date date) |
Returns the start of the day of the given date in this model's calendar.
|
addSelectionInterval, clearSelection, getFirstSelectionDate, getLastSelectionDate, getNormalizedDate, getSelection, getSelectionMode, getUnselectableDates, isSelected, isSelectionEmpty, isUnselectableDate, removeSelectionInterval, setSelectionInterval, setSelectionMode, setUnselectableDates
public static final java.util.SortedSet<java.util.Date> EMPTY_DATES
protected EventListenerMap listenerMap
protected boolean adjusting
protected java.util.Calendar calendar
protected java.util.Date upperBound
protected java.util.Date lowerBound
protected java.util.Locale locale
NOTE: need to keep separately as a Calendar has no getter.
public AbstractDateSelectionModel()
public AbstractDateSelectionModel(java.util.Locale locale)
locale
- the Locale to use with this model, defaults to Locale.default()
if null.public java.util.Calendar getCalendar()
getCalendar
in interface DateSelectionModel
public int getFirstDayOfWeek()
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.getFirstDayOfWeek
in interface DateSelectionModel
DateSelectionModel.setFirstDayOfWeek(int)
public void setFirstDayOfWeek(int firstDayOfWeek)
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?
setFirstDayOfWeek
in interface DateSelectionModel
firstDayOfWeek
- The first day of the week.DateSelectionModel.getFirstDayOfWeek()
,
Calendar
public int getMinimalDaysInFirstWeek()
getMinimalDaysInFirstWeek
in interface DateSelectionModel
public void setMinimalDaysInFirstWeek(int minimalDays)
setMinimalDaysInFirstWeek
in interface DateSelectionModel
minimalDays
- the minimal number of days in the first week of the year.DateSelectionModel.getMinimalDaysInFirstWeek()
,
Calendar
public java.util.TimeZone getTimeZone()
getTimeZone
in interface DateSelectionModel
DateSelectionModel.setTimeZone(TimeZone)
public void setTimeZone(java.util.TimeZone timeZone)
setTimeZone
in interface DateSelectionModel
timeZone
- the TimeZone to use in this model, must not be null.DateSelectionModel.getTimeZone()
protected void adjustDatesToTimeZone(java.util.TimeZone oldTimeZone)
This implementation resets all dates to null, clears everything. Subclasses may override to really map to the new time zone.
oldTimeZone
- the old time zonepublic java.util.Locale getLocale()
getLocale
in interface DateSelectionModel
public void setLocale(java.util.Locale locale)
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?
setLocale
in interface DateSelectionModel
locale
- the Locale to use. If null, the default Locale is used.protected java.util.Date startOfDay(java.util.Date date)
date
- the Date to get the start for.protected java.util.Date endOfDay(java.util.Date date)
date
- the Date to get the start for.protected boolean isSameDay(java.util.Date selected, java.util.Date compare)
selected
- one of the dates to check, must not be null.compare
- the other of the dates to check, must not be null.public java.util.Date getUpperBound()
getUpperBound
in interface DateSelectionModel
public void setUpperBound(java.util.Date upperBound)
setUpperBound
in interface DateSelectionModel
upperBound
- upper boundpublic java.util.Date getLowerBound()
getLowerBound
in interface DateSelectionModel
public void setLowerBound(java.util.Date lowerBound)
setLowerBound
in interface DateSelectionModel
lowerBound
- lower bound date or null if not setpublic boolean isAdjusting()
isAdjusting
in interface DateSelectionModel
public void setAdjusting(boolean adjusting)
setAdjusting
in interface DateSelectionModel
adjusting
- a flag to turn the adjusting property on/off.public void addDateSelectionListener(DateSelectionListener l)
addDateSelectionListener
in interface DateSelectionModel
l
- listener to add to this modelpublic void removeDateSelectionListener(DateSelectionListener l)
removeDateSelectionListener
in interface DateSelectionModel
l
- listener to remove from this modelpublic java.util.List<DateSelectionListener> getDateSelectionListeners()
protected void fireValueChanged(DateSelectionEvent.EventType eventType)