public class MultiSelectionTableModelAdapter extends Object implements TableModel, ListSelectionListener
MultiSelectionInList
ValueModel to a
JTable TableModel and ListSelectionModel.ListTableMapper
.
Each entry in the list of the MultiSelectionInList
ValueModel describes a
row, all entries are assumed to be objects from the same class/interface.
Whenever the either the list or the selection changes, the table is
adjusted accordingly.
The table data is read-only, when the user changes the selection in the
table, the selection of the MultiSelectionInList
is changed accordingly.
The initial selection is taken from the MultiSelectionInList
value model.
FIXME: currently we never unregister from the MultiSelectionInList value model,
this might lead to memory leaks.
Modifier and Type | Field and Description |
---|---|
protected MultiSelectionInList |
mMultiSelectionInList
value model holding the list, never null
|
Constructor and Description |
---|
MultiSelectionTableModelAdapter(JTable pTable,
MultiSelectionInList pValueModel,
List<ListTableMapper.Mapping> pMapping,
boolean pSortable)
Create a new adaption object between a JTable and a
MultiSelectionInList value model. |
MultiSelectionTableModelAdapter(JTable pTable,
MultiSelectionInList pValueModel,
List<ListTableMapper.Mapping> pMapping,
boolean pSortable,
int pColumnForInitialSorting)
Create a new adaption object between a JTable and a
MultiSelectionInList value model. |
MultiSelectionTableModelAdapter(JTable pTable,
MultiSelectionInList pValueModel,
List<ListTableMapper.Mapping> pMapping,
boolean pSortable,
int pColumnForInitialSorting,
TableFilterPlugin pTableFilterPlugin)
Create a new adaption object between a JTable and a
MultiSelectionInList value model. |
Modifier and Type | Method and Description |
---|---|
void |
addTableModelListener(TableModelListener pTableModelListener) |
protected void |
fireTableChanged(TableModelEvent peEvent) |
Class<?> |
getColumnClass(int pColumnIndex) |
int |
getColumnCount() |
String |
getColumnName(int pColumnIndex) |
Object |
getRawValueAt(int pRowIndex,
int pColumnIndex) |
int |
getRowCount() |
TableFilterPlugin |
getTableFilterPlugin()
Getter for TableFilterPlugin
|
Object |
getValueAt(int pRowIndex,
int pColumnIndex) |
Object |
getValueForSortingAt(int pRowIndex,
int pColumnIndex) |
protected void |
init(JTable pTable,
MultiSelectionInList pValueModel)
Common construction stuff, it creates a new adaption between
a JTable and a
MultiSelectionInList value model. |
boolean |
isCellEditable(int pRowIndex,
int pColumnIndex) |
boolean |
isColumnSortable(int pColumnIndex) |
void |
removeTableModelListener(TableModelListener pTableModelListener) |
protected void |
setIndexConverter(IndexConverter pIndexConverter)
Setter for IndexConverter.
|
void |
setValueAt(Object pValue,
int pRowIndex,
int pColumnIndex) |
void |
valueChanged(ListSelectionEvent pEvent)
Called whenever the selection of the JTable changes, we update
our SelectionInList index.
|
void |
vmDataChanged(ChangeEvent pEvent)
Called whenever the data of the
MultiSelectionInList changes. |
void |
vmSelectionChanged(ChangeEvent pEvent)
Called whenever the selection of the SelectionInList changes.
|
protected MultiSelectionInList mMultiSelectionInList
public MultiSelectionTableModelAdapter(JTable pTable, MultiSelectionInList pValueModel, List<ListTableMapper.Mapping> pMapping, boolean pSortable)
MultiSelectionInList
value model.
This object is also set as the JTable's TableModel.pTable
- the table for which we provide TableModel behaviour and connect to the ListSelectionModel
pValueModel
- the value model that drives the table (data, selection)
and gets updated by the table (selection only)pMapping
- non-null List containing ListTableMapper.Mapping
objectspSortable
- true if table is sortableIllegalArgumentException
- if a parameter is boguspublic MultiSelectionTableModelAdapter(JTable pTable, MultiSelectionInList pValueModel, List<ListTableMapper.Mapping> pMapping, boolean pSortable, int pColumnForInitialSorting)
MultiSelectionInList
value model.
This object is also set as the JTable's TableModel.pTable
- the table for which we provide TableModel behaviour and connect to the ListSelectionModel
pValueModel
- the value model that drives the table (data, selection)
and gets updated by the table (selection only)pMapping
- non-null List containing ListTableMapper.Mapping
objectspSortable
- true if table is sortablepColumnForInitialSorting
- -1 or the column index for initial sortingIllegalArgumentException
- if a parameter is boguspublic MultiSelectionTableModelAdapter(JTable pTable, MultiSelectionInList pValueModel, List<ListTableMapper.Mapping> pMapping, boolean pSortable, int pColumnForInitialSorting, TableFilterPlugin pTableFilterPlugin)
MultiSelectionInList
value model.
This object is also set as the JTable's TableModel.pTable
- the table for which we provide TableModel behaviour and connect to the ListSelectionModel
pValueModel
- the value model that drives the table (data, selection)
and gets updated by the table (selection only)pMapping
- non-null List containing ListTableMapper.Mapping
objectspSortable
- true if table is sortablepColumnForInitialSorting
- -1 or the column index for initial sortingpTableFilterPlugin
- our table filter plugin, may be nullIllegalArgumentException
- if a parameter is boguspublic TableFilterPlugin getTableFilterPlugin()
protected void init(JTable pTable, MultiSelectionInList pValueModel)
MultiSelectionInList
value model.
This object is also set as the JTable's TableModel.pTable
- the table for which we provide TableModel behaviour and connect to the ListSelectionModel
pValueModel
- the value model that drives the table (data, selection)
and gets updated by the table (selection only)IllegalArgumentException
- if a parameter is boguspublic int getColumnCount()
getColumnCount
in interface TableModel
public String getColumnName(int pColumnIndex)
getColumnName
in interface TableModel
public Class<?> getColumnClass(int pColumnIndex)
getColumnClass
in interface TableModel
public Object getValueAt(int pRowIndex, int pColumnIndex)
getValueAt
in interface TableModel
public Object getRawValueAt(int pRowIndex, int pColumnIndex)
public Object getValueForSortingAt(int pRowIndex, int pColumnIndex)
public boolean isColumnSortable(int pColumnIndex)
protected void setIndexConverter(IndexConverter pIndexConverter)
pIndexConverter
- the new IndexConverter, must not be nullpublic void vmDataChanged(ChangeEvent pEvent)
MultiSelectionInList
changes.pEvent
- not usedpublic void vmSelectionChanged(ChangeEvent pEvent)
pEvent
- not usedpublic void valueChanged(ListSelectionEvent pEvent)
valueChanged
in interface ListSelectionListener
pEvent
- event describing the new selectionpublic int getRowCount()
getRowCount
in interface TableModel
public boolean isCellEditable(int pRowIndex, int pColumnIndex)
isCellEditable
in interface TableModel
public void setValueAt(Object pValue, int pRowIndex, int pColumnIndex)
setValueAt
in interface TableModel
public void addTableModelListener(TableModelListener pTableModelListener)
addTableModelListener
in interface TableModel
public void removeTableModelListener(TableModelListener pTableModelListener)
removeTableModelListener
in interface TableModel
protected void fireTableChanged(TableModelEvent peEvent)
Copyright © 2017 Jürgen Zeller (privat). All rights reserved.