Preferences Editor

de.jppietsch.prefedit
Class PreferencesTableModel

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byde.jppietsch.prefedit.PreferencesTableModel
All Implemented Interfaces:
EventListener, PreferenceChangeListener, Serializable, TableModel

public class PreferencesTableModel
extends AbstractTableModel
implements PreferenceChangeListener

A table model to display a Preferences as a table where each entry is a row. The keys are in column 0 and the values are in column 2.

Version:
$Revision: 1.8 $
Author:
Jan-Peter Pietsch
See Also:
Serialized Form

Field Summary
private static String[] EMPTY_KEYS
          Description of the Field
private static int KEY_COLUMN
          Description of the Field
private  Preferences preferences
          Description of the Field
private  RscBundle rsc
          Resource bundle which delivers column names etc.
static int VALUE_COLUMN
          Description of the Field
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
PreferencesTableModel()
           
 
Method Summary
 int getColumnCount()
          Gets the columnCount attribute of the PreferencesTableModel object
 String getColumnName(int aColumnIndex)
          Returns the name of a column from the resource bundle's resources Rsc.KEY_COLUMN_NAME and Rsc.VALUE_COLUMN_NAME.
 int getRowCount()
          Gets the rowCount attribute of the PreferencesTableModel object
 Object getValueAt(int aRowIndex, int aColumnIndex)
          Gets the valueAt attribute of the PreferencesTableModel object
 boolean isCellEditable(int aRowIndex, int aColumnIndex)
          Returns true for the right column, because the preferences values are editable, but not their keys.
private  String key(int aRowIndex)
          Description of the Method
private  String[] keys()
          Description of the Method
 void preferenceChange(PreferenceChangeEvent anEvent)
          Fires a table data changed event.
 void setPreferences(Preferences somePreferences)
          Assigns a preferences node to this table model.
 void setValueAt(Object aValue, int aRowIndex, int aColumnIndex)
          Changes the value of a preference.
 
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

VALUE_COLUMN

public static final int VALUE_COLUMN
Description of the Field

See Also:
Constant Field Values

KEY_COLUMN

private static final int KEY_COLUMN
Description of the Field

See Also:
Constant Field Values

EMPTY_KEYS

private static final String[] EMPTY_KEYS
Description of the Field


preferences

private Preferences preferences
Description of the Field


rsc

private final RscBundle rsc
Resource bundle which delivers column names etc.

Constructor Detail

PreferencesTableModel

public PreferencesTableModel()
Method Detail

getRowCount

public int getRowCount()
Gets the rowCount attribute of the PreferencesTableModel object

Specified by:
getRowCount in interface TableModel
Returns:
The rowCount value

getColumnCount

public int getColumnCount()
Gets the columnCount attribute of the PreferencesTableModel object

Specified by:
getColumnCount in interface TableModel
Returns:
The columnCount value

getColumnName

public String getColumnName(int aColumnIndex)
Returns the name of a column from the resource bundle's resources Rsc.KEY_COLUMN_NAME and Rsc.VALUE_COLUMN_NAME.

Specified by:
getColumnName in interface TableModel
Parameters:
aColumnIndex - KEY_COLUMN oder VALUE_COLUMN.
Returns:
Localized name of column.

isCellEditable

public boolean isCellEditable(int aRowIndex,
                              int aColumnIndex)
Returns true for the right column, because the preferences values are editable, but not their keys.

Specified by:
isCellEditable in interface TableModel
Parameters:
aRowIndex - Is ignored, there is no difference between the rows.
aColumnIndex - 0 is not editable, but 1 is.
Returns:
aColumnIndex==1.

getValueAt

public Object getValueAt(int aRowIndex,
                         int aColumnIndex)
Gets the valueAt attribute of the PreferencesTableModel object

Specified by:
getValueAt in interface TableModel
Parameters:
aRowIndex - Description of Parameter
aColumnIndex - Description of Parameter
Returns:
The valueAt value

setValueAt

public void setValueAt(Object aValue,
                       int aRowIndex,
                       int aColumnIndex)
Changes the value of a preference.

Specified by:
setValueAt in interface TableModel
Parameters:
aValue - Must be a string.
aRowIndex - Determines the key of the preference to be changed.
aColumnIndex - Must be 1 because that's the values column's index.

setPreferences

public void setPreferences(Preferences somePreferences)
Assigns a preferences node to this table model.

Parameters:
somePreferences - The preferences object to be displayed or null if there is none (e.g. for the tree's root node).

preferenceChange

public void preferenceChange(PreferenceChangeEvent anEvent)
Fires a table data changed event.

Specified by:
preferenceChange in interface PreferenceChangeListener
Parameters:
anEvent - is currently not used, but may be in future.

key

private String key(int aRowIndex)
Description of the Method

Parameters:
aRowIndex - Description of Parameter
Returns:
Description of the Returned Value

keys

private String[] keys()
Description of the Method

Returns:
Description of the Returned Value

Preferences Editor