Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jdesktop.swingx.calendar
Class SingleDaySelectionModel

    java.lang.Object
      org.jdesktop.swingx.calendar.AbstractDateSelectionModel
          org.jdesktop.swingx.calendar.SingleDaySelectionModel

All Implemented Interfaces:
  DateSelectionModel

    public class SingleDaySelectionModel

extends AbstractDateSelectionModel

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

- takes all Dates as-are (that is the normalized is the same as the given): selected, unselectable, lower/upper bounds
- interprets any Date between the start/end of day of the selected as selected
- interprets any Date between the start/end of an unselectable date as unselectable
- interprets the lower/upper bounds as being the start/end of the given dates, that is any Date after the start of day of the lower and before the end of day of the upper is selectable.

  Author:
    Jeanette Winzenburg

  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(java.util.Locale locale)` Instantiates a SingleSelectionModel with the given locale.

  Method Summary
  `void` | `addSelectionInterval(java.util.Date startDate, java.util.Date endDate)` Adds the specified selection interval to the selection model.
  `void` | `clearSelection()` Clears any selection from the selection model.
  `java.util.Date` | `getFirstSelectionDate()` Returns the earliest date in the selection or null if the selection is empty.
  `java.util.Date` | `getLastSelectionDate()` Returns the latest date in the selection or null if the selection is empty.
  `java.util.Date` | `getNormalizedDate(java.util.Date date)` Returns a normalized Date as used by the implementation, if any.
  `java.util.SortedSet<java.util.Date>` | `getSelection()` Returns the current selection.
  `DateSelectionModel.SelectionMode` | `getSelectionMode()` Get the selection mode.
  `java.util.SortedSet<java.util.Date>` | `getUnselectableDates()` Returns a `SortedSet` of `Dates that are unselectable.`
  `boolean` | `isSelectable(java.util.Date date)` Returns a boolean indicating whether the given date is selectable.
  `boolean` | `isSelected(java.util.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(java.util.Date startDate, java.util.Date endDate)` Checks and returns whether the selected date is contained in the interval given by startDate/endDate.
  `boolean` | `isUnselectableDate(java.util.Date date)` Returns true is the specified date is unselectable.
  `void` | `removeSelectionInterval(java.util.Date startDate, java.util.Date endDate)` Removes the specifed selection interval from the selection model.
  `protected void` | `setSelection(java.util.Date date)` Selects the given date if it is selectable and not yet selected.
  `void` | `setSelectionInterval(java.util.Date startDate, java.util.Date endDate)` Sest the specified selection interval to the selection model.
  `void` | `setSelectionMode(DateSelectionModel.SelectionMode selectionMode)` Set the selection mode.
  `void` | `setUnselectableDates(java.util.SortedSet<java.util.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

  ### SingleDaySelectionModel

      public SingleDaySelectionModel()

    Instantiates a SingleDaySelectionModel with default locale.

  ### SingleDaySelectionModel

      public SingleDaySelectionModel(java.util.Locale locale)

    Instantiates a SingleSelectionModel 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

  ### getSelectionMode

      public DateSelectionModel.SelectionMode getSelectionMode()

    Get the selection mode.

    Returns:
      return the current selection mode

  ### setSelectionMode

      public void setSelectionMode(DateSelectionModel.SelectionMode selectionMode)

    Set the selection mode.

    Implemented to do nothing.

    Parameters:
      `selectionMode` - new selection mode

  ### addSelectionInterval

      public void addSelectionInterval(java.util.Date startDate,
                                       java.util.Date endDate)

    Adds the specified selection interval to the selection model.

    Implemented to call setSelectionInterval with startDate for both parameters.

    Parameters:
      `startDate` - interval start date, must not be null
      `endDate` - interval end date >= start date, must not be null

  ### setSelectionInterval

      public void setSelectionInterval(java.util.Date startDate,
                                       java.util.Date endDate)

    Sest the specified selection interval to the selection model.

    PENDING JW: define what happens if we have a selection but the interval isn't selectable.

    Parameters:
      `startDate` - interval start date, must not be null
      `endDate` - interval end date >= start date, must not be null

  ### removeSelectionInterval

      public void removeSelectionInterval(java.util.Date startDate,
                                          java.util.Date endDate)

    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 null
      `endDate` - interval end date >= start date, must not be null

  ### isSelectionInInterval

      protected boolean isSelectionInInterval(java.util.Date startDate,
                                              java.util.Date endDate)

    Checks and returns whether the selected date is contained in the interval given by startDate/endDate. The selection must not be empty when calling this method.

    This implementation interprets the interval between the start of the day of startDay to the end of the day of endDate.

    Parameters:
      `startDate` - the start of the interval, must not be null
      `endDate` - the end of the interval, must not be null
    Returns:
      true if the selected date is contained in the interval

  ### setSelection

      protected void setSelection(java.util.Date date)

    Selects the given date if it is selectable and not yet selected. Does nothing otherwise. If this operation changes the current selection, it will fire a DateSelectionEvent of type DATES_SET.

    Parameters:
      `date` - the Date to select, must not be null.

  ### getFirstSelectionDate

      public java.util.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:
      `DateSelectionModel.getLastSelectionDate()`, `DateSelectionModel.getSelection()`, `DateSelectionModel.isSelectionEmpty()`

  ### getLastSelectionDate

      public java.util.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:
      `DateSelectionModel.getFirstSelectionDate()`, `DateSelectionModel.getSelection()`, `DateSelectionModel.isSelectionEmpty()`

  ### isSelectable

      public boolean isSelectable(java.util.Date date)

    Returns a boolean indicating whether the given date is selectable.

    Parameters:
      `date` - the date to check for selectable, must not be null.
    Returns:
      true if the given date is selectable, false if not.

  ### clearSelection

      public 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

      public java.util.SortedSet<java.util.Date> getSelection()

    Returns the current selection.

    Returns:
      sorted set of selected dates, guaranteed to be never null.

  ### isSelected

      public boolean isSelected(java.util.Date date)

    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

  ### getNormalizedDate

      public java.util.Date getNormalizedDate(java.util.Date date)

    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();
         }

    Implemented to return the date itself.

    Returns:
      the date as it would be normalized before used in the model, must not be null.

  ### isSelectionEmpty

      public boolean isSelectionEmpty()

    Returns true if the selection is empty, false otherwise.

    Returns:
      true if the selection is empty, false otherwise

  ### getUnselectableDates

      public java.util.SortedSet<java.util.Date> getUnselectableDates()

    Returns a `SortedSet` of `Dates that are unselectable.

    `
    Returns:
      sorted set of dates

  ### setUnselectableDates

      public void setUnselectableDates(java.util.SortedSet<java.util.Date> unselectables)

    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:
      `unselectables` - dates that are unselectable, must not be null and must not contain null dates.

  ### isUnselectableDate

      public boolean isUnselectableDate(java.util.Date date)

    Returns true is the specified date is unselectable.

    Parameters:
      `date` - the date to check for unselectability, must not be null.
    Returns:
      true is the date is unselectable, false otherwise

  Overview | Package | Class | Use | Tree | Deprecated | Index | Help
  PREV CLASS NEXT CLASS | FRAMES NO FRAMES
  SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

  Copyright © 2010. All Rights Reserved.