Package io.guise.framework.model
Class CalendarMonthTableModel
- java.lang.Object
-
- com.globalmentor.beans.BoundPropertyObject
-
- io.guise.framework.model.AbstractModel
-
- io.guise.framework.model.AbstractTableModel
-
- io.guise.framework.model.CalendarMonthTableModel
-
- All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable
,com.globalmentor.beans.PropertyConstrainable
,Model
,TableModel
public class CalendarMonthTableModel extends AbstractTableModel
A table model representing the days of a calendar month. Each cell contains aDate
value.- Author:
- Garret Wilson
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CalendarMonthTableModel.WeekDayTableColumnModel
A day-of-week column in a calendar month table.-
Nested classes/interfaces inherited from interface io.guise.framework.model.TableModel
TableModel.Cell<C>
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
COLUMN_LABEL_DATE_STYLE_PROPERTY
The column style bound property.static java.lang.String
DATE_PROPERTY
The date bound property.
-
Constructor Summary
Constructors Constructor Description CalendarMonthTableModel()
Default constructor for current month using the current date.CalendarMonthTableModel(java.util.Date date)
Date constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <C> C
getCellValue(int rowIndex, TableColumnModel<C> column)
Returns the cell value at the given row and column.protected java.text.DateFormat
getColumnLabelDateFormat()
DateStringLiteralStyle
getColumnLabelDateStyle()
java.util.Date
getDate()
protected int
getDayOffset()
protected java.util.Calendar
getMonthCalendar()
int
getRowCount()
GuiseSession
getSession()
<C> void
setCellValue(int rowIndex, TableColumnModel<C> column, C newCellValue)
Sets the cell value at the given row and column.void
setColumnLabelDateStyle(DateStringLiteralStyle newColumnLabelStyle)
Sets the style of the column label.void
setDate(java.util.Date newDate)
Sets the date this calendar represents.protected void
updateColumnLabelDateFormat()
Updates the column label date format based upon the column label date style and current locale.protected void
updateModel()
Updates the model based upon the current calendar.-
Methods inherited from class io.guise.framework.model.AbstractTableModel
addColumn, clearColumns, getCellValue, getColumnCount, getColumnIndex, getColumns, setCellValue
-
Methods inherited from class io.guise.framework.model.AbstractModel
getEventListenerManager, getPlainText
-
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Constructor Detail
-
CalendarMonthTableModel
public CalendarMonthTableModel()
Default constructor for current month using the current date.
-
CalendarMonthTableModel
public CalendarMonthTableModel(java.util.Date date)
Date constructor.- Parameters:
date
- The date this calendar is to represent.- Throws:
java.lang.NullPointerException
- if the given date isnull
.
-
-
Method Detail
-
getSession
public GuiseSession getSession()
- Returns:
- The Guise session that owns this object.
-
getDayOffset
protected int getDayOffset()
- Returns:
- The number of days this calendar should be offset left (negative) or right (positive) so that the days align with the correct day-of-the-week column.
-
getRowCount
public int getRowCount()
- Returns:
- The number of rows in this table.
-
getMonthCalendar
protected java.util.Calendar getMonthCalendar()
- Returns:
- A clone of the calendar representing the first day of the month.
-
getDate
public java.util.Date getDate()
- Returns:
- The date this calendar represents.
-
setDate
public void setDate(java.util.Date newDate)
Sets the date this calendar represents. A copy will be made of the date before it is stored. This is a bound property.- Parameters:
newDate
- The date this calendar is to represent.- Throws:
java.lang.NullPointerException
- if the given date isnull
.- See Also:
DATE_PROPERTY
-
getColumnLabelDateStyle
public DateStringLiteralStyle getColumnLabelDateStyle()
- Returns:
- The style of the column label.
-
setColumnLabelDateStyle
public void setColumnLabelDateStyle(DateStringLiteralStyle newColumnLabelStyle)
Sets the style of the column label. Note that this property is experimental, and may eventually be replaced with a style specification in the table component rather than the table model. This is a bound property.- Parameters:
newColumnLabelStyle
- The style of the column label.- Throws:
java.lang.NullPointerException
- if the given label style isnull
.- See Also:
COLUMN_LABEL_DATE_STYLE_PROPERTY
-
getColumnLabelDateFormat
protected java.text.DateFormat getColumnLabelDateFormat()
- Returns:
- The date format object for formatting the column labels.
-
updateModel
protected void updateModel()
Updates the model based upon the current calendar. The column label date format is also updated.- See Also:
updateColumnLabelDateFormat()
-
updateColumnLabelDateFormat
protected void updateColumnLabelDateFormat()
Updates the column label date format based upon the column label date style and current locale.- See Also:
getColumnLabelDateStyle()
-
getCellValue
public <C> C getCellValue(int rowIndex, TableColumnModel<C> column)
Description copied from interface:TableModel
Returns the cell value at the given row and column.- Type Parameters:
C
- The type of cell values in the given column.- Parameters:
rowIndex
- The zero-based row index.column
- The column for which a value should be returned.- Returns:
- The value in the cell at the given row and column, or
null
if there is no value in that cell.
-
setCellValue
public <C> void setCellValue(int rowIndex, TableColumnModel<C> column, C newCellValue)
Description copied from interface:TableModel
Sets the cell value at the given row and column.- Type Parameters:
C
- The type of cell values in the given column.- Parameters:
rowIndex
- The zero-based row index.column
- The column for which a value should be returned.newCellValue
- The value to place in the cell at the given row and column, ornull
if there should be no value in that cell.
-
-