com.glaivestone.mv.swing
Class TableHolder

java.lang.Object
  |
  +--com.glaivestone.mv.swing.AbstractListHolder
        |
        +--com.glaivestone.mv.swing.TableHolder

public class TableHolder
extends AbstractListHolder

A table holder is a value holder model which manages both the data model and the selection model for a list of values presented as tabular data in rows and column. Each value in the list corresponds to a row in the table.

Data elements must be instances of TableRow.

The mapping from the value into a set of column values for rendering that value is provided either by the owner of the table or by a subclass with a point of view on the type of values it holds.

Author:
Deb Lewis

Field Summary
 
Fields inherited from class com.glaivestone.mv.swing.AbstractListHolder
DEFAULT_SELECTION_MODE, MULTI_SELECT_MODE, NOT_FOUND_INDEX, SINGLE_SELECT_MODE
 
Constructor Summary
TableHolder()
          Create a new single-select mode table holder with an empty data model
TableHolder(javax.swing.table.DefaultTableModel dataModel, javax.swing.ListSelectionModel selectionModel)
          Create a new table holder with the specified data and selection models.
TableHolder(int selectionMode)
          Create a new table holder with an empty data model which is configured for the specified selection mode.
 
Method Summary
static java.util.Vector asVector(java.lang.Object[] values)
           
 boolean contains(java.lang.Object aValue)
          Answer whether the specified value is contained in the list.
static javax.swing.table.DefaultTableModel createDefaultDataModel()
          Create a new instance of the default table data model.
 java.lang.Object get(int index)
          Answer the value at the specified row position in the table data.
 javax.swing.table.TableModel getDataModel()
          Answer the data model which holds the table rows.
 java.lang.Object getRow(int index)
          Answer the row at the specified position in the table data.
 int indexOf(java.lang.Object aValue)
          Answer the index of the specified value in the list.
 void setColumnNames(java.util.List columnNames)
          Set the column names of the table.
 void setColumnNames(java.lang.String[] columnNames)
          Set the column names of the table.
 void setData(java.util.List columnNames, java.util.List rows)
          Set the column names and rows of the table.
 void setData(java.lang.String[] columnNames, java.util.List rows)
          Set the column names and rows of the table.
 int size()
          Answer the number of rows in the table.
 
Methods inherited from class com.glaivestone.mv.swing.AbstractListHolder
add, addAll, clear, clearSelection, createDefaultSelectionModel, createDefaultSelectionModel, getSelectedIndex, getSelectedValue, getSelectedValues, getSelectionModel, getSelectionSize, getValues, hasSelection, isMultiSelect, isSingleSelect, remove, remove, selectAll, selectIndex, selectIndex, selectIndices, selectIndices, selectValue, selectValue, selectValues, selectValues, setMultiSelect, setSingleSelect
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableHolder

public TableHolder()
Create a new single-select mode table holder with an empty data model


TableHolder

public TableHolder(int selectionMode)
Create a new table holder with an empty data model which is configured for the specified selection mode.


TableHolder

public TableHolder(javax.swing.table.DefaultTableModel dataModel,
                   javax.swing.ListSelectionModel selectionModel)
Create a new table holder with the specified data and selection models.

Method Detail

asVector

public static java.util.Vector asVector(java.lang.Object[] values)

createDefaultDataModel

public static javax.swing.table.DefaultTableModel createDefaultDataModel()
Create a new instance of the default table data model.


contains

public boolean contains(java.lang.Object aValue)
Answer whether the specified value is contained in the list.

Specified by:
contains in class AbstractListHolder

get

public java.lang.Object get(int index)
Answer the value at the specified row position in the table data.

Specified by:
get in class AbstractListHolder
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

getDataModel

public javax.swing.table.TableModel getDataModel()
Answer the data model which holds the table rows.


getRow

public java.lang.Object getRow(int index)
Answer the row at the specified position in the table data.

Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

indexOf

public int indexOf(java.lang.Object aValue)
Answer the index of the specified value in the list. Answer NOT_FOUND_INDEX if not found.

Specified by:
indexOf in class AbstractListHolder

setColumnNames

public void setColumnNames(java.lang.String[] columnNames)
Set the column names of the table. The row data is initialized to an empty list.


setColumnNames

public void setColumnNames(java.util.List columnNames)
Set the column names of the table. The row data is initialized to an empty list.


setData

public void setData(java.lang.String[] columnNames,
                    java.util.List rows)
Set the column names and rows of the table.


setData

public void setData(java.util.List columnNames,
                    java.util.List rows)
Set the column names and rows of the table.


size

public int size()
Answer the number of rows in the table.

Specified by:
size in class AbstractListHolder

GFL 1.1 API