Class CalendarMonthTableModel

java.lang.Object
com.globalmentor.beans.BoundPropertyObject
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 a Date value.
Author:
Garret Wilson
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    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 final String
    The column style bound property.
    static final String
    The date bound property.

    Fields inherited from class com.globalmentor.beans.BoundPropertyObject

    NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for current month using the current date.
    Date constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    <C> C
    getCellValue(int rowIndex, TableColumnModel<C> column)
    Returns the cell value at the given row and column.
    protected DateFormat
     
     
     
    protected int
     
    protected Calendar
     
    int
     
     
    <C> void
    setCellValue(int rowIndex, TableColumnModel<C> column, C newCellValue)
    Sets the cell value at the given row and column.
    void
    Sets the style of the column label.
    void
    setDate(Date newDate)
    Sets the date this calendar represents.
    protected void
    Updates the column label date format based upon the column label date style and current locale.
    protected void
    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

    Methods inherited from interface com.globalmentor.beans.PropertyBindable

    addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener

    Methods inherited from interface com.globalmentor.beans.PropertyConstrainable

    addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, hasVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
  • Field Details

    • COLUMN_LABEL_DATE_STYLE_PROPERTY

      public static final String COLUMN_LABEL_DATE_STYLE_PROPERTY
      The column style bound property.
    • DATE_PROPERTY

      public static final String DATE_PROPERTY
      The date bound property.
  • Constructor Details

    • CalendarMonthTableModel

      public CalendarMonthTableModel()
      Default constructor for current month using the current date.
    • CalendarMonthTableModel

      public CalendarMonthTableModel(Date date)
      Date constructor.
      Parameters:
      date - The date this calendar is to represent.
      Throws:
      NullPointerException - if the given date is null.
  • Method Details

    • 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 Calendar getMonthCalendar()
      Returns:
      A clone of the calendar representing the first day of the month.
    • getDate

      public Date getDate()
      Returns:
      The date this calendar represents.
    • setDate

      public void setDate(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:
      NullPointerException - if the given date is null.
      See Also:
    • 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:
      NullPointerException - if the given label style is null.
      See Also:
    • getColumnLabelDateFormat

      protected 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

      protected void updateColumnLabelDateFormat()
      Updates the column label date format based upon the column label date style and current locale.
      See Also:
    • 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, or null if there should be no value in that cell.