public class DaySelectionModel extends AbstractDateSelectionModel
DateSelectionModel.SelectionMode
Modifier and Type | Field and Description |
---|---|
private SortedSet<Date> |
selectedDates |
private DateSelectionModel.SelectionMode |
selectionMode |
private SortedSet<Date> |
unselectableDates |
adjusting, calendar, EMPTY_DATES, listenerMap, locale, lowerBound, upperBound
Constructor and Description |
---|
DaySelectionModel() |
DaySelectionModel(Locale locale) |
Modifier and Type | Method and Description |
---|---|
private boolean |
addSelectionImpl(Date startDate,
Date endDate) |
void |
addSelectionInterval(Date startDate,
Date endDate)
Adds the specified selection interval to the selection model.
|
void |
clearSelection()
Clears any selection from the selection model.
|
private void |
clearSelectionImpl() |
Date |
getFirstSelectionDate()
Returns the earliest date in the selection or null if the selection is empty.
|
Date |
getLastSelectionDate()
Returns the latest date in the selection or null if the selection is empty.
|
Date |
getNormalizedDate(Date date)
Returns a normalized Date as used by the implementation, if any.
|
SortedSet<Date> |
getSelection()
Returns the current selection.
|
DateSelectionModel.SelectionMode |
getSelectionMode()
Get the selection mode.
|
SortedSet<Date> |
getUnselectableDates()
Returns a
SortedSet of Dates that are unselectable. |
private boolean |
isIntervalSelected(Date startDate,
Date endDate)
Checks and returns if the single date interval bounded by startDate and endDate
is selected.
|
boolean |
isSelected(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(Date date)
Returns true is the specified date is unselectable.
|
void |
removeSelectionInterval(Date startDate,
Date endDate)
Removes the specifed selection interval from the selection model.
|
void |
setSelectionInterval(Date startDate,
Date endDate)
Sest the specified selection interval to the selection model.
|
void |
setSelectionMode(DateSelectionModel.SelectionMode selectionMode)
Set the selection mode.
|
void |
setUnselectableDates(SortedSet<Date> unselectables)
Sets a collection of dates which are not selectable.
|
addDateSelectionListener, adjustDatesToTimeZone, endOfDay, fireValueChanged, getCalendar, getDateSelectionListeners, getFirstDayOfWeek, getLocale, getLowerBound, getMinimalDaysInFirstWeek, getTimeZone, getUpperBound, isAdjusting, isSameDay, removeDateSelectionListener, setAdjusting, setFirstDayOfWeek, setLocale, setLowerBound, setMinimalDaysInFirstWeek, setTimeZone, setUpperBound, startOfDay
private DateSelectionModel.SelectionMode selectionMode
private SortedSet<Date> selectedDates
private SortedSet<Date> unselectableDates
public DaySelectionModel()
public DaySelectionModel(Locale locale)
public DateSelectionModel.SelectionMode getSelectionMode()
DateSelectionModel
public void setSelectionMode(DateSelectionModel.SelectionMode selectionMode)
DateSelectionModel
selectionMode
- new selection modepublic void addSelectionInterval(Date startDate, Date endDate)
startDate
- interval start date, must not be nullendDate
- interval end date >= start date, must not be nullpublic void setSelectionInterval(Date startDate, Date endDate)
startDate
- interval start date, must not be nullendDate
- interval end date >= start date, must not be nullprivate boolean isIntervalSelected(Date startDate, Date endDate)
startDate
- the start of the intervalendDate
- the end of the interval, must be >= startDatepublic void removeSelectionInterval(Date startDate, Date endDate)
startDate
- interval start date, must not be nullendDate
- interval end date >= start date, must not be nullpublic void clearSelection()
private void clearSelectionImpl()
public SortedSet<Date> getSelection()
public Date getFirstSelectionDate()
DateSelectionModel.getLastSelectionDate()
,
DateSelectionModel.getSelection()
,
DateSelectionModel.isSelectionEmpty()
public Date getLastSelectionDate()
DateSelectionModel.getFirstSelectionDate()
,
DateSelectionModel.getSelection()
,
DateSelectionModel.isSelectionEmpty()
public boolean isSelected(Date date)
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().
date
- date to check for selection, must not be nullpublic boolean isSelectionEmpty()
public SortedSet<Date> getUnselectableDates()
SortedSet
of Dates that are unselectable.
public void setUnselectableDates(SortedSet<Date> unselectables)
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?
unselectables
- dates that are unselectable, must not be null and
must not contain null dates.public boolean isUnselectableDate(Date date)
date
- the date to check for unselectability, must not be null.private boolean addSelectionImpl(Date startDate, Date endDate)
public Date getNormalizedDate(Date date)
The overall contract:
if ((date != null) && isSelectable(date)) {
setSelectionInterval(date, date);
assertEquals(getNormalized(date), getFirstSelectionDate();
}
Implemented to return the start of the day which contains the date.
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses