public class VirtualTableModel extends AbstractTableModel implements VirtualTableListener, VirtualTableWrapper
XdevTable
s using a
VirtualTable
as the underlying data model.
Calls for retrieving or modifying data are delegated to the
VirtualTable
.
The number and order of columns of this Model and the VirtualTable
may differ. modelColumnIndices
is used to map the columns of
this Model to the columns of the VirtualTable
.
listenerList
Constructor and Description |
---|
VirtualTableModel(VirtualTable vt,
int[] columnIndices)
Initializes a new
VirtualTableModel . |
Modifier and Type | Method and Description |
---|---|
static Class |
getClassForType(DataType type)
Helper method for mapping
DataType s to Java classes. |
Class |
getColumnClass(int col)
Returns the class of the underlying
VirtualTableColumn . |
int |
getColumnCount()
Returns the number of columns of the model.
|
String |
getColumnName(int col)
Returns the column name using the caption of the underlying
VirtualTableColumn . |
int[] |
getModelColumnIndices()
Returns the array of column indexes of the model.
|
int |
getRowCount()
Returns the number of rows in the
VirtualTable . |
Object |
getValueAt(int row,
int col)
Returns a value from the
VirtualTable at the specified position. |
VirtualTable |
getVirtualTable()
Returns the wrapped
VirtualTable . |
VirtualTable.VirtualTableRow |
getVirtualTableRow(int modelRow)
Returns the wrapped
VirtualTable.VirtualTableRow behind the index
modelRow . |
VirtualTable |
getVT()
Returns the wrapped
VirtualTable . |
boolean |
isCellEditable(int row,
int col)
Returns, if a cell is editables.
|
void |
setValueAt(Object newValue,
int row,
int col)
Sets a value in the underlying
VirtualTable at the specified
position. |
int |
viewToModelColumn(int col)
Return the index of the wrapped
VirtualTable corresponding to
Parameter col . |
void |
virtualTableDataChanged(VirtualTableEvent event)
Notifies listeners that all cell values in the
VirtualTable may
have changed. |
void |
virtualTableRowDeleted(VirtualTableEvent event)
Notifies all listeners that a row in the
VirtualTable has been
deleted. |
void |
virtualTableRowInserted(VirtualTableEvent event)
Notifies all listeners that a row in the
VirtualTable has been
inserted. |
void |
virtualTableRowUpdated(VirtualTableEvent event)
Notifies all listeners that a row in the
VirtualTable has been
updated. |
void |
virtualTableStructureChanged(VirtualTableEvent event)
Notifies all listeners that the structure of the
VirtualTable has
been changed and updates the model column indices. |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
public VirtualTableModel(VirtualTable vt, int[] columnIndices)
VirtualTableModel
.vt
- the VirtualTable
to usecolumnIndices
- an int
array of column indices of the model. The
values of the array contain the indexes of the
VirtualTable
.public VirtualTable getVT()
VirtualTable
.VirtualTable
public int[] getModelColumnIndices()
getModelColumnIndices
in interface VirtualTableWrapper
int
array of indexedpublic Object getValueAt(int row, int col)
VirtualTable
at the specified position.getValueAt
in interface TableModel
row
- the row indexcol
- the model column index.public int getColumnCount()
getColumnCount
in interface TableModel
public int getRowCount()
VirtualTable
.getRowCount
in interface TableModel
getRowCount
in interface VirtualTableWrapper
public String getColumnName(int col)
VirtualTableColumn
.getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
col
- the model column index.public Class getColumnClass(int col)
VirtualTableColumn
.getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
col
- the model column index.DataType
of the columnpublic static Class getClassForType(DataType type)
DataType
s to Java classes.public void setValueAt(Object newValue, int row, int col)
VirtualTable
at the specified
position.setValueAt
in interface TableModel
setValueAt
in class AbstractTableModel
newValue
- the new value to be set.row
- the index of the row.col
- the model column index.public boolean isCellEditable(int row, int col)
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
row
- the index of the row.col
- the model column index.true
, the cell can be edited.public VirtualTable getVirtualTable()
VirtualTable
.getVirtualTable
in interface VirtualTableWrapper
VirtualTable
public int viewToModelColumn(int col)
VirtualTable
corresponding to
Parameter col
.viewToModelColumn
in interface VirtualTableWrapper
col
- the model column indexVirtualTable
public VirtualTable.VirtualTableRow getVirtualTableRow(int modelRow)
VirtualTable.VirtualTableRow
behind the index
modelRow
.getVirtualTableRow
in interface VirtualTableWrapper
modelRow
- the index in the modelVirtualTable.VirtualTableRow
public void virtualTableDataChanged(VirtualTableEvent event)
VirtualTable
may
have changed.virtualTableDataChanged
in interface VirtualTableListener
event
- a VirtualTableEvent
with detailed information.public void virtualTableRowDeleted(VirtualTableEvent event)
VirtualTable
has been
deleted.virtualTableRowDeleted
in interface VirtualTableListener
event
- a VirtualTableEvent
with detailed information.public void virtualTableRowInserted(VirtualTableEvent event)
VirtualTable
has been
inserted.virtualTableRowInserted
in interface VirtualTableListener
event
- a VirtualTableEvent
with detailed information.public void virtualTableRowUpdated(VirtualTableEvent event)
VirtualTable
has been
updated.virtualTableRowUpdated
in interface VirtualTableListener
event
- a VirtualTableEvent
with detailed information.public void virtualTableStructureChanged(VirtualTableEvent event)
VirtualTable
has
been changed and updates the model column indices.virtualTableStructureChanged
in interface VirtualTableListener
event
- a VirtualTableEvent
with detailed information.Copyright © 2003–2021 XDEV Software. All rights reserved.