Class TableModelWrapper<ROW_OBJECT>
- java.lang.Object
-
- docking.widgets.table.TableModelWrapper<ROW_OBJECT>
-
- Type Parameters:
ROW_OBJECT
- the row object type
- All Implemented Interfaces:
RowObjectFilterModel<ROW_OBJECT>
,RowObjectTableModel<ROW_OBJECT>
,SelectionStorage<ROW_OBJECT>
,javax.swing.table.TableModel
public class TableModelWrapper<ROW_OBJECT> extends java.lang.Object implements RowObjectFilterModel<ROW_OBJECT>, SelectionStorage<ROW_OBJECT>
A wrapper that will take a table model and decorate it with filtering capability. This is only needed when the given model does not have filtering.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.Integer>
filteredIndexList
-
Fields inherited from interface docking.widgets.table.RowObjectFilterModel
SUB_FILTERING_DISABLED_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description TableModelWrapper(RowObjectTableModel<ROW_OBJECT> wrappedModel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTableModelListener(javax.swing.event.TableModelListener l)
void
fireTableDataChanged()
Sends an event to all listeners that all the data inside of this model may have changed.void
fireTableDataChanged(javax.swing.event.TableModelEvent event)
java.lang.Class<?>
getColumnClass(int columnIndex)
int
getColumnCount()
java.lang.String
getColumnName(int columnIndex)
java.lang.Object
getColumnValueForRow(ROW_OBJECT t, int columnIndex)
Implementors are expected to return a value at the given column index for the specified row object.java.util.List<ROW_OBJECT>
getLastSelectedObjects()
java.util.List<ROW_OBJECT>
getModelData()
Implementors should return the current data of the model.int
getModelIndex(ROW_OBJECT t)
Returns the model index of the given item.int
getModelRow(int viewRow)
java.lang.String
getName()
Returns the name of this modelint
getRowCount()
int
getRowIndex(ROW_OBJECT t)
Returns the row number for the given object.ROW_OBJECT
getRowObject(int viewRow)
Returns the row object for the given row.TableFilter<ROW_OBJECT>
getTableFilter()
java.util.List<ROW_OBJECT>
getUnfilteredData()
int
getUnfilteredRowCount()
java.lang.Object
getValueAt(int rowIndex, int columnIndex)
int
getViewIndex(ROW_OBJECT t)
Returns the view index of the given item.int
getViewRow(int modelRow)
javax.swing.table.TableModel
getWrappedModel()
boolean
isCellEditable(int rowIndex, int columnIndex)
boolean
isFiltered()
void
removeTableModelListener(javax.swing.event.TableModelListener l)
void
setLastSelectedObjects(java.util.List<ROW_OBJECT> lastSelectedObjects)
void
setTableFilter(TableFilter<ROW_OBJECT> tableFilter)
void
setValueAt(java.lang.Object value, int rowIndex, int columnIndex)
void
wrappedModelChangedFromTableChangedEvent()
-
-
-
Constructor Detail
-
TableModelWrapper
public TableModelWrapper(RowObjectTableModel<ROW_OBJECT> wrappedModel)
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:RowObjectTableModel
Returns the name of this model- Specified by:
getName
in interfaceRowObjectTableModel<ROW_OBJECT>
- Returns:
- the name of this model
-
getLastSelectedObjects
public java.util.List<ROW_OBJECT> getLastSelectedObjects()
- Specified by:
getLastSelectedObjects
in interfaceSelectionStorage<ROW_OBJECT>
-
setLastSelectedObjects
public void setLastSelectedObjects(java.util.List<ROW_OBJECT> lastSelectedObjects)
- Specified by:
setLastSelectedObjects
in interfaceSelectionStorage<ROW_OBJECT>
-
setTableFilter
public void setTableFilter(TableFilter<ROW_OBJECT> tableFilter)
- Specified by:
setTableFilter
in interfaceRowObjectFilterModel<ROW_OBJECT>
-
getTableFilter
public TableFilter<ROW_OBJECT> getTableFilter()
- Specified by:
getTableFilter
in interfaceRowObjectFilterModel<ROW_OBJECT>
-
getModelRow
public int getModelRow(int viewRow)
- Specified by:
getModelRow
in interfaceRowObjectFilterModel<ROW_OBJECT>
-
getViewRow
public int getViewRow(int modelRow)
- Specified by:
getViewRow
in interfaceRowObjectFilterModel<ROW_OBJECT>
-
wrappedModelChangedFromTableChangedEvent
public void wrappedModelChangedFromTableChangedEvent()
-
fireTableDataChanged
public void fireTableDataChanged(javax.swing.event.TableModelEvent event)
-
fireTableDataChanged
public void fireTableDataChanged()
Description copied from interface:RowObjectTableModel
Sends an event to all listeners that all the data inside of this model may have changed.- Specified by:
fireTableDataChanged
in interfaceRowObjectTableModel<ROW_OBJECT>
-
isFiltered
public boolean isFiltered()
- Specified by:
isFiltered
in interfaceRowObjectFilterModel<ROW_OBJECT>
-
addTableModelListener
public void addTableModelListener(javax.swing.event.TableModelListener l)
- Specified by:
addTableModelListener
in interfacejavax.swing.table.TableModel
-
removeTableModelListener
public void removeTableModelListener(javax.swing.event.TableModelListener l)
- Specified by:
removeTableModelListener
in interfacejavax.swing.table.TableModel
-
getColumnClass
public java.lang.Class<?> getColumnClass(int columnIndex)
- Specified by:
getColumnClass
in interfacejavax.swing.table.TableModel
-
getColumnCount
public int getColumnCount()
- Specified by:
getColumnCount
in interfacejavax.swing.table.TableModel
-
getColumnName
public java.lang.String getColumnName(int columnIndex)
- Specified by:
getColumnName
in interfacejavax.swing.table.TableModel
-
getRowCount
public int getRowCount()
- Specified by:
getRowCount
in interfacejavax.swing.table.TableModel
-
getUnfilteredRowCount
public int getUnfilteredRowCount()
- Specified by:
getUnfilteredRowCount
in interfaceRowObjectFilterModel<ROW_OBJECT>
-
getUnfilteredData
public java.util.List<ROW_OBJECT> getUnfilteredData()
- Specified by:
getUnfilteredData
in interfaceRowObjectFilterModel<ROW_OBJECT>
-
getModelData
public java.util.List<ROW_OBJECT> getModelData()
Description copied from interface:RowObjectTableModel
Implementors should return the current data of the model. For models that support filtering, this will be the filtered version of the data. Furthermore, the data should be the underlying data and not a copy, as this method will potentially sort the given data.For those subclasses using an array, you may use the Arrays class to create a list backed by the array (
Arrays.asList(Object...)
).- Specified by:
getModelData
in interfaceRowObjectTableModel<ROW_OBJECT>
- Returns:
- the model data.
-
getModelIndex
public int getModelIndex(ROW_OBJECT t)
Description copied from interface:RowObjectFilterModel
Returns the model index of the given item. When filtered, this is the index is the larger, set of data; when unfiltered, this index is the same as that returned byRowObjectFilterModel.getModelIndex(Object)
.This operation will be O(n) unless the implementation is sorted, in which case the operation is O(log n), as it uses a binary search.
- Specified by:
getModelIndex
in interfaceRowObjectFilterModel<ROW_OBJECT>
- Parameters:
t
- the item- Returns:
- the model index
-
getViewIndex
public int getViewIndex(ROW_OBJECT t)
Description copied from interface:RowObjectFilterModel
Returns the view index of the given item. When filtered, this is the index is the smaller, visible set of data; when unfiltered, this index is the same as that returned byRowObjectFilterModel.getModelIndex(Object)
.This operation will be O(n) unless the implementation is sorted, in which case the operation is O(log n), as it uses a binary search.
- Specified by:
getViewIndex
in interfaceRowObjectFilterModel<ROW_OBJECT>
- Parameters:
t
- the item- Returns:
- the view index
-
getRowIndex
public int getRowIndex(ROW_OBJECT t)
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 interfaceRowObjectTableModel<ROW_OBJECT>
- Parameters:
t
- the object- Returns:
- the row number
-
getRowObject
public ROW_OBJECT getRowObject(int viewRow)
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 interfaceRowObjectTableModel<ROW_OBJECT>
- Parameters:
viewRow
- the row for which to return a row object.- Returns:
- the row object
-
getColumnValueForRow
public java.lang.Object getColumnValueForRow(ROW_OBJECT t, int columnIndex)
Description copied from interface:RowObjectTableModel
Implementors are expected to return a value at the given column index for the specified row object. This is essentially a more specific version of theTableModel.getValueAt(int, int)
that allows this class's comparator objects to work.- Specified by:
getColumnValueForRow
in interfaceRowObjectTableModel<ROW_OBJECT>
- Parameters:
t
- The object that represents a given row.columnIndex
- The column index for which a value is requested.- Returns:
- a value at the given column index for the specified row object.
-
getValueAt
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
- Specified by:
getValueAt
in interfacejavax.swing.table.TableModel
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)
- Specified by:
isCellEditable
in interfacejavax.swing.table.TableModel
-
setValueAt
public void setValueAt(java.lang.Object value, int rowIndex, int columnIndex)
- Specified by:
setValueAt
in interfacejavax.swing.table.TableModel
-
getWrappedModel
public javax.swing.table.TableModel getWrappedModel()
-
-