Package docking.widgets.table

# Class AbstractGTableModel<T>

java.lang.Object
javax.swing.table.AbstractTableModel
docking.widgets.table.AbstractGTableModel<T>

All Implemented Interfaces:
  `RowObjectTableModel<T>`, `SelectionStorage<T>`, `Serializable`, `TableModel`

Direct Known Subclasses:
  `AbstractSortedTableModel`

public abstract class AbstractGTableModel<T> extends AbstractTableModel implements RowObjectTableModel<T>, SelectionStorage<T>

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected boolean`
  `isDisposed`
  `static final int`
  `WIDTH_UNDEFINED`

  ### Fields inherited from class javax.swing.table.AbstractTableModel

  `listenerList`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractGTableModel()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `dispose()`
  Call this when the model will no longer be used
  `protected int`
  `getIndexForRowObject(T rowObject)`
  A convenience method to search for the index of a given row object that is visible in the GUI.
  `protected int`
  `getIndexForRowObject(T rowObject, List<T> data)`
  Returns the index for the given object in the given list; -1 when the item is not in the list.
  `List<T>`
  `getLastSelectedObjects()`
  `int`
  `getPreferredColumnWidth(int columnIndex)`
  `int`
  `getRowCount()`
  `int`
  `getRowIndex(T rowObject)`
  Returns the row number for the given object.
  `T`
  `getRowObject(int row)`
  Returns the row object for the given row.
  `Object`
  `getValueAt(int rowIndex, int columnIndex)`
  The default implementation of `TableModel.getValueAt(int, int)` that calls the abstract `RowObjectTableModel.getColumnValueForRow(Object, int)`.
  `boolean`
  `isDisposed()`
  Returns true if `dispose()` has been called
  `void`
  `refresh()`
  Invoke this method when the underlying data has changed, but a reload is not required.
  `void`
  `setLastSelectedObjects(List<T> lastSelectedObjects)`

  ### Methods inherited from class javax.swing.table.AbstractTableModel

  `addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface docking.widgets.table.RowObjectTableModel

  `fireTableDataChanged, getColumnValueForRow, getModelData, getName`

  ### Methods inherited from interface javax.swing.table.TableModel

  `addTableModelListener, getColumnClass, getColumnCount, getColumnName, isCellEditable, removeTableModelListener, setValueAt`

- ## Field Details

  - ### WIDTH_UNDEFINED

    public static final int WIDTH_UNDEFINED
    See Also:
      - Constant Field Values

  - ### isDisposed

    protected boolean isDisposed

- ## Constructor Details

  - ### AbstractGTableModel

    public AbstractGTableModel()

- ## Method Details

  - ### getRowObject

    public T getRowObject(int row)
    Description copied from interface: `RowObjectTableModel`
    Returns the row object for the given row. This is the row in the UI. For models that know how to filter, the model row value will not match the view row value. For non-filtering models the view and model rows will always be the same.
    Specified by:
      `getRowObject` in interface `RowObjectTableModel<T>`
    Parameters:
      `row` - the row for which to return a row object.
    Returns:
      the row object

  - ### getRowIndex

    public int getRowIndex(T rowObject)
    Description copied from interface: `RowObjectTableModel`
    Returns the row number for the given object.

    Note: the index returned is always the 'view' index. For non-filtering table models, the 'view' and the 'model' index are the same. However, for filtering table models, the 'view' may be a subset of the 'model' index. Thus, it is possible, if this model is a filtering model, that the given `t` may not have a row value for the current state of the model (i.e., when the model is filtered in the view. If you really need to get the model index in such a situation, see `RowObjectFilterModel`.

    Specified by:
      `getRowIndex` in interface `RowObjectTableModel<T>`
    Parameters:
      `rowObject` - the object
    Returns:
      the row number

  - ### getRowCount

    public int getRowCount()
    Specified by:
      `getRowCount` in interface `TableModel`

  - ### refresh

    public void refresh()
    Invoke this method when the underlying data has changed, but a reload is not required.

  - ### getLastSelectedObjects

    public List<T> getLastSelectedObjects()
    Specified by:
      `getLastSelectedObjects` in interface `SelectionStorage<T>`

  - ### setLastSelectedObjects

    public void setLastSelectedObjects(List<T> lastSelectedObjects)
    Specified by:
      `setLastSelectedObjects` in interface `SelectionStorage<T>`

  - ### getPreferredColumnWidth

    public int getPreferredColumnWidth(int columnIndex)

  - ### getValueAt

    public Object getValueAt(int rowIndex, int columnIndex)
    The default implementation of `TableModel.getValueAt(int, int)` that calls the abstract `RowObjectTableModel.getColumnValueForRow(Object, int)`.
    Specified by:
      `getValueAt` in interface `TableModel`

  - ### getIndexForRowObject

    protected int getIndexForRowObject(T rowObject)
    A convenience method to search for the index of a given row object that is visible in the GUI. The visible limitation is due to the fact that the data searched is retrieved from `RowObjectTableModel.getModelData()`, which may be filtered.

    Note: this operation is O(n). For quick lookups, consider using the sorted version of this class.

    Parameters:
      `rowObject` - The object for which to search.
    Returns:
      the index of the item in the data returned by

  - ### getIndexForRowObject

    protected int getIndexForRowObject(T rowObject, List<T> data)
    Returns the index for the given object in the given list; -1 when the item is not in the list.
    Parameters:
      `rowObject` - the item
      `data` - the data
    Returns:
      the index

  - ### dispose

    public void dispose()
    Call this when the model will no longer be used

  - ### isDisposed

    public boolean isDisposed()
    Returns true if `dispose()` has been called
    Returns:
      true if `dispose()` has been called