com.guiseframework.component.urf
Class URFResourceTableModel

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<com.globalmentor.urf.URFResource>
                      extended by com.guiseframework.component.urf.URFResourceTableModel
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, ListListenable<com.globalmentor.urf.URFResource>, ListSelectModel<com.globalmentor.urf.URFResource>, Model, SelectModel<com.globalmentor.urf.URFResource>, TableModel, Valued<com.globalmentor.urf.URFResource>, ValueModel<com.globalmentor.urf.URFResource>, java.lang.Iterable<com.globalmentor.urf.URFResource>, java.util.Collection<com.globalmentor.urf.URFResource>, java.util.List<com.globalmentor.urf.URFResource>

public class URFResourceTableModel
extends AbstractListSelectTableModel<com.globalmentor.urf.URFResource>

A table model based upon a list of URF resource. This table recognizes URFResourceURITableColumnModel columns. As for other columns, this table only recognizes URFPropertyTableColumnModel columns and will throw an exception if such a column is not found, so subclasses using non-URF property columns should override getCellValue(URFResource, int, TableColumnModel) and use setCellValue(URFResource, int, TableColumnModel, Object) to handle those custom columns before delegating to this class. For URFPropertyTableColumnModel columns, if the TableColumnModel.getValueClass() is URFResource, then the value will be used as-is. Otherwise, it will be attempted to be converted to the correct type using URF.asObject(Resource). If the returned object is not of the correct type, the value will be ignored rather than a ClassCastException thrown, as a common use case is to display loosely-coupled URF resources that could have various value types. Values to be set, on the other hand, must be of the appropriate value or a ClassCastException will be thrown. Setting non-resource values is not yet supported.

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
URFResourceTableModel(TableColumnModel<?>... columns)
          Constructs a table model indicating the type of values it can hold, using a default multiple selection strategy.
 
Method Summary
protected
<C> C
getCellValue(com.globalmentor.urf.URFResource resource, int rowIndex, TableColumnModel<C> column)
          Returns the value's property for the given column.
protected
<C> void
setCellValue(com.globalmentor.urf.URFResource resource, int rowIndex, TableColumnModel<C> column, C newCellValue)
          Sets the value's property for the given column.
 
Methods inherited from class com.guiseframework.model.AbstractListSelectTableModel
getCellValue, getCellValue, getCellValueModel, getColumnCount, getColumnIndex, getColumns, getRowCount, setCellValue, setCellValue
 
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

URFResourceTableModel

public URFResourceTableModel(TableColumnModel<?>... columns)
Constructs a table model indicating the type of values it can hold, using a default multiple selection strategy.

Parameters:
columns - The models representing the table columns.
Method Detail

getCellValue

protected <C> C getCellValue(com.globalmentor.urf.URFResource resource,
                             int rowIndex,
                             TableColumnModel<C> column)
Returns the value's property for the given column.

Specified by:
getCellValue in class AbstractListSelectTableModel<com.globalmentor.urf.URFResource>
Type Parameters:
C - The type of cell values in the given column.
Parameters:
resource - The resource 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.
java.lang.ClassCastException - if the given column is not a URFPropertyTableColumnModel or one of the other column types supported by this class.

setCellValue

protected <C> void setCellValue(com.globalmentor.urf.URFResource resource,
                                int rowIndex,
                                TableColumnModel<C> column,
                                C newCellValue)
Sets the value's property for the given column.

Specified by:
setCellValue in class AbstractListSelectTableModel<com.globalmentor.urf.URFResource>
Type Parameters:
C - The type of cell values in the given column.
Parameters:
resource - The resource 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.
java.lang.ClassCastException - if the given column is not a URFPropertyTableColumnModel or one of the other column types supported by this class or the new cell value is not an URFResource.


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