com.l2fprod.common.propertysheet
Class PropertySheetTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.l2fprod.common.propertysheet.PropertySheetTableModel
All Implemented Interfaces:
PropertySheet, ObjectTableModel, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.swing.table.TableModel

public class PropertySheetTableModel
extends javax.swing.table.AbstractTableModel
implements java.beans.PropertyChangeListener, PropertySheet, ObjectTableModel

PropertySheetTableModel.

See Also:
Serialized Form

Nested Class Summary
 class PropertySheetTableModel.Item
           
static class PropertySheetTableModel.NaturalOrderStringComparator
           
static class PropertySheetTableModel.PropertyComparator
          The default comparator for Properties.
 
Field Summary
static int NAME_COLUMN
           
static int NUM_COLUMNS
           
static int VALUE_COLUMN
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface com.l2fprod.common.propertysheet.PropertySheet
VIEW_AS_CATEGORIES, VIEW_AS_FLAT_LIST
 
Constructor Summary
PropertySheetTableModel()
           
 
Method Summary
 void addProperty(int index, Property property)
           
 void addProperty(Property property)
           
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener to the current model.
 java.lang.Class getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 int getMode()
          Get the current mode, either PropertySheet.VIEW_AS_CATEGORIES or PropertySheet.VIEW_AS_FLAT_LIST.
 java.lang.Object getObject(int rowIndex)
           
 Property[] getProperties()
           
protected  java.util.List getPropertyCategories(java.util.List localProperties)
           
 int getPropertyCount()
           
 PropertySheetTableModel.Item getPropertySheetElement(int rowIndex)
          Get the current property sheet element, of type PropertySheetTableModel.Item, at the specified row.
 int getRowCount()
           
 java.util.Map getToggleStates()
           
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Retrieve the value at the specified row and column location.
 boolean isRestoreToggleStates()
          Get whether this model is restoring toggle states
 boolean isSortingCategories()
          Get whether this model is currently sorting categories.
 boolean isSortingProperties()
          Get whether this model is currently sorting properties.
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 java.util.Iterator propertyIterator()
           
 void removeProperty(Property property)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void setCategorySortingComparator(java.util.Comparator comp)
          Set the comparator used for sorting categories.
 void setMode(int mode)
          Set the current mode, either PropertySheet.VIEW_AS_CATEGORIES or PropertySheet.VIEW_AS_FLAT_LIST.
 void setProperties(Property[] newProperties)
           
 void setPropertySortingComparator(java.util.Comparator comp)
          Set the comparator used for sorting properties.
 void setRestoreToggleStates(boolean value)
          Set whether or not this model will restore the toggle states when new properties are applied.
 void setSortingCategories(boolean value)
          Set whether this model is currently sorting categories.
 void setSortingProperties(boolean value)
          Set whether this model is currently sorting properties.
 void setToggleStates(java.util.Map toggleStates)
          Sets the toggle states for the category views.
 void setValueAt(java.lang.Object value, int rowIndex, int columnIndex)
          Sets the value at the specified row and column.
protected  java.util.List sortCategories(java.util.List localCategories)
           
protected  java.util.List sortProperties(java.util.List localProperties)
           
protected  void visibilityChanged(boolean restoreOldStates)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnName, isCellEditable, removeTableModelListener
 

Field Detail

NAME_COLUMN

public static final int NAME_COLUMN
See Also:
Constant Field Values

VALUE_COLUMN

public static final int VALUE_COLUMN
See Also:
Constant Field Values

NUM_COLUMNS

public static final int NUM_COLUMNS
See Also:
Constant Field Values
Constructor Detail

PropertySheetTableModel

public PropertySheetTableModel()
Method Detail

setProperties

public void setProperties(Property[] newProperties)
Specified by:
setProperties in interface PropertySheet

getProperties

public Property[] getProperties()
Specified by:
getProperties in interface PropertySheet

addProperty

public void addProperty(Property property)
Specified by:
addProperty in interface PropertySheet

addProperty

public void addProperty(int index,
                        Property property)
Specified by:
addProperty in interface PropertySheet

removeProperty

public void removeProperty(Property property)
Specified by:
removeProperty in interface PropertySheet

getPropertyCount

public int getPropertyCount()
Specified by:
getPropertyCount in interface PropertySheet

propertyIterator

public java.util.Iterator propertyIterator()
Specified by:
propertyIterator in interface PropertySheet

setMode

public void setMode(int mode)
Set the current mode, either PropertySheet.VIEW_AS_CATEGORIES or PropertySheet.VIEW_AS_FLAT_LIST.


getMode

public int getMode()
Get the current mode, either PropertySheet.VIEW_AS_CATEGORIES or PropertySheet.VIEW_AS_FLAT_LIST.


getColumnClass

public java.lang.Class getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface javax.swing.table.TableModel

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface javax.swing.table.TableModel

getObject

public java.lang.Object getObject(int rowIndex)
Specified by:
getObject in interface ObjectTableModel

getPropertySheetElement

public PropertySheetTableModel.Item getPropertySheetElement(int rowIndex)
Get the current property sheet element, of type PropertySheetTableModel.Item, at the specified row.


isSortingCategories

public boolean isSortingCategories()
Get whether this model is currently sorting categories.


setSortingCategories

public void setSortingCategories(boolean value)
Set whether this model is currently sorting categories. If this changes the sorting, the model will be rebuilt.


isSortingProperties

public boolean isSortingProperties()
Get whether this model is currently sorting properties.


setSortingProperties

public void setSortingProperties(boolean value)
Set whether this model is currently sorting properties. If this changes the sorting, the model will be rebuilt.


setCategorySortingComparator

public void setCategorySortingComparator(java.util.Comparator comp)
Set the comparator used for sorting categories. If this changes the comparator, the model will be rebuilt.


setPropertySortingComparator

public void setPropertySortingComparator(java.util.Comparator comp)
Set the comparator used for sorting properties. If this changes the comparator, the model will be rebuilt.


setRestoreToggleStates

public void setRestoreToggleStates(boolean value)
Set whether or not this model will restore the toggle states when new properties are applied.


isRestoreToggleStates

public boolean isRestoreToggleStates()
Get whether this model is restoring toggle states


getToggleStates

public java.util.Map getToggleStates()
Returns:
the category view toggle states.

setToggleStates

public void setToggleStates(java.util.Map toggleStates)
Sets the toggle states for the category views. Note this MUST be called BEFORE setting any properties.

Parameters:
toggleStates - the toggle states as returned by getToggleStates

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Retrieve the value at the specified row and column location. When the row contains a category or the column is NAME_COLUMN, an PropertySheetTableModel.Item object will be returned. If the row is a property and the column is VALUE_COLUMN, the value of the property will be returned.

Specified by:
getValueAt in interface javax.swing.table.TableModel
See Also:
TableModel.getValueAt(int, int)

setValueAt

public void setValueAt(java.lang.Object value,
                       int rowIndex,
                       int columnIndex)
Sets the value at the specified row and column. This will have no effect unless the row is a property and the column is VALUE_COLUMN.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel
See Also:
TableModel.setValueAt(java.lang.Object, int, int)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the current model.


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

propertyChange

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

visibilityChanged

protected void visibilityChanged(boolean restoreOldStates)

sortProperties

protected java.util.List sortProperties(java.util.List localProperties)

sortCategories

protected java.util.List sortCategories(java.util.List localCategories)

getPropertyCategories

protected java.util.List getPropertyCategories(java.util.List localProperties)