ehsbe CommonsTM
Version 1.1.0rc3

com.ehsbe.commons.gui
Class PropertyTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by javax.swing.table.DefaultTableModel
          extended by com.ehsbe.commons.gui.PropertyTableModel
All Implemented Interfaces:
Serializable, TableModel

public class PropertyTableModel
extends DefaultTableModel

A simple Table model for properties.

Version:
$Revision: 433 $
Author:
Jens Elkner
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.DefaultTableModel
columnIdentifiers, dataVector
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
PropertyTableModel(Map<?,?> props, String keyName, String valueName)
          Create a new (n,2) table model, where the keys in the Map represent the first column and the values the second column.
 
Method Summary
 boolean isCellEditable(int row, int column)
          Per contract a value cell is always editable to allow copy operations.
 boolean isEditable()
          Check, whether the content of value cells is allowed to be changed.
 void setEditable(boolean editable)
          Set, whether the content of value cells is allowed to be changed.
 void setValueAt(Object o, int row, int column)
          Sets the value only, if the table is editable.
 
Methods inherited from class javax.swing.table.DefaultTableModel
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getColumnCount, getColumnName, getDataVector, getRowCount, getValueAt, insertRow, insertRow, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, 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(Map<?,?> props,
                          String keyName,
                          String valueName)
Create a new (n,2) table model, where the keys in the Map represent the first column and the values the second column.

Parameters:
props - table to copy to a Object[][2] array. null will be treated as { {"" , ""} }.
keyName - header name for the key column. Might be null.
valueName - header name for the value column. Might be null.
See Also:
setEditable(boolean), isEditable()
Method Detail

setEditable

public void setEditable(boolean editable)
Set, whether the content of value cells is allowed to be changed. Default is false.

Parameters:
editable - If true the content of value cells are changeable

isEditable

public boolean isEditable()
Check, whether the content of value cells is allowed to be changed.

Returns:
true if content of value cells are changeable

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Per contract a value cell is always editable to allow copy operations. However, if the table is not editable, the cell editing will have no effect, i.e. reverts to its original value, when the focus gets lost.

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class DefaultTableModel
Parameters:
row -
column -
Returns:
true for a value cell, otherwise false.

setValueAt

public void setValueAt(Object o,
                       int row,
                       int column)
Sets the value only, if the table is editable.

Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class DefaultTableModel
Parameters:
o -
row -
column -
See Also:
setEditable(boolean), isEditable()

ehsbe CommonsTM
Version 1.1.0rc3

Copyright ©2005-2009 EHSBE, Walther-Rathenau-Str. 58, 39104 Magdeburg, Sachsen-Anhalt, Germany. All Rights Reserved.