Package io.guise.framework.model
Class AbstractListSelectTableModel<V>
- java.lang.Object
-
- com.globalmentor.beans.BoundPropertyObject
-
- io.guise.framework.model.AbstractModel
-
- io.guise.framework.model.AbstractValueModel<V>
-
- io.guise.framework.model.DefaultListSelectModel<V>
-
- io.guise.framework.model.AbstractListSelectTableModel<V>
-
- Type Parameters:
V
- The type of values representing table rows.
- All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable
,com.globalmentor.beans.PropertyConstrainable
,com.globalmentor.model.MutableValued<V>
,com.globalmentor.model.Valued<V>
,ListListenable<V>
,ListSelectModel<V>
,Model
,SelectModel<V>
,TableModel
,ValueModel<V>
,java.lang.Iterable<V>
,java.util.Collection<V>
,java.util.List<V>
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 io.guise.framework.model.DefaultListSelectModel
DefaultListSelectModel.ValueState
-
Nested classes/interfaces inherited from interface io.guise.framework.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 io.guise.framework.model.ValueModel
VALIDATOR_PROPERTY, VALUE_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <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 io.guise.framework.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 io.guise.framework.model.AbstractValueModel
createPropertyVetoException, getValidator, getValueClass, isValidValue, setValidator, validateValue
-
Methods inherited from class io.guise.framework.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 io.guise.framework.model.ValueModel
getValidator, getValueClass, isValidValue, setValidator, validateValue
-
-
-
-
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 isnull
.
-
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 isnull
.
-
-
Method Detail
-
getColumnIndex
public int getColumnIndex(TableColumnModel<?> column)
Description copied from interface:TableModel
Determines the logical index of the given table column.- Specified by:
getColumnIndex
in interfaceTableModel
- 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 interfaceTableModel
- Returns:
- A read-only list of table columns in physical order.
-
getRowCount
public int getRowCount()
- Specified by:
getRowCount
in interfaceTableModel
- Returns:
- The number of rows in this table.
-
getColumnCount
public int getColumnCount()
- Specified by:
getColumnCount
in interfaceTableModel
- 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)
Description copied from interface:TableModel
Returns the cell value for the given cell. This method delegates toTableModel.getCellValue(int, TableColumnModel)
.- Specified by:
getCellValue
in interfaceTableModel
- 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.
-
getCellValue
public <C> C getCellValue(int rowIndex, TableColumnModel<C> column)
Description copied from interface:TableModel
Returns the cell value at the given row and column.- Specified by:
getCellValue
in interfaceTableModel
- 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.
-
setCellValue
public <C> void setCellValue(TableModel.Cell<C> cell, C newCellValue)
Description copied from interface:TableModel
Sets the cell value for the given cell. This method delegates toTableModel.setCellValue(int, TableColumnModel, Object)
.- Specified by:
setCellValue
in interfaceTableModel
- 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, ornull
if there should be no value in that cell.
-
setCellValue
public <C> void setCellValue(int rowIndex, TableColumnModel<C> column, C newCellValue)
Description copied from interface:TableModel
Sets the cell value at the given row and column.- Specified by:
setCellValue
in interfaceTableModel
- 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, ornull
if there should be no value in that cell.
-
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, ornull
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.
-
-