com.jp.comp.calendar
Class CalendarTableModel

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended bycom.jp.comp.calendar.CalendarTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class CalendarTableModel
extends javax.swing.table.AbstractTableModel

CalendarTableModel builds the Calendar's data and columns depending on the Locale to show it in the CalendarPanel

See Also:
CalendarPanel, Serialized Form

Field Summary
protected static int COLUMN_COUNT
          Maximum Calendar's columns
protected  java.util.Calendar fCalendar
           
protected  CalendarInterface fCalendarPanel
           
protected  java.lang.String[] fColumnNames
           
protected  CalendarItem[][] fData
           
protected  java.text.SimpleDateFormat fDayOfWeekFormat
           
protected  java.util.Vector fListeners
           
protected  java.util.Locale fLocale
           
protected  java.text.NumberFormat fNumberFormat
           
protected  int fSelectedColumn
           
protected  int fSelectedRow
           
protected  boolean fShortDayCaption
           
protected  java.util.Calendar fTempCalendar
           
protected static int ROW_COUNT
          Maximum Calendar's rows
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
CalendarTableModel(java.util.Locale aLocale, CalendarInterface aCalendarPanel)
          Builds the Calendar's data and columns depending on specified Locale
 
Method Summary
 void addCalendarListener(CalendarListener aListener)
          Adds Calendar's listener
protected  void buildColumns()
          Builds the Calendar's columns depending on the Locale
protected  void fireDateChanged(java.util.Date aOldDate, java.util.Date aNewDate)
          Fires date is changed event
protected  void fireLocaleChanged(java.util.Locale aLocale, java.util.Date aDate)
          Fires locale is changed event
protected  java.lang.String formatDay(int aNumber)
          Formats specified number with the Location
 java.lang.Class getColumnClass(int aColumnIndex)
           
 int getColumnCount()
           
 java.lang.String getColumnName(int aColumn)
           
 java.util.Date getDate()
          Returns selected Date
 int getDayOfMonth()
          Returns selected day of month
protected  int getFirstDayOfWeekInMonth(java.util.Date aDate)
          Returns first day of the week in the month
 CalendarItem getItem(int aRow, int aColumn)
          Gets the CalendarItem from specified row and column
 int getMonth()
          Returns selected month number (0 - 11)
 int getRowCount()
           
 int getSelectedColumn()
          Gets selected column
 CalendarItem getSelectedItem()
          Gets selected CalendarItem
 int getSelectedRow()
          Gets selected row
 java.lang.Object getValueAt(int aRow, int aColumn)
           
 int getYear()
          Returns selected year
 boolean isShortDayCaption()
          Returns true if short day caption is shown
 void removeCalendarListener(CalendarListener aListener)
          Removes Calendar's listener
 void setDate(java.util.Date aDate)
          Sets a new Date
protected  void setDate(java.util.Date aDate, boolean aForceDataRebuilding, boolean aFireDateChanged)
          Sets a new Date
protected  void setDayOfMonth(int aDay)
          Sets a new day of current month
 void setLocale(java.util.Locale aLocale)
          Sets a new Locale
 void setSelectedColumn(int aColumn)
          Sets the column
 void setSelectedRow(int aRow)
          Sets the row
 void setShortDayCaption(boolean aShortDayCaption)
          Sets whether short day caption should be shown
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROW_COUNT

protected static final int ROW_COUNT
Maximum Calendar's rows

See Also:
Constant Field Values

COLUMN_COUNT

protected static final int COLUMN_COUNT
Maximum Calendar's columns

See Also:
Constant Field Values

fDayOfWeekFormat

protected java.text.SimpleDateFormat fDayOfWeekFormat

fColumnNames

protected java.lang.String[] fColumnNames

fData

protected CalendarItem[][] fData

fListeners

protected java.util.Vector fListeners

fLocale

protected java.util.Locale fLocale

fCalendarPanel

protected CalendarInterface fCalendarPanel

fCalendar

protected java.util.Calendar fCalendar

fTempCalendar

protected java.util.Calendar fTempCalendar

fNumberFormat

protected java.text.NumberFormat fNumberFormat

fSelectedRow

protected int fSelectedRow

fSelectedColumn

protected int fSelectedColumn

fShortDayCaption

protected boolean fShortDayCaption
Constructor Detail

CalendarTableModel

public CalendarTableModel(java.util.Locale aLocale,
                          CalendarInterface aCalendarPanel)
Builds the Calendar's data and columns depending on specified Locale

Parameters:
aLocale - the Locale
aCalendarPanel - the CalendarInterface instance
Method Detail

buildColumns

protected void buildColumns()
Builds the Calendar's columns depending on the Locale


getValueAt

public java.lang.Object getValueAt(int aRow,
                                   int aColumn)

getRowCount

public int getRowCount()

getColumnCount

public int getColumnCount()

getColumnClass

public java.lang.Class getColumnClass(int aColumnIndex)

getColumnName

public java.lang.String getColumnName(int aColumn)

getSelectedRow

public int getSelectedRow()
Gets selected row

Returns:
selected row

setSelectedRow

public void setSelectedRow(int aRow)
Sets the row

Parameters:
aRow - the row

getSelectedColumn

public int getSelectedColumn()
Gets selected column

Returns:
selected column

setSelectedColumn

public void setSelectedColumn(int aColumn)
Sets the column

Parameters:
aColumn - the column

setLocale

public void setLocale(java.util.Locale aLocale)
Sets a new Locale

Parameters:
aLocale - a new Locale

isShortDayCaption

public boolean isShortDayCaption()
Returns true if short day caption is shown

Returns:
true if short day caption is shown

setShortDayCaption

public void setShortDayCaption(boolean aShortDayCaption)
Sets whether short day caption should be shown

Parameters:
aShortDayCaption - true if short day caption should be shown

getItem

public CalendarItem getItem(int aRow,
                            int aColumn)
Gets the CalendarItem from specified row and column

Parameters:
aRow - the row
aColumn - the column
Returns:
the CalendarItem

getSelectedItem

public CalendarItem getSelectedItem()
Gets selected CalendarItem

Returns:
selected CalendarItem

getDate

public java.util.Date getDate()
Returns selected Date

Returns:
selected Date

setDate

public final void setDate(java.util.Date aDate)
Sets a new Date

Parameters:
aDate - a new Date

setDate

protected void setDate(java.util.Date aDate,
                       boolean aForceDataRebuilding,
                       boolean aFireDateChanged)
Sets a new Date

Parameters:
aDate - a new Date
aForceDataRebuilding - whether to force data rebuilding
aFireDateChanged - whether to fire date is changed event

getDayOfMonth

public int getDayOfMonth()
Returns selected day of month

Returns:
selected day of month

setDayOfMonth

protected void setDayOfMonth(int aDay)
Sets a new day of current month

Parameters:
aDay - a new day of month

getMonth

public int getMonth()
Returns selected month number (0 - 11)

Returns:
selected month number

getYear

public int getYear()
Returns selected year

Returns:
selected year

formatDay

protected java.lang.String formatDay(int aNumber)
Formats specified number with the Location

Parameters:
aNumber - the number to formatt
Returns:
formatted number

getFirstDayOfWeekInMonth

protected int getFirstDayOfWeekInMonth(java.util.Date aDate)
Returns first day of the week in the month

Parameters:
aDate - the Date
Returns:
first day of the week in the month

addCalendarListener

public void addCalendarListener(CalendarListener aListener)
Adds Calendar's listener

Parameters:
aListener - Calendar's listener

removeCalendarListener

public void removeCalendarListener(CalendarListener aListener)
Removes Calendar's listener

Parameters:
aListener - Calendar's listener

fireDateChanged

protected void fireDateChanged(java.util.Date aOldDate,
                               java.util.Date aNewDate)
Fires date is changed event

Parameters:
aOldDate - old Date
aNewDate - new Date

fireLocaleChanged

protected void fireLocaleChanged(java.util.Locale aLocale,
                                 java.util.Date aDate)
Fires locale is changed event

Parameters:
aLocale - new Locale
aDate - current Date