Holger's
Java API

com.antelmann.calendar
Class CalendarTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.antelmann.calendar.CalendarTableModel
All Implemented Interfaces:
CalendarModelListener, Localizable, Serializable, TableModel

public class CalendarTableModel
extends AbstractTableModel
implements CalendarModelListener, Localizable

a special table model that can place values for specific dates into a table model; each model represents one month.

Author:
Holger Antelmann
See Also:
CalendarCell, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.antelmann.util.Localizable
Localizable.Adapter
 
Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
CalendarTableModel(CalendarModel cmodel)
          calls this(cmodel, Calendar.getInstance())
CalendarTableModel(CalendarModel cmodel, Calendar calendar)
          calls this(cmodel, month, true, false)
CalendarTableModel(CalendarModel cmodel, Calendar calendar, boolean withWeekNumber)
          uses the default Locale
CalendarTableModel(CalendarModel cmodel, Calendar calendar, Locale locale)
          doesn't use week numbers
CalendarTableModel(CalendarModel cmodel, Calendar calendar, Locale locale, boolean withWeekNumber)
          adds itself as a CalendarModelListener to the given CalendarModel
CalendarTableModel(CalendarModel cmodel, Date month)
           
 
Method Summary
 void calendarChanged(CalendarChangeEvent event)
           
protected  void finalize()
           
 Calendar getCalendar()
          changing the calendar (for instance its date or the first day of the week) will change the contents of this model from behind, so instead of doing that, call setCalendar(Calendar).
 CalendarModel getCalendarModel()
           
 Class<?> getColumnClass(int column)
          returns CalendarCell for all columns
 int getColumnCount()
           
 String getColumnName(int column)
           
 Date getDateFor(int row, int column)
           
 Date getFirstVisibleDate()
           
 Date getLastVisibleDate()
           
 Locale getLocale()
          allows access to the Locale that this instance currently uses to localize its messages,
 int getRowCount()
           
 Object getValueAt(int row, int column)
          this implementation always returns a CalendarCell instance.
 boolean isWithWeekNumber()
           
 void setCalendar(Calendar calendar)
          also calls fireTableDataChanged()
 void setCalendarModel(CalendarModel cmodel)
           
 void setLocale(Locale locale, Object context)
          sets the Locale for this object so that all subsequent return values of method calls to this instance can be localized accordingly until a different Locale is set.
 void setWithWeekNumber(boolean flag)
           
 
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, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CalendarTableModel

public CalendarTableModel(CalendarModel cmodel)
calls this(cmodel, Calendar.getInstance())


CalendarTableModel

public CalendarTableModel(CalendarModel cmodel,
                          Date month)

CalendarTableModel

public CalendarTableModel(CalendarModel cmodel,
                          Calendar calendar)
calls this(cmodel, month, true, false)


CalendarTableModel

public CalendarTableModel(CalendarModel cmodel,
                          Calendar calendar,
                          Locale locale)
doesn't use week numbers


CalendarTableModel

public CalendarTableModel(CalendarModel cmodel,
                          Calendar calendar,
                          boolean withWeekNumber)
uses the default Locale


CalendarTableModel

public CalendarTableModel(CalendarModel cmodel,
                          Calendar calendar,
                          Locale locale,
                          boolean withWeekNumber)
adds itself as a CalendarModelListener to the given CalendarModel

Method Detail

isWithWeekNumber

public boolean isWithWeekNumber()

setWithWeekNumber

public void setWithWeekNumber(boolean flag)

getCalendarModel

public CalendarModel getCalendarModel()

setCalendarModel

public void setCalendarModel(CalendarModel cmodel)

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

getLocale

public Locale getLocale()
Description copied from interface: Localizable
allows access to the Locale that this instance currently uses to localize its messages,

Specified by:
getLocale in interface Localizable
Returns:
the current Locale that this instance uses to determine return values for its methods; if null is returned, this instance is expected to use the default Locale of the system.
See Also:
Localizable.setLocale(Locale, Object)

setLocale

public void setLocale(Locale locale,
                      Object context)
Description copied from interface: Localizable
sets the Locale for this object so that all subsequent return values of method calls to this instance can be localized accordingly until a different Locale is set.

Specified by:
setLocale in interface Localizable
Parameters:
locale - the Locale that is to be used to determine return values for all methods of this instance; if set to null, the default locale is to be used.
context - a context that may be required for this instance to load the resources for the given locale; this context may be null for objects that do not require an external context. Examples of a context may be a database, a resource file, some map or no context at all.
See Also:
Localizable.getLocale()

getCalendar

public Calendar getCalendar()
changing the calendar (for instance its date or the first day of the week) will change the contents of this model from behind, so instead of doing that, call setCalendar(Calendar).


setCalendar

public void setCalendar(Calendar calendar)
also calls fireTableDataChanged()


getColumnClass

public Class<?> getColumnClass(int column)
returns CalendarCell for all columns

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

getColumnName

@Localized
public String getColumnName(int column)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel

getValueAt

public Object getValueAt(int row,
                         int column)
this implementation always returns a CalendarCell instance. If you seek to just return the value of a CalendarCell, you may want to consider using a ConvertedTableModel

Specified by:
getValueAt in interface TableModel
See Also:
CalendarCell

getDateFor

public Date getDateFor(int row,
                       int column)

getFirstVisibleDate

public Date getFirstVisibleDate()

getLastVisibleDate

public Date getLastVisibleDate()

calendarChanged

public void calendarChanged(CalendarChangeEvent event)
Specified by:
calendarChanged in interface CalendarModelListener


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads