com.pcauto.gui.table
Class RowHeaderModel

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended bycom.pcauto.gui.table.ProxyTableModel
          extended bycom.pcauto.gui.table.RowHeaderModel
All Implemented Interfaces:
EntityListListener, java.util.EventListener, java.io.Serializable, javax.swing.table.TableModel

public class RowHeaderModel
extends com.pcauto.gui.table.ProxyTableModel
implements javax.swing.table.TableModel, EntityListListener

This RowHeaderModel is used to manage and manipulate the row header of the EntityTable. For more information about the row header see the RowHeaderColumnModel. This RowHeaderModel provides methods to manage the virtual column and obtain information about table columns and cells. It can enable or disable the virtual column and set or query if row numbers or entity indices are displayed in the virtual column. It can also access information from the EntityList and EntityTableColumnModel, such as obtaining the value of a table cell, or obtaining more information about a column in the table.

The virtual column is an extra column that appears before any normal columns. It can be used to select rows, if row selection is enabled, and to display usefull information about the row, such as the row number or the row index.

See Also:
Serialized Form

Field Summary
protected  EntityTableColumnModel columnModel
          The EntityTableColumnModel which, stores the columns that are in the table and their properties.
protected  EntityList entityList
          The EntityList which, stores the entities of the table.
protected  boolean readOnly
          Stores if the table is editable or not editable (read-only).
protected  java.lang.Object virtualEntity
          The entity which, holds desirable column values which are displayed in the virtual row.
protected  boolean virtualRow
          Stores if the virtual row is enabled or disabled.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
RowHeaderModel()
          Constructs a new RowHeaderModel.
RowHeaderModel(EntityList e, EntityTableColumnModel c)
          Constructs a new RowHeaderModel using the given EntityList and EntityTableColumnModel.
RowHeaderModel(com.pcauto.gui.table.ProxyTableModel m)
          Constructs a new RowHeaderModel using the given ProxyTableModel, which holds the EntityList and EntityTableColumnModel, which define the rows and the columns of the table respectively.
 
Method Summary
 java.lang.Class getColumnClass(int p1)
          Returns the column class of the column at the given index.
 int getColumnCount()
          Returns the total number of columns in the table.
 EntityTableColumnModel getColumnModel()
          Returns the column model which, represents the columns in the table and their properties.
 java.lang.String getColumnName(int p1)
          Returns the name of the column at the specified index.
 EntityList getEntityList()
          Returns the EntityList representing the data in the table.
 com.pcauto.gui.table.ProxyTableModel getMainTableModel()
          Returns the ProxyTableModel, which is the the model used for accessing table data.
 int getRowCount()
          Returns the number of rows in the table.
 java.lang.Object getValueAt(int p1, int p2)
          Returns the value of the cell at the specified row and column.
 java.lang.Object getVirtualEntity()
          Returns the entity which, represents the virtual row.
 boolean isCellEditable(int p1, int p2)
          Returns true if the column at the given index is editable, false otherwise.
 boolean isCellEditingEnabled()
          Returns true if cell editing is enabled, false otherwise.
 boolean isEntityIndexDisplayed()
          Returns true if the entity index is displayed, false otherwise.
 boolean isReadOnly()
          Returns true if the table is read-only, false otherwise.
 boolean isRowNumberDisplayed()
          Returns true if the row numbers are displayed in the virtual column, false otherwise.
 boolean isVirtualColumnEnabled()
          Returns true if the virtual column is enabled, false otherwise.
 boolean isVirtualRowEnabled()
          Returns true if the virtual row is displayed in the table, false otherwise.
 void listChanged(EntityListEvent e)
          The list changed event handler.
 void refresh()
          Updates the view to reflect any changes to the table structure or data.
 void revalidate()
          Sets all the model properties and listeners again.
 void setCellEditingEnabled(boolean b)
          Enables or disables cell editing.
 void setColumnModel(EntityTableColumnModel c)
          Sets the column model which, represents the columns in the table and their properties.
 void setEntityIndexDisplayed(boolean d)
          Enables or disables entity index display in the virtual column.
 void setEntityList(EntityList e)
          Sets the EntityList which, represents the data in the table.
 void setMainTableModel(com.pcauto.gui.table.ProxyTableModel m)
          Sets the table model, which is the model used for accessing table data.
 void setReadOnly(boolean r)
          Enables or disables editing of the table.
 void setRowNumberDisplayed(boolean d)
          Enables or disables row number display in the virtual column.
 void setValueAt(java.lang.Object p1, int p2, int p3)
          Sets the value of the cell at the given row and column.
 void setVirtualColumnEnabled(boolean v)
          Enables or disables the virtual column.
 void setVirtualEntity(java.lang.Object v)
          Sets the virtual entity to display to the user.
 void setVirtualRowEnabled(boolean v)
          Enables or disables the virtual row.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getRowCount, removeTableModelListener
 
Methods inherited from interface com.pcauto.gui.table.EntityListListener
listChanged
 

Field Detail

entityList

protected EntityList entityList
The EntityList which, stores the entities of the table.


columnModel

protected EntityTableColumnModel columnModel
The EntityTableColumnModel which, stores the columns that are in the table and their properties. Some valid properties include the column being hidden or read-only. See EntityTableColumnModel for more information.


virtualEntity

protected java.lang.Object virtualEntity
The entity which, holds desirable column values which are displayed in the virtual row.


readOnly

protected boolean readOnly
Stores if the table is editable or not editable (read-only). The table is read-only if true, editable if false.


virtualRow

protected boolean virtualRow
Stores if the virtual row is enabled or disabled. It is enabled if true, disabled otherwise.

Constructor Detail

RowHeaderModel

public RowHeaderModel()
Constructs a new RowHeaderModel.


RowHeaderModel

public RowHeaderModel(EntityList e,
                      EntityTableColumnModel c)
Constructs a new RowHeaderModel using the given EntityList and EntityTableColumnModel. The EntityList holds entities, which in turn hold the table data. The EntityTableColumnModel holds the columns of the table and their associated properties. See EntityTableColumnModel for more information.

Parameters:
e - the EntityList
c - the EntityTableColumnModel

RowHeaderModel

public RowHeaderModel(com.pcauto.gui.table.ProxyTableModel m)
Constructs a new RowHeaderModel using the given ProxyTableModel, which holds the EntityList and EntityTableColumnModel, which define the rows and the columns of the table respectively. See ProxyTableModel for more information.

Parameters:
m - the ProxyTableModel
Method Detail

getMainTableModel

public com.pcauto.gui.table.ProxyTableModel getMainTableModel()
Returns the ProxyTableModel, which is the the model used for accessing table data. See ProxyTableModel for more information.

Returns:
the ProxyTableModel used for accessing table data

setMainTableModel

public void setMainTableModel(com.pcauto.gui.table.ProxyTableModel m)
Sets the table model, which is the model used for accessing table data. See ProxyTableModel for more information.

Parameters:
m - the new ProxyTableModel

isVirtualColumnEnabled

public boolean isVirtualColumnEnabled()
Returns true if the virtual column is enabled, false otherwise. See the documentation for this class for information about virtual columns.

Returns:
true if virtual columns are enabled, false otherwise

setVirtualColumnEnabled

public void setVirtualColumnEnabled(boolean v)
Enables or disables the virtual column. See the documentation for this class for information about virtual columns.

Parameters:
v - enabled if true, disabled otherwise

isRowNumberDisplayed

public boolean isRowNumberDisplayed()
Returns true if the row numbers are displayed in the virtual column, false otherwise.

Returns:
true if row numbers are displayed, false otherwise

setRowNumberDisplayed

public void setRowNumberDisplayed(boolean d)
Enables or disables row number display in the virtual column.

Parameters:
d - enabled if true, disabled otherwise

isEntityIndexDisplayed

public boolean isEntityIndexDisplayed()
Returns true if the entity index is displayed, false otherwise. If enabled, the virtual column displays numbers representing the order in which the entities were added to the table.

Returns:
true if entity index is displayed, false otherwise

setEntityIndexDisplayed

public void setEntityIndexDisplayed(boolean d)
Enables or disables entity index display in the virtual column. If enabled, the virtual column displays numbers representing the order in which the entities were added to the table.

Parameters:
d - enabled if true, disabled otherwise

isCellEditable

public boolean isCellEditable(int p1,
                              int p2)
Description copied from class: com.pcauto.gui.table.ProxyTableModel
Returns true if the column at the given index is editable, false otherwise. If enabled, then the column values can be modified.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Parameters:
p1 - not used
p2 - index of the column
Returns:
true if the column is editable, false otherwise

getValueAt

public java.lang.Object getValueAt(int p1,
                                   int p2)
Description copied from class: com.pcauto.gui.table.ProxyTableModel
Returns the value of the cell at the specified row and column. The indices start at 0.

Specified by:
getValueAt in interface javax.swing.table.TableModel
Parameters:
p1 - the row index
p2 - the column index
Returns:
the value of the cell

setValueAt

public void setValueAt(java.lang.Object p1,
                       int p2,
                       int p3)
Description copied from class: com.pcauto.gui.table.ProxyTableModel
Sets the value of the cell at the given row and column. All indices start at 0.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Parameters:
p1 - the Object representing the new value
p2 - the row entity index
p3 - the column index

getColumnCount

public int getColumnCount()
Description copied from class: com.pcauto.gui.table.ProxyTableModel
Returns the total number of columns in the table.

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Returns:
the column count

getColumnClass

public java.lang.Class getColumnClass(int p1)
Description copied from class: com.pcauto.gui.table.ProxyTableModel
Returns the column class of the column at the given index. This represents the data type of the cell values for the specified column. One possibility for the class is String.class. This is used to set up a default renderer and editor for the cells in this column. See EntityTableColumn for more information.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Parameters:
p1 - the column index
Returns:
the class of the column

getColumnName

public java.lang.String getColumnName(int p1)
Description copied from class: com.pcauto.gui.table.ProxyTableModel
Returns the name of the column at the specified index. This is what is displayed in the table column header for that column.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Parameters:
p1 - the column index
Returns:
the column name

getEntityList

public EntityList getEntityList()
Returns the EntityList representing the data in the table. See EntityList for more information.

Returns:
the EntityList which holds the entities of the table

setEntityList

public void setEntityList(EntityList e)
Sets the EntityList which, represents the data in the table. This is the same as replacing all the entities in the table. See EntityList for more information.

Parameters:
e - the new EntityList which holds the new entities

getColumnModel

public EntityTableColumnModel getColumnModel()
Returns the column model which, represents the columns in the table and their properties. See EntityTableColumnModel for more information.

Returns:
the EntityTableColumnModel holding the columns

setColumnModel

public void setColumnModel(EntityTableColumnModel c)
Sets the column model which, represents the columns in the table and their properties. See EntityTableColumnModel for more information.

Parameters:
c - the new EntityTableColumnModel which holds the new columns

isVirtualRowEnabled

public boolean isVirtualRowEnabled()
Returns true if the virtual row is displayed in the table, false otherwise. See class desctiption for more information about virtual rows.

Returns:
true if enabled, false otherwise

setVirtualRowEnabled

public void setVirtualRowEnabled(boolean v)
Enables or disables the virtual row. This determines if the virtual row is displayed in the table or not. See class desctiption for more information about virtual rows.

Parameters:
v - enabled if true, disabled otherwise

isCellEditingEnabled

public boolean isCellEditingEnabled()
Returns true if cell editing is enabled, false otherwise. Turing on cell editing permits the modification of the table cells.

Returns:
true if enabled, false otherwise

setCellEditingEnabled

public void setCellEditingEnabled(boolean b)
Enables or disables cell editing. Turning on cell editing permits the modification of the table cells.

Parameters:
b - enabled if true, disabled otherwise

getVirtualEntity

public java.lang.Object getVirtualEntity()
Returns the entity which, represents the virtual row. The values in the entity will be displayed as default values in the virtual row to the user. See the class description for further information about virtual rows.

Returns:
the entity representing the virtual row

setVirtualEntity

public void setVirtualEntity(java.lang.Object v)
Sets the virtual entity to display to the user. The values in the entity will be displayed as default values in the virtual row to the user. See the class description for further information about virtual rows.

Parameters:
v - the new virtual entity

getRowCount

public int getRowCount()
Returns the number of rows in the table.

Specified by:
getRowCount in interface javax.swing.table.TableModel
Returns:
the number of rows

refresh

public void refresh()
Updates the view to reflect any changes to the table structure or data.


isReadOnly

public boolean isReadOnly()
Returns true if the table is read-only, false otherwise. If the table is read-only then it can't be edited by the user, otherwise it can be.

Returns:
true if read-only, false otherwise

setReadOnly

public void setReadOnly(boolean r)
Enables or disables editing of the table. To enable editing set the parameter to false, to disable set it to true.

Parameters:
r - read-only if true, editable otherwise

listChanged

public void listChanged(EntityListEvent e)
The list changed event handler. It is called whenever the EntityList representing entities in the table changes. This method is responsible for performing appropriate actions to reflect the changes in the table. It is responsible for generating the events that will inform the listeners of the changes.

Specified by:
listChanged in interface EntityListListener
Parameters:
e - the generated EntityListEvent

revalidate

public void revalidate()
Sets all the model properties and listeners again. This method could be called if the EntityList or the EntityTableColumnModel have been changed externally.