org.jdesktop.swingx.calendar
Class AbstractDateSelectionModel

java.lang.Object
  extended by org.jdesktop.swingx.calendar.AbstractDateSelectionModel
All Implemented Interfaces:
DateSelectionModel
Direct Known Subclasses:
DaySelectionModel, DefaultDateSelectionModel, SingleDaySelectionModel

public abstract class AbstractDateSelectionModel
extends java.lang.Object
implements DateSelectionModel

Abstract base implementation of DateSelectionModel. Implements notification, Calendar related properties and lower/upper bounds.

Author:
Jeanette Winzenburg

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jdesktop.swingx.calendar.DateSelectionModel
DateSelectionModel.SelectionMode
 
Field Summary
static java.util.SortedSet<java.util.Date> EMPTY_DATES
           
 
Constructor Summary
AbstractDateSelectionModel()
          Instantiates a DateSelectionModel with default locale.
AbstractDateSelectionModel(java.util.Locale locale)
          Instantiates a DateSelectionModel with the given locale.
 
Method Summary
 void addDateSelectionListener(DateSelectionListener l)
          Add the specified listener to this model.
 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.
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jdesktop.swingx.calendar.DateSelectionModel
addSelectionInterval, clearSelection, getFirstSelectionDate, getLastSelectionDate, getNormalizedDate, getSelection, getSelectionMode, getUnselectableDates, isSelected, isSelectionEmpty, isUnselectableDate, removeSelectionInterval, setSelectionInterval, setSelectionMode, setUnselectableDates
 

Field Detail

EMPTY_DATES

public static final java.util.SortedSet<java.util.Date> EMPTY_DATES
Constructor Detail

AbstractDateSelectionModel

public AbstractDateSelectionModel()
Instantiates a DateSelectionModel with default locale.


AbstractDateSelectionModel

public AbstractDateSelectionModel(java.util.Locale locale)
Instantiates a DateSelectionModel with the given locale. If the locale is null, the Locale's default is used. PENDING JW: fall back to JComponent.getDefaultLocale instead? We use this with components anyway?

Parameters:
locale - the Locale to use with this model, defaults to Locale.default() if null.
Method Detail

getCalendar

public java.util.Calendar getCalendar()
Returns a clone of the calendar used by this model. It's date is unspecified.

Specified by:
getCalendar in interface DateSelectionModel
Returns:
a clone of the calendar used by this model.

getFirstDayOfWeek

public 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.

Specified by:
getFirstDayOfWeek in interface DateSelectionModel
Returns:
int The first day of the week.
See Also:
DateSelectionModel.setFirstDayOfWeek(int)

setFirstDayOfWeek

public 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?

Specified by:
setFirstDayOfWeek in interface DateSelectionModel
Parameters:
firstDayOfWeek - The first day of the week.
See Also:
DateSelectionModel.getFirstDayOfWeek(), Calendar

getMinimalDaysInFirstWeek

public int getMinimalDaysInFirstWeek()
Gets the minimal number of days in the first week of the year.

Specified by:
getMinimalDaysInFirstWeek in interface DateSelectionModel
Returns:
int the minimal number of days in the first week of the year.

setMinimalDaysInFirstWeek

public 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?

Specified by:
setMinimalDaysInFirstWeek in interface DateSelectionModel
Parameters:
minimalDays - the minimal number of days in the first week of the year.
See Also:
DateSelectionModel.getMinimalDaysInFirstWeek(), Calendar

getTimeZone

public java.util.TimeZone getTimeZone()
Returns the TimeZone of this model.

Specified by:
getTimeZone in interface DateSelectionModel
Returns:
the TimeZone of this model.
See Also:
DateSelectionModel.setTimeZone(TimeZone)

setTimeZone

public 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?

Specified by:
setTimeZone in interface DateSelectionModel
Parameters:
timeZone - the TimeZone to use in this model, must not be null.
See Also:
DateSelectionModel.getTimeZone()

getLocale

public java.util.Locale getLocale()
Returns the Locale of this model's calendar.

Specified by:
getLocale in interface DateSelectionModel
Returns:
the Locale of this model's calendar.

setLocale

public 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?

Specified by:
setLocale in interface DateSelectionModel
Parameters:
locale - the Locale to use. If null, the default Locale is used.

getUpperBound

public java.util.Date getUpperBound()
Return the upper bound date that is allowed to be selected for this model.

Specified by:
getUpperBound in interface DateSelectionModel
Returns:
upper bound date or null if not set

setUpperBound

public void setUpperBound(java.util.Date upperBound)
Set the upper bound date that is allowed to be selected for this model.

Specified by:
setUpperBound in interface DateSelectionModel
Parameters:
upperBound - upper bound

getLowerBound

public java.util.Date getLowerBound()
Return the lower bound date that is allowed to be selected for this model.

Specified by:
getLowerBound in interface DateSelectionModel
Returns:
lower bound date or null if not set

setLowerBound

public void setLowerBound(java.util.Date lowerBound)
Set the lower bound date that is allowed to be selected for this model.

Specified by:
setLowerBound in interface DateSelectionModel
Parameters:
lowerBound - lower bound date or null if not set

isAdjusting

public boolean isAdjusting()
Returns the property to decide whether the selection is intermediate or final.

Specified by:
isAdjusting in interface DateSelectionModel
Returns:
the adjusting property.

setAdjusting

public 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.

Specified by:
setAdjusting in interface DateSelectionModel
Parameters:
adjusting - a flag to turn the adjusting property on/off.

addDateSelectionListener

public void addDateSelectionListener(DateSelectionListener l)
Add the specified listener to this model.

Specified by:
addDateSelectionListener in interface DateSelectionModel
Parameters:
l - listener to add to this model

removeDateSelectionListener

public void removeDateSelectionListener(DateSelectionListener l)
Remove the specified listener to this model.

Specified by:
removeDateSelectionListener in interface DateSelectionModel
Parameters:
l - listener to remove from this model

getDateSelectionListeners

public java.util.List<DateSelectionListener> getDateSelectionListeners()