com.guiseframework.model
Class AbstractListSelectTableModel<V>

java.lang.Object
  extended by com.globalmentor.beans.BoundPropertyObject
      extended by com.guiseframework.model.AbstractModel
          extended by com.guiseframework.model.AbstractValueModel<V>
              extended by com.guiseframework.model.DefaultListSelectModel<V>
                  extended by com.guiseframework.model.AbstractListSelectTableModel<V>
Type Parameters:
V - The type of values representing table rows.
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, ListListenable<V>, ListSelectModel<V>, Model, SelectModel<V>, TableModel, Valued<V>, ValueModel<V>, java.lang.Iterable<V>, java.util.Collection<V>, java.util.List<V>
Direct Known Subclasses:
AuthorizeUsersPanel.UserAuthorizationTableModel, RDFResourceTableModel, URFResourceTableModel

public abstract class AbstractListSelectTableModel<V>
extends DefaultListSelectModel<V>
implements TableModel

An abstract implementation of a table model representing selectable list values. The model is thread-safe, synchronized on itself. Any iteration over values should include synchronization on the instance of this class.

Author:
Garret Wilson

Nested Class Summary
 
Nested classes/interfaces inherited from class com.guiseframework.model.DefaultListSelectModel
DefaultListSelectModel.ValueState
 
Nested classes/interfaces inherited from interface com.guiseframework.model.TableModel
TableModel.Cell<C>
 
Field Summary
 
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
 
Fields inherited from interface com.guiseframework.model.Model
PLAIN_TEXT_CONTENT_TYPE, XHTML_CONTENT_TYPE, XHTML_FRAGMENT_CONTENT_TYPE
 
Fields inherited from interface com.guiseframework.model.ValueModel
VALIDATOR_PROPERTY, VALUE_PROPERTY
 
Constructor Summary
AbstractListSelectTableModel(java.lang.Class<V> valueClass, ListSelectionPolicy<V> listSelectionStrategy, TableColumnModel<?>... columns)
          Constructs a list select table model indicating the type of values it can hold.
AbstractListSelectTableModel(java.lang.Class<V> valueClass, TableColumnModel<?>... columns)
          Constructs a list select table model indicating the type of values it can hold, using a default multiple selection strategy.
 
Method Summary
<C> C
getCellValue(int rowIndex, TableColumnModel<C> column)
          Returns the cell value at the given row and column.
<C> C
getCellValue(TableModel.Cell<C> cell)
          Returns the cell value for the given cell.
protected abstract
<C> C
getCellValue(V value, int rowIndex, TableColumnModel<C> column)
          Returns the value's property for the given column.
 ValueModel<java.lang.Object> getCellValueModel(int rowIndex, int colIndex)
          Returns the model representing the cell value at the given row and column.
 int getColumnCount()
           
 int getColumnIndex(TableColumnModel<?> column)
          Determines the logical index of the given table column.
 java.util.List<TableColumnModel<?>> getColumns()
           
 int getRowCount()
           
<C> void
setCellValue(int rowIndex, TableColumnModel<C> column, C newCellValue)
          Sets the cell value at the given row and column.
<C> void
setCellValue(TableModel.Cell<C> cell, C newCellValue)
          Sets the cell value for the given cell.
protected abstract
<C> void
setCellValue(V value, int rowIndex, TableColumnModel<C> column, C newCellValue)
          Sets the value's property for the given column.
 
Methods inherited from class com.guiseframework.model.DefaultListSelectModel
add, add, addAll, addAll, addListListener, addListSelectionListener, addSelectedIndexes, clear, clearValue, contains, containsAll, fireListModified, fireSelectionChanged, get, getDefaultValue, getSelectedIndex, getSelectedIndexes, getSelectedValue, getSelectedValues, getSelectionPolicy, getValue, indexOf, isEmpty, isIndexDisplayed, isIndexEnabled, isValueDisplayed, isValueEnabled, iterator, lastIndexOf, listIterator, listIterator, listModified, remove, remove, removeAll, removeListListener, removeListSelectionListener, removeSelectedIndexes, replace, resetValue, retainAll, set, setIndexDisplayed, setIndexEnabled, setSelectedIndexes, setSelectedValues, setValue, setValueDisplayed, setValueEnabled, size, subList, toArray, toArray
 
Methods inherited from class com.guiseframework.model.AbstractValueModel
createPropertyVetoException, getValidator, getValueClass, isValidValue, setValidator, validateValue
 
Methods inherited from class com.guiseframework.model.AbstractModel
getEventListenerManager, getPlainText
 
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface com.globalmentor.beans.PropertyConstrainable
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, hasVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from interface com.guiseframework.model.ValueModel
getValidator, getValueClass, isValidValue, setValidator, validateValue
 
Methods inherited from interface java.util.List
equals, hashCode
 

Constructor Detail

AbstractListSelectTableModel

public AbstractListSelectTableModel(java.lang.Class<V> valueClass,
                                    TableColumnModel<?>... columns)
Constructs a list select table model indicating the type of values it can hold, using a default multiple selection strategy.

Parameters:
valueClass - The class indicating the type of values held in the model.
columns - The models representing the table columns.
Throws:
java.lang.NullPointerException - if the given value class is null.

AbstractListSelectTableModel

public AbstractListSelectTableModel(java.lang.Class<V> valueClass,
                                    ListSelectionPolicy<V> listSelectionStrategy,
                                    TableColumnModel<?>... columns)
Constructs a list select table model indicating the type of values it can hold. The selection strategy is not added as a listener to this model but is rather notified manually so that the event won't be delayed and/or sent out of order

Parameters:
valueClass - The class indicating the type of values held in the model.
listSelectionStrategy - The strategy for selecting values in the model.
columns - The models representing the table columns.
Throws:
java.lang.NullPointerException - if the given value class and/or selection strategy is null.
Method Detail

getColumnIndex

public int getColumnIndex(TableColumnModel<?> column)
Determines the logical index of the given table column.

Specified by:
getColumnIndex in interface TableModel
Parameters:
column - One of the table columns.
Returns:
The zero-based logical index of the column within the table, or -1 if the column is not one of the model's columns.

getColumns

public java.util.List<TableColumnModel<?>> getColumns()
Specified by:
getColumns in interface TableModel
Returns:
A read-only list of table columns in physical order.

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel
Returns:
The number of rows in this table.

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel
Returns:
The number of columns in this table.

getCellValueModel

public ValueModel<java.lang.Object> getCellValueModel(int rowIndex,
                                                      int colIndex)
Returns the model representing the cell value at the given row and column.

Parameters:
rowIndex - The zero-based row index.
colIndex - The zero-based column index.
Returns:
The value model representing the value in the cell at the given row and column.
Throws:
java.lang.IndexOutOfBoundsException - if the given row index and/or column index represents an invalid location for the table.

getCellValue

public <C> C getCellValue(TableModel.Cell<C> cell)
Returns the cell value for the given cell. This method delegates to getCellValue(int, TableColumnModel).

Specified by:
getCellValue in interface TableModel
Type Parameters:
C - The type of cell value.
Parameters:
cell - The cell containing the row index and column information.
Returns:
The value in the cell at the given row and column, or null if there is no value in that cell.
Throws:
java.lang.IndexOutOfBoundsException - if the given row index represents an invalid location for the table.
java.lang.IllegalArgumentException - if the given column is not one of this table's columns.

getCellValue

public <C> C getCellValue(int rowIndex,
                          TableColumnModel<C> column)
Returns the cell value at the given row and column.

Specified by:
getCellValue in interface TableModel
Type Parameters:
C - The type of cell values in the given column.
Parameters:
rowIndex - The zero-based row index.
column - The column for which a value should be returned.
Returns:
The value in the cell at the given row and column, or null if there is no value in that cell.
Throws:
java.lang.IndexOutOfBoundsException - if the given row index represents an invalid location for the table.
java.lang.IllegalArgumentException - if the given column is not one of this table's columns.

setCellValue

public <C> void setCellValue(TableModel.Cell<C> cell,
                             C newCellValue)
Sets the cell value for the given cell. This method delegates to #setCellValue(int, TableColumnModel, C).

Specified by:
setCellValue in interface TableModel
Type Parameters:
C - The type of cell value.
Parameters:
cell - The cell containing the row index and column information.
newCellValue - The value to place in the cell at the given row and column, or null if there should be no value in that cell.
Throws:
java.lang.IndexOutOfBoundsException - if the given row index represents an invalid location for the table.
java.lang.IllegalArgumentException - if the given column is not one of this table's columns.

setCellValue

public <C> void setCellValue(int rowIndex,
                             TableColumnModel<C> column,
                             C newCellValue)
Sets the cell value at the given row and column.

Specified by:
setCellValue in interface TableModel
Type Parameters:
C - The type of cell values in the given column.
Parameters:
rowIndex - The zero-based row index.
column - The column for which a value should be returned.
newCellValue - The value to place in the cell at the given row and column, or null if there should be no value in that cell.
Throws:
java.lang.IndexOutOfBoundsException - if the given row index represents an invalid location for the table.
java.lang.IllegalArgumentException - if the given column is not one of this table's columns.

getCellValue

protected abstract <C> C getCellValue(V value,
                                      int rowIndex,
                                      TableColumnModel<C> column)
Returns the value's property for the given column.

Type Parameters:
C - The type of cell values in the given column.
Parameters:
value - The value in this list select model.
rowIndex - The zero-based row index of the value.
column - The column for which a value should be returned.
Returns:
The value in the cell at the given row and column, or null if there is no value in that cell.
Throws:
java.lang.IndexOutOfBoundsException - if the given row index represents an invalid location for the table.
java.lang.IllegalArgumentException - if the given column is not one of this table's columns.

setCellValue

protected abstract <C> void setCellValue(V value,
                                         int rowIndex,
                                         TableColumnModel<C> column,
                                         C newCellValue)
Sets the value's property for the given column.

Type Parameters:
C - The type of cell values in the given column.
Parameters:
value - The value in this list select model.
rowIndex - The zero-based row index of the value.
column - The column for which a value should be returned.
newCellValue - The value to place in the cell at the given row and column, or null if there should be no value in that cell.
Throws:
java.lang.IndexOutOfBoundsException - if the given row index represents an invalid location for the table.
java.lang.IllegalArgumentException - if the given column is not one of this table's columns.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.