org.rimudb.editor
Class PropertyTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.rimudb.editor.swing.ATableModel
          extended by org.rimudb.editor.PropertyTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class PropertyTableModel
extends ATableModel

This TableModel class is used to display the table descriptor columns.

Author:
Simon Ritchie
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
PropertyTableModel()
          Construct a PropertyTableModel
 
Method Summary
 void addEntry(FieldEntry entry)
          Add an entry to the TableModel
 void clear()
          Clear the data in the model
 java.lang.String[] getAllColumnNames()
          Return an array of all the column names
 FieldEntry[] getAllRows()
          Return all the entries
 java.lang.Class getColumnClass(int columnIndex)
          Returns the lowest common denominator Class in the column.
 int getColumnCount()
          Returns the number of columns managed by the data source object.
 java.lang.String getColumnName(int columnIndex)
          Returns the name of the column at columnIndex.
 int getColumnWidthPercent(int col)
          Return the width of a given column as a percent of the entire width.
 FieldEntry[] getFieldEntriesByKey(java.lang.String columns)
          Convert a comma delimited String of column names to an array of FieldEntry instances.
 FieldEntry getFieldEntry(java.lang.String columnName)
          Return the FieldEntry for a given clumnName
 FieldEntry[] getFullKeyedRowsByKey()
          Return an array of FieldEntry instances for key columns.
 FieldEntry getRow(int row)
          Return the FieldEntry for a given row
 int getRowCount()
          Returns the number of records managed by the data source object.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Returns an attribute value for the cell at columnIndex and rowIndex.
 void insertEntry(FieldEntry entry, int row)
          Insert an entry in the TableModel at a given row
 boolean isCellEditable(int rowIndex, int columnIndex)
          Returns true if the cell at rowIndex and columnIndex is editable.
 void moveRowDown(int row)
          Move the row down in the table
 void moveRowUp(int row)
          Move the row up in the table
 void removeRow(int row)
          Remove a row.
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
          Sets an attribute value for the record in the cell at columnIndex and rowIndex.
 
Methods inherited from class org.rimudb.editor.swing.ATableModel
getColumnFixedWidth
 
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
 

Constructor Detail

PropertyTableModel

public PropertyTableModel()
Construct a PropertyTableModel

Method Detail

addEntry

public void addEntry(FieldEntry entry)
Add an entry to the TableModel

Parameters:
entry - FieldEntry

insertEntry

public void insertEntry(FieldEntry entry,
                        int row)
Insert an entry in the TableModel at a given row

Parameters:
entry - FieldEntry
row - int

getAllRows

public FieldEntry[] getAllRows()
Return all the entries

Returns:
FieldEntry[]

getColumnClass

public java.lang.Class getColumnClass(int columnIndex)
Returns the lowest common denominator Class in the column. This is used by the table to set up a default renderer and editor for the column.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Returns:
the common ancestor class of the object values in the model.

getColumnCount

public int getColumnCount()
Returns the number of columns managed by the data source object. A JTable uses this method to determine how many columns it should create and display on initialization.

Returns:
the number or columns in the model
See Also:
getRowCount()

getColumnName

public java.lang.String getColumnName(int columnIndex)
Returns the name of the column at columnIndex. This is used to initialize the table's column header name. Note, this name does not need to be unique. Two columns on a table can have the same name.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
columnIndex - the index of column
Returns:
the name of the column

getFullKeyedRowsByKey

public FieldEntry[] getFullKeyedRowsByKey()
Return an array of FieldEntry instances for key columns. The instances are sorted by key number.

Returns:
FieldEntry[]

getFieldEntry

public FieldEntry getFieldEntry(java.lang.String columnName)
Return the FieldEntry for a given clumnName

Parameters:
columnName - String
Returns:
FieldEntry

getFieldEntriesByKey

public FieldEntry[] getFieldEntriesByKey(java.lang.String columns)
Convert a comma delimited String of column names to an array of FieldEntry instances.

Parameters:
columns - String
Returns:
FieldEntry[]

getRow

public FieldEntry getRow(int row)
Return the FieldEntry for a given row

Parameters:
row - int
Returns:
FieldEntry

getRowCount

public int getRowCount()
Returns the number of records managed by the data source object. A JTable uses this method to determine how many rows it should create and display. This method should be quick, as it is call by JTable quite frequently.

Returns:
the number or rows in the model
See Also:
getColumnCount()

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Returns an attribute value for the cell at columnIndex and rowIndex.

Parameters:
rowIndex - the row whose value is to be looked up
columnIndex - the column whose value is to be looked up
Returns:
the value Object at the specified cell

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Returns true if the cell at rowIndex and columnIndex is editable. Otherwise, setValueAt() on the cell will not change the value of that cell.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Parameters:
rowIndex - the row whose value is to be looked up
columnIndex - the column whose value is to be looked up
Returns:
true if the cell is editable.
See Also:
setValueAt(java.lang.Object, int, int)

removeRow

public void removeRow(int row)
Remove a row.


clear

public void clear()
Clear the data in the model


moveRowUp

public void moveRowUp(int row)
Move the row up in the table


moveRowDown

public void moveRowDown(int row)
Move the row down in the table


setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Sets an attribute value for the record in the cell at columnIndex and rowIndex. aValue is the new value.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel
Parameters:
aValue - the new value
rowIndex - the row whose value is to be changed
columnIndex - the column whose value is to be changed
See Also:
getValueAt(int, int), isCellEditable(int, int)

getColumnWidthPercent

public int getColumnWidthPercent(int col)
Description copied from class: ATableModel
Return the width of a given column as a percent of the entire width.

Specified by:
getColumnWidthPercent in class ATableModel
See Also:
ATableModel.getColumnWidthPercent(int)

getAllColumnNames

public java.lang.String[] getAllColumnNames()
Return an array of all the column names



Copyright © 2008-2011 Simon Ritchie. All Rights Reserved.