phenote.gui
Class TableColumnPrefsSaver

java.lang.Object
  extended by phenote.gui.TableColumnPrefsSaver
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, javax.swing.event.TableColumnModelListener

public class TableColumnPrefsSaver
extends java.lang.Object
implements java.beans.PropertyChangeListener, javax.swing.event.TableColumnModelListener

Persists user changes to column widths and order for a table using java.util.prefs. Column titles should be unique within the table. If the column content (count or titles) is changed between uses of a table, columns will be reset to the default order until the user moves them again. Not only persists changes, but enacts the ordering on the table with orderColumns


Constructor Summary
TableColumnPrefsSaver(javax.swing.JTable aTable, java.lang.String autoSaveName)
          Constructs a TableColumnPrefsSaver for the given table using a default column width of 150.
TableColumnPrefsSaver(javax.swing.JTable aTable, java.lang.String autoSaveName, int defaultColumnWidth)
          Constructs a TableColumnPrefsSaver for the given table.
 
Method Summary
 void columnAdded(javax.swing.event.TableColumnModelEvent e)
           
 void columnMarginChanged(javax.swing.event.ChangeEvent e)
           
 void columnMoved(javax.swing.event.TableColumnModelEvent e)
           
 void columnRemoved(javax.swing.event.TableColumnModelEvent e)
           
 void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
           
 void dispose()
          Removes this object from listening to any tables or table columns.
 void propertyChange(java.beans.PropertyChangeEvent e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableColumnPrefsSaver

public TableColumnPrefsSaver(javax.swing.JTable aTable,
                             java.lang.String autoSaveName)
Constructs a TableColumnPrefsSaver for the given table using a default column width of 150. Column widths and order are persisted to the preferences datastore. The autoSaveName should be sufficiently unique to avoid conflicts with saved states for other tables.


TableColumnPrefsSaver

public TableColumnPrefsSaver(javax.swing.JTable aTable,
                             java.lang.String autoSaveName,
                             int defaultColumnWidth)
Constructs a TableColumnPrefsSaver for the given table. Column widths and order are persisted to the preferences datastore. The autoSaveName should be sufficiently unique to avoid conflicts with saved states for other tables. If no column width values are already saved for this table, the defaultColumnWidth will be used.

Method Detail

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

columnAdded

public void columnAdded(javax.swing.event.TableColumnModelEvent e)
Specified by:
columnAdded in interface javax.swing.event.TableColumnModelListener

columnMarginChanged

public void columnMarginChanged(javax.swing.event.ChangeEvent e)
Specified by:
columnMarginChanged in interface javax.swing.event.TableColumnModelListener

columnMoved

public void columnMoved(javax.swing.event.TableColumnModelEvent e)
Specified by:
columnMoved in interface javax.swing.event.TableColumnModelListener

columnRemoved

public void columnRemoved(javax.swing.event.TableColumnModelEvent e)
Specified by:
columnRemoved in interface javax.swing.event.TableColumnModelListener

columnSelectionChanged

public void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
Specified by:
columnSelectionChanged in interface javax.swing.event.TableColumnModelListener

dispose

public void dispose()
Removes this object from listening to any tables or table columns.