|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.swingx.calendar.AbstractDateSelectionModel
org.jdesktop.swingx.calendar.SingleDaySelectionModel
public class SingleDaySelectionModel
DateSelectionModel which allows a single selection only.
Temporary quick & dirty class to explore requirements as needed by a DatePicker. Need to define the states more exactly. Currently
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.jdesktop.swingx.calendar.DateSelectionModel |
---|
DateSelectionModel.SelectionMode |
Field Summary |
---|
Fields inherited from class org.jdesktop.swingx.calendar.AbstractDateSelectionModel |
---|
adjusting, calendar, EMPTY_DATES, listenerMap, locale, lowerBound, upperBound |
Constructor Summary | |
---|---|
SingleDaySelectionModel()
Instantiates a SingleDaySelectionModel with default locale. |
|
SingleDaySelectionModel(Locale locale)
Instantiates a SingleSelectionModel with the given locale. |
Method Summary | |
---|---|
void |
addSelectionInterval(Date startDate,
Date endDate)
Adds the specified selection interval to the selection model. |
void |
clearSelection()
Clears any selection from the selection model. |
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. |
boolean |
isSelectable(Date date)
Returns a boolean indicating whether the given date is selectable. |
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. |
protected boolean |
isSelectionInInterval(Date startDate,
Date endDate)
Checks and returns whether the selected date is contained in the interval given by startDate/endDate. |
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. |
protected void |
setSelection(Date date)
Selects the given date if it is selectable and not yet selected. |
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. |
Methods inherited from class org.jdesktop.swingx.calendar.AbstractDateSelectionModel |
---|
addDateSelectionListener, adjustDatesToTimeZone, endOfDay, fireValueChanged, getCalendar, getDateSelectionListeners, getFirstDayOfWeek, getLocale, getLowerBound, getMinimalDaysInFirstWeek, getTimeZone, getUpperBound, isAdjusting, isSameDay, removeDateSelectionListener, setAdjusting, setFirstDayOfWeek, setLocale, setLowerBound, setMinimalDaysInFirstWeek, setTimeZone, setUpperBound, startOfDay |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SingleDaySelectionModel()
public SingleDaySelectionModel(Locale locale)
locale
- the Locale to use with this model, defaults to Locale.default()
if null.Method Detail |
---|
public DateSelectionModel.SelectionMode getSelectionMode()
public void setSelectionMode(DateSelectionModel.SelectionMode selectionMode)
Implemented to do nothing.
selectionMode
- new selection modepublic void addSelectionInterval(Date startDate, Date endDate)
Implemented to call setSelectionInterval with startDate for both parameters.
startDate
- interval start date, must not be nullendDate
- interval end date >= start date, must not be nullpublic void setSelectionInterval(Date startDate, Date endDate)
PENDING JW: define what happens if we have a selection but the interval isn't selectable.
startDate
- interval start date, must not be nullendDate
- interval end date >= start date, must not be nullpublic void removeSelectionInterval(Date startDate, Date endDate)
startDate
- interval start date, must not be nullendDate
- interval end date >= start date, must not be nullprotected boolean isSelectionInInterval(Date startDate, Date endDate)
This implementation interprets the interval between the start of the day of startDay to the end of the day of endDate.
startDate
- the start of the interval, must not be nullendDate
- the end of the interval, must not be null
protected void setSelection(Date date)
date
- the Date to select, must not be null.public Date getFirstSelectionDate()
DateSelectionModel.getLastSelectionDate()
,
DateSelectionModel.getSelection()
,
DateSelectionModel.isSelectionEmpty()
public Date getLastSelectionDate()
DateSelectionModel.getFirstSelectionDate()
,
DateSelectionModel.getSelection()
,
DateSelectionModel.isSelectionEmpty()
public boolean isSelectable(Date date)
date
- the date to check for selectable, must not be null.
public void clearSelection()
public SortedSet<Date> getSelection()
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 null
public Date getNormalizedDate(Date date)
The overall contract:
if ((date != null) && isSelectable(date)) {
setSelectionInterval(date, date);
assertEquals(getNormalized(date), getFirstSelectionDate();
}
Implemented to return the date itself.
public boolean isSelectionEmpty()
public SortedSet<Date> getUnselectableDates()
SortedSet
of Dates that are unselectable.
- Returns:
- sorted set of dates
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |