datechooser.model
Class AbstractDateChooseModel

java.lang.Object
  extended by datechooser.model.AbstractDateChooseModel
All Implemented Interfaces:
DateChoose, java.io.Serializable
Direct Known Subclasses:
FooModel, MultyDateChooseModel, SingleDateChooseModel

public abstract class AbstractDateChooseModel
extends java.lang.Object
implements DateChoose

Dafault date selection model. Uses one fully visible month and partially two neighbour months. Provides basic functionality for month scrolling. Only selection functions are abstract.
Модель выбора даты по умолчанию. Отображается только месяц и частично предыдущий и следующий. Обеспечивает всю базовую функциональность по прокрутке месяцев. Делегирует только функции непосредственного выбора.

Since:
1.0
Author:
Androsov Vadim
See Also:
DateChoose, Serialized Form

Field Summary
protected  boolean changeEventsOn
           
 
Constructor Summary
AbstractDateChooseModel(java.util.Calendar current, int rowsCount, int colsCount)
          Constructor for abstract model.
 
Method Summary
 void addCommitListener(CommitListener listener)
          Adds commit selection event listener.
 void addCursorMoveListener(CursorMoveListener listener)
          Adds cursor move listener.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds property change listener.
 void addSelectionChangedListener(SelectionChangedListener listener)
          Adds selection change listener.
protected abstract  void applySelection()
          Делает попытка выбрать ячейку под курсором.
protected abstract  void applySelectNothing()
          Попытка не выбрать ни одной даты.
 void commit()
          Commits selection.
protected  void fireCursorMove()
           
 void firePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
           
 void fireSelectionChange()
          Fires "Selection changed" event.
 java.lang.String getCellCaption(int row, int column)
          Caption of the specified cell.
 java.util.Calendar getCellDate(int row, int column)
          Date corresponding to the specified cell.
 CellState getCellState(int row, int column)
          State of the specified cell.
 int getColsCount()
          Columns count in day selection grid.
 java.util.Calendar getCurrent()
          Get date under cursor.
 java.util.Calendar getDefaultDate()
          Default date.
 java.lang.Iterable<Period> getForbidden()
          Forbidden date for selection.
 PeriodSet getForbiddenSet()
           
 java.util.Locale getLocale()
          Locale.
 java.util.Calendar getMaxConstraint()
          Get maximal enabled date.
 java.util.Calendar getMinConstraint()
          Get minimal enabled date.
 int getRowsCount()
          Rows count in day selection grid.
 java.util.Calendar getVisibleDate()
          Visible date.
protected  void invalidate()
           
 boolean isAutoScroll()
          Is auto month scroll enabled.
 boolean isChangeEventsOn()
           
 boolean isCursor(int row, int column)
          Is cursor in specified position.
protected  boolean isDateForbidden(java.util.Calendar date)
           
 boolean isEnabled()
          Is model enabled.
protected  boolean isForbiddenDefault(PeriodSet forbiddenPeriods)
           
 boolean isLocked()
          Is model locked (cursor is moving but no selection available).
 boolean isNothingAllowed()
          Is null selection allowed.
protected  boolean isPeriodForbidden(Period period)
           
 boolean isShowNeighbourMonth()
          Are neighbour months visible.
 void monthShift(int shift)
          Jumps on specified months count.
 boolean needsFullValidation()
          Note: returns validation flag and resets it.
 void removeCommitListener(CommitListener listener)
          Removes commit selection event listener.
 void removeCursorMoveListener(CursorMoveListener listener)
          Removes cursor move listener.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes property change listener.
 void removeSelectionChangedListener(SelectionChangedListener listener)
          Removes selection change listener.
 boolean select(java.util.Calendar aDate)
          Selects specified date.
 boolean select(int row, int column)
          Selects specified cell.
protected abstract  void selectColumn(int column)
           
 void selectNothing()
          Selects null.
 void setAutoScroll(boolean autoScroll)
          Sets auto month scroll enabled.
 void setChangeEventsOn(boolean changeEventsOn)
           
 void setConstraints(java.util.Calendar min, java.util.Calendar max)
          Date selection constraints.
 void setDefaultDate(java.util.Calendar aDate)
          Sets default date.
 void setEnabled(boolean enabled)
          Sets model enabled.
 void setForbidden(java.lang.Iterable<Period> forbiddenPeriods)
          Sets forbiddend for selection dates.
 void setForbiddenSet(PeriodSet forbiddenPeriods)
           
 void setLocale(java.util.Locale locale)
          Sets locale.
 void setLocked(boolean locked)
          Sets lock.
 void setMaxConstraint(java.util.Calendar maxConstraint)
          Sets maximal date.
 void setMinConstraint(java.util.Calendar minConstraint)
          Sets minimal date.
 void setNothingAllowed(boolean allow)
          Allows null selection.
 void setSelectedDate(java.util.Calendar aDate)
          Sets cursor on specified date.
 void setShowNeighbourMonth(boolean showNeighbourMonth)
          Sets neighbour months visibility.
 void shift(int rowShift, int columnShift)
          Shifts cursor on specified steps count vertically and hirizontally.
 void showMonthYear(int month, int year)
          Shows specified month and year.
 void tryApplySelection()
          Trying select date under cursor, must be defined in child classes.
 void yearShift(int shift)
          Jumps on specified years count.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface datechooser.model.DateChoose
getSelectedDate, isNothingSelected, isSelected, setNothingSelected
 

Field Detail

changeEventsOn

protected boolean changeEventsOn
Constructor Detail

AbstractDateChooseModel

public AbstractDateChooseModel(java.util.Calendar current,
                               int rowsCount,
                               int colsCount)
Constructor for abstract model.
Конструктор абстрактной модели выбора.

Parameters:
current - Current date.
Текущая дата.
rowsCount - Rows count in day selection grid.
Количество строк в сетке выбора дней.
colsCount - Columns count in day selection grid.
Количество колонок в сетке выбора дней.
Method Detail

selectColumn

protected abstract void selectColumn(int column)

getRowsCount

public int getRowsCount()
Description copied from interface: DateChoose
Rows count in day selection grid.
Количество строк в сетке выбора даты.

Specified by:
getRowsCount in interface DateChoose

getColsCount

public int getColsCount()
Description copied from interface: DateChoose
Columns count in day selection grid.
Количество столбцов в сетке выбора даты.

Specified by:
getColsCount in interface DateChoose

isCursor

public boolean isCursor(int row,
                        int column)
Description copied from interface: DateChoose
Is cursor in specified position.
Проверяет, находится ли курсор в заданной позиции.

Specified by:
isCursor in interface DateChoose

getCellState

public CellState getCellState(int row,
                              int column)
Description copied from interface: DateChoose
State of the specified cell.
Состояние указанной ячейки.

Specified by:
getCellState in interface DateChoose

getCellCaption

public java.lang.String getCellCaption(int row,
                                       int column)
Description copied from interface: DateChoose
Caption of the specified cell.
Заголовок указанной ячейки

Specified by:
getCellCaption in interface DateChoose

getCellDate

public java.util.Calendar getCellDate(int row,
                                      int column)
Description copied from interface: DateChoose
Date corresponding to the specified cell.
Дата, соответствующая указанной ячейки.

Specified by:
getCellDate in interface DateChoose

setConstraints

public void setConstraints(java.util.Calendar min,
                           java.util.Calendar max)
Description copied from interface: DateChoose
Date selection constraints.
Ограничения на выбор даты.

Specified by:
setConstraints in interface DateChoose

needsFullValidation

public boolean needsFullValidation()
Note: returns validation flag and resets it.
Внимание! Возвратив статус необходимости обновления, сбрасывает его - если необходимости не было, то ничего не меняется.

Specified by:
needsFullValidation in interface DateChoose

select

public boolean select(int row,
                      int column)
Description copied from interface: DateChoose
Selects specified cell.
Выбор ячейки.

Specified by:
select in interface DateChoose
Returns:
Произошел ли выбор.

select

public boolean select(java.util.Calendar aDate)
Description copied from interface: DateChoose
Selects specified date.
Выбирает заданную дату.

Specified by:
select in interface DateChoose

invalidate

protected void invalidate()

getCurrent

public java.util.Calendar getCurrent()
Description copied from interface: DateChoose
Get date under cursor.
Возвращает дату, на которой находится курсор.

Specified by:
getCurrent in interface DateChoose

showMonthYear

public void showMonthYear(int month,
                          int year)
Description copied from interface: DateChoose
Shows specified month and year.
Показать отрезок за заданный месяц и год.

Specified by:
showMonthYear in interface DateChoose

getVisibleDate

public java.util.Calendar getVisibleDate()
Description copied from interface: DateChoose
Visible date.
Видимая дата.

Specified by:
getVisibleDate in interface DateChoose

getDefaultDate

public java.util.Calendar getDefaultDate()
Description copied from interface: DateChoose
Default date.
Дата по умолчанию.

Specified by:
getDefaultDate in interface DateChoose

setDefaultDate

public void setDefaultDate(java.util.Calendar aDate)
                    throws IncompatibleDataExeption
Description copied from interface: DateChoose
Sets default date.
Устанавливает дату по умолчанию.

Specified by:
setDefaultDate in interface DateChoose
Throws:
IncompatibleDataExeption

shift

public void shift(int rowShift,
                  int columnShift)
Description copied from interface: DateChoose
Shifts cursor on specified steps count vertically and hirizontally.
Сдвиг выбранной ячейки.

Specified by:
shift in interface DateChoose

monthShift

public void monthShift(int shift)
Description copied from interface: DateChoose
Jumps on specified months count.
Осуществляет прыжок на заданной количество месяцев.

Specified by:
monthShift in interface DateChoose
Parameters:
shift - На скоько месяцев переместиться. Отрицательные значения обозначают прыжок назад.

yearShift

public void yearShift(int shift)
Description copied from interface: DateChoose
Jumps on specified years count.
Осуществляет прыжок на заданной количество лет.

Specified by:
yearShift in interface DateChoose
Parameters:
shift - На скоько лет переместиться. Отрицательные значения обозначают прыжок назад.

isAutoScroll

public boolean isAutoScroll()
Description copied from interface: DateChoose
Is auto month scroll enabled.
Проверяет, включена ли автоматическая прокрутка.

Specified by:
isAutoScroll in interface DateChoose

setAutoScroll

public void setAutoScroll(boolean autoScroll)
Description copied from interface: DateChoose
Sets auto month scroll enabled.
Устанавливает режим автоматической прокрутки.

Specified by:
setAutoScroll in interface DateChoose

isShowNeighbourMonth

public boolean isShowNeighbourMonth()
Description copied from interface: DateChoose
Are neighbour months visible.
Выводить ли соседний месяц.

Specified by:
isShowNeighbourMonth in interface DateChoose

setShowNeighbourMonth

public void setShowNeighbourMonth(boolean showNeighbourMonth)
Description copied from interface: DateChoose
Sets neighbour months visibility.
Настраивает вывод дней из соседнего месяца.

Specified by:
setShowNeighbourMonth in interface DateChoose

isEnabled

public boolean isEnabled()
Description copied from interface: DateChoose
Is model enabled.
Доступна для изменений.

Specified by:
isEnabled in interface DateChoose

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: DateChoose
Sets model enabled.
Доступна для изменений.

Specified by:
setEnabled in interface DateChoose

getForbiddenSet

public PeriodSet getForbiddenSet()

isForbiddenDefault

protected boolean isForbiddenDefault(PeriodSet forbiddenPeriods)

setForbiddenSet

public void setForbiddenSet(PeriodSet forbiddenPeriods)
                     throws IncompatibleDataExeption
Throws:
IncompatibleDataExeption

getForbidden

public java.lang.Iterable<Period> getForbidden()
Description copied from interface: DateChoose
Forbidden date for selection.
Возвращает запрещенные для выбора даты.

Specified by:
getForbidden in interface DateChoose

setForbidden

public void setForbidden(java.lang.Iterable<Period> forbiddenPeriods)
Description copied from interface: DateChoose
Sets forbiddend for selection dates.
Устанавливает запрещенные для выбора даты.

Specified by:
setForbidden in interface DateChoose

isPeriodForbidden

protected boolean isPeriodForbidden(Period period)

isDateForbidden

protected boolean isDateForbidden(java.util.Calendar date)

getMinConstraint

public java.util.Calendar getMinConstraint()
Description copied from interface: DateChoose
Get minimal enabled date.
Возвращает минимальную дату.

Specified by:
getMinConstraint in interface DateChoose

setMinConstraint

public void setMinConstraint(java.util.Calendar minConstraint)
Description copied from interface: DateChoose
Sets minimal date.
Устанавливает минимальную дату.

Specified by:
setMinConstraint in interface DateChoose

getMaxConstraint

public java.util.Calendar getMaxConstraint()
Description copied from interface: DateChoose
Get maximal enabled date.
Возвращает максимальную дату.

Specified by:
getMaxConstraint in interface DateChoose

setMaxConstraint

public void setMaxConstraint(java.util.Calendar maxConstraint)
Description copied from interface: DateChoose
Sets maximal date.
Устанавливает максимальную дату.

Specified by:
setMaxConstraint in interface DateChoose

setSelectedDate

public void setSelectedDate(java.util.Calendar aDate)
Description copied from interface: DateChoose
Sets cursor on specified date.
Устанавливает курсор на заданную дату.

Specified by:
setSelectedDate in interface DateChoose

getLocale

public java.util.Locale getLocale()
Description copied from interface: DateChoose
Locale.
Возвращает локализацию.

Specified by:
getLocale in interface DateChoose

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: DateChoose
Sets locale.
Устанавливает локализацию.

Specified by:
setLocale in interface DateChoose

commit

public void commit()
Description copied from interface: DateChoose
Commits selection.
Закрепляет выбор

Specified by:
commit in interface DateChoose

tryApplySelection

public final void tryApplySelection()
Description copied from interface: DateChoose
Trying select date under cursor, must be defined in child classes.
Выбирает дату под курсором с учетом возможной блокировки. Должен быть переопределен в потомках.

Specified by:
tryApplySelection in interface DateChoose

isLocked

public boolean isLocked()
Description copied from interface: DateChoose
Is model locked (cursor is moving but no selection available).
Проверяет не заблокирован ли компонент.

Specified by:
isLocked in interface DateChoose

setLocked

public void setLocked(boolean locked)
Description copied from interface: DateChoose
Sets lock.
Изменяет состояние блокировки компонента.

Specified by:
setLocked in interface DateChoose

setNothingAllowed

public void setNothingAllowed(boolean allow)
Description copied from interface: DateChoose
Allows null selection.
Позволяет разрешить или запретить не выбирать ни одной даты.

Specified by:
setNothingAllowed in interface DateChoose

isNothingAllowed

public boolean isNothingAllowed()
Description copied from interface: DateChoose
Is null selection allowed.
Разрешен ли пустой выбор.

Specified by:
isNothingAllowed in interface DateChoose

isChangeEventsOn

public boolean isChangeEventsOn()

setChangeEventsOn

public void setChangeEventsOn(boolean changeEventsOn)

selectNothing

public void selectNothing()
Description copied from interface: DateChoose
Selects null.
Выбор null

Specified by:
selectNothing in interface DateChoose

addSelectionChangedListener

public void addSelectionChangedListener(SelectionChangedListener listener)
Description copied from interface: DateChoose
Adds selection change listener.
Добавляет слушателя события "Изменение выбора".

Specified by:
addSelectionChangedListener in interface DateChoose

removeSelectionChangedListener

public void removeSelectionChangedListener(SelectionChangedListener listener)
Description copied from interface: DateChoose
Removes selection change listener.
Удаляет слушателя события "Изменение выбора".

Specified by:
removeSelectionChangedListener in interface DateChoose

fireSelectionChange

public void fireSelectionChange()
Description copied from interface: DateChoose
Fires "Selection changed" event.
Рассылает событие "Изменение выбора".

Specified by:
fireSelectionChange in interface DateChoose

addCommitListener

public void addCommitListener(CommitListener listener)
Description copied from interface: DateChoose
Adds commit selection event listener.
Добавляет слушателя события "Подтверждение выбора".

Specified by:
addCommitListener in interface DateChoose

removeCommitListener

public void removeCommitListener(CommitListener listener)
Description copied from interface: DateChoose
Removes commit selection event listener.
Удаляет слушателя события "Подтверждение выбора".

Specified by:
removeCommitListener in interface DateChoose

addCursorMoveListener

public void addCursorMoveListener(CursorMoveListener listener)
Description copied from interface: DateChoose
Adds cursor move listener.
Добавляет слушателя события "Перемещение курсора".

Specified by:
addCursorMoveListener in interface DateChoose

removeCursorMoveListener

public void removeCursorMoveListener(CursorMoveListener listener)
Description copied from interface: DateChoose
Removes cursor move listener.
Удаляет слушателя события "Перемещение курсора".

Specified by:
removeCursorMoveListener in interface DateChoose

fireCursorMove

protected void fireCursorMove()

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: DateChoose
Adds property change listener.
Добавляет слушателя события "Изменение свойства".

Specified by:
addPropertyChangeListener in interface DateChoose

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: DateChoose
Removes property change listener.
Удаляет слушателя события "Изменение свойства".

Specified by:
removePropertyChangeListener in interface DateChoose

firePropertyChange

public void firePropertyChange(java.lang.String name,
                               java.lang.Object oldValue,
                               java.lang.Object newValue)

applySelection

protected abstract void applySelection()
Делает попытка выбрать ячейку под курсором. Что делать дальше зависит от допустимых вариантов выбора.


applySelectNothing

protected abstract void applySelectNothing()
Попытка не выбрать ни одной даты.