Class 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 a Date value.
    Author:
    Garret Wilson
    • 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.
      • Fields inherited from class com.globalmentor.beans.BoundPropertyObject

        NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
    • 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 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 Detail

      • COLUMN_LABEL_DATE_STYLE_PROPERTY

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

        public static final java.lang.String DATE_PROPERTY
        The date bound property.
    • 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 is null.
    • 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 is null.
        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 is null.
        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, or null if there should be no value in that cell.