jview
Class JPropertyEdit.PropertyTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by jview.JPropertyEdit.PropertyTableModel
All Implemented Interfaces:
Serializable, TableModel
Enclosing class:
JPropertyEdit

protected static class JPropertyEdit.PropertyTableModel
extends AbstractTableModel

A table model using a mapping of unchangable keys to changable values.

See Also:
Serialized Form

Field Summary
private  LinkedProperties properties
          The properties we want to edit converted into a linked map.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
protected JPropertyEdit.PropertyTableModel(Map<String,String> props)
          Constructs a new table model focusing on the properties given.
 
Method Summary
 int getColumnCount()
          Properties have key-value pairs, thus we return two here.
 String getColumnName(int kv)
          The column name is either name or value.
protected  Map<String,String> getProperties()
          Returns the properties.
 int getRowCount()
          The number of rows is the number of pairs stored in the properties.
 Object getValueAt(int row, int col)
          Returns the value for the cell.
 boolean isCellEditable(int row, int column)
          The only table cell that may be edited is the value part.
protected  void newComment(int index)
          Inserts a new comment.
 void setValueAt(Object to, int row, int column)
          Sets the property value at the specified row.
 
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
 

Field Detail

properties

private LinkedProperties properties
The properties we want to edit converted into a linked map.

Constructor Detail

JPropertyEdit.PropertyTableModel

protected JPropertyEdit.PropertyTableModel(Map<String,String> props)
Constructs a new table model focusing on the properties given.

Method Detail

getColumnCount

public int getColumnCount()
Properties have key-value pairs, thus we return two here.


getColumnName

public String getColumnName(int kv)
The column name is either name or value.

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

getRowCount

public int getRowCount()
The number of rows is the number of pairs stored in the properties.


getValueAt

public Object getValueAt(int row,
                         int col)
Returns the value for the cell. This is either the key name or the value mapped to it, converted to a string. Note that special properties that can not be displayed as strings may look strange, but there is no way to reconstruct the initial mapping, if parsing has alerady occured on the properties.


setValueAt

public void setValueAt(Object to,
                       int row,
                       int column)
Sets the property value at the specified row. It is not possible to change the key.

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

isCellEditable

public boolean isCellEditable(int row,
                              int column)
The only table cell that may be edited is the value part.

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

newComment

protected void newComment(int index)
Inserts a new comment. This is the insert action allowed. We add an empty comment to the underlying LinkedProperties and fire a tablerowchanged event.


getProperties

protected Map<String,String> getProperties()
Returns the properties.