public class TTableModel extends AbstractPageTableModel implements java.beans.PropertyChangeListener
In TWaver framework, we recommend you use TElementTable
and TDataBox
to manage your network data in your
OSS application. In this way, you don't need to face this
table model, the only thing you need to do is operate and
manage data box. The table model will automatically driven
by the connected data box.
Please see TElementTable
for more information.
Modifier and Type | Field and Description |
---|---|
protected TTableColumn |
checkColumn |
protected static TTableColumn |
currentSortColumn |
protected static int |
currentSortColumnIndex |
protected boolean |
isAdjusting |
protected boolean |
isEditable |
protected boolean |
isInitingColumn |
protected boolean |
locked |
protected TTableColumn |
oidColumn |
protected java.util.List |
publishedColumn |
protected java.util.Map |
publishedColumnMap |
protected java.util.Vector |
publishedData |
protected java.util.List |
rawColumn |
protected java.util.Map |
rawColumnIndexMap |
protected java.util.Map |
rawColumnMap |
protected java.util.Vector |
rawData |
protected static java.util.Comparator |
ROWDATA_COMPARATOR
row data comparator
|
protected java.util.List |
rowFilters |
protected java.util.List |
selectedRows |
static int |
SORT_ASCENDING
Indicate ascending column sorting
|
static int |
SORT_DESCENDING
Indicate descending column sorting
|
static int |
SORT_NONE
Indicate no column sorting
|
protected java.util.List |
sortColumnList |
protected TTable |
table |
protected java.util.List |
tableListeners |
currentPageIndex, pageRowSize, pageTotalCount
Modifier | Constructor and Description |
---|---|
protected |
TTableModel(TTable table)
Create table model
|
Modifier and Type | Method and Description |
---|---|
void |
addColumn(javax.swing.table.TableColumn column)
Add a table column into table model.
|
void |
addColumns(java.util.List columnList)
Add a list of columns to this table.
|
void |
addRow(java.util.Vector rowData)
Adds a row to the table model.
|
void |
addRowFilter(TTableRowFilter rowFilter)
Add a table row filter on this table.
|
void |
addTableListener(TTableListener l)
Add a new table listener into this model
|
void |
checkCurrentPageRows()
Check all table rows on current page.
|
void |
checkPublishedRows()
Check all published table rows.
|
void |
checkSelectedRows()
Check all selected table rows.
|
void |
clearAllColumns()
clear all custom table columns
|
void |
clearPublishedData()
Clear all published data
|
void |
clearRawData()
Clear all raw data
|
protected void |
createPredefindedColumn()
create predefined column
|
protected void |
fireCellUpdate(java.util.Vector rowData,
int columnIndex,
java.lang.Object oldValue,
java.lang.Object newValue)
Fire a cell update event.
|
protected void |
fireColumnAdded(TTableColumn tableColumn)
Fire column added event.
|
protected void |
fireColumnRemoved(TTableColumn tableColumn)
Fire column removed event.
|
protected void |
fireColumnSorted(TTableColumn tableColumn,
boolean multiColumnSort)
Fire column sorted event.
|
protected void |
fireLockedChanged()
Fire table lock state change event.
|
void |
fireRowClicked(int clickCount,
int rowIndex,
int columnIndex)
Fire table row has been clicked event to all table model listeners.
|
protected void |
fireRowDataAdded(java.util.Vector rowData)
fire row data added event.
|
protected void |
fireRowDataRemoved(java.util.Vector rowData)
Fire row data removed event.
|
protected void |
fireRowSelectionChanged(boolean isSelectionAdjusting)
Fire row select change event.
|
protected void |
fireTableDataCleared()
Fire table data cleared event.
|
java.util.Vector |
getAllCheckedRowData()
Get all checked row data which has been check by checkbox of each row.
|
TTableColumn |
getCheckColumn()
Get the internal checkbox column
|
TTableColumn |
getColumnByName(java.lang.String name)
Get table column by the a column name.
|
int |
getColumnCount()
Gets published column count
|
java.lang.String |
getColumnName(int columnIndex)
Gets column name of specified columnIndex
|
protected int |
getCurrentOID()
Get the current OID.
|
java.util.Vector |
getCurrentPageData()
Get current page data.
|
protected java.lang.Integer |
getNextOID()
Create the next OID object.
|
TTableColumn |
getOIDColumn()
Get internal OID column.
|
int |
getPageIndex(java.util.Vector rowData)
Get which published page it located for a raw table row.
|
java.util.List |
getPublishedColumn()
Get all published columns.
|
TTableColumn |
getPublishedColumn(int columnIndex)
Get published column by column index.
|
java.util.Vector |
getPublishedData()
Get the published table data.
|
java.util.List |
getRawColumn()
Get all raw columns.
|
int |
getRawColumnIndexByName(java.lang.String columnName)
Get raw column index by column name.
|
java.util.Vector |
getRawData()
Get the table raw data.
|
int |
getRowCount()
Gets current page row count
|
int |
getRowIndex(java.util.Vector rowData)
Get table row index via row data from the whole published data.
|
int |
getRowIndexAtPage(java.util.Vector rowData)
Get table row index via row data from current page.
|
java.util.List |
getSelectedRows()
Get all selected table rows in a list.
|
java.util.List |
getSortColumnList()
Get all sorted columns with a list.
|
TTable |
getTable()
Get the bound table.
|
int |
getTotalRowCount()
Get published row count.
|
java.lang.Object |
getValueAt(int rowIndex,
int columnIndex)
Returns the value for the cell at
columnIndex and
rowIndex . |
protected void |
initColumnIndexMap()
initialize column index map
|
void |
insertRow(int row,
java.util.Vector rowData)
Inserts a row at
row in the model. |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Checks whether or not the cell at
columnIndex and
rowIndex is editable. |
boolean |
isEditable()
Whether table is cell editable.
|
boolean |
isInitingColumn()
Check whether the column is now during the initializing time.
|
boolean |
isLocked()
Returns true if the table model is locked, false if not locked.
|
protected boolean |
isVisible(java.util.Vector rowData)
Check whether row is visible.
|
void |
lock()
Call this method to lock table model.
|
void |
propertyChange(java.beans.PropertyChangeEvent evt)
table column property change process
|
protected void |
publishColumn()
Publish column
|
void |
publishData()
Call this method to publish data from raw data layer.
|
void |
removeCheckedRows()
Delete all checked table rows from table.
|
void |
removeColumn(javax.swing.table.TableColumn column)
Remove a table column from this table.
|
void |
removeColumnByName(java.lang.String columnName)
Remove a table column by column name.
|
void |
removeRow(int row)
Removes the row with the specified row index.
|
void |
removeRow(java.util.Vector rowData)
Removes the row with the specified row data
|
void |
removeRowByOID(java.lang.Integer oid)
Removes the row with the specified row OID
|
void |
removeRowFilter(TTableRowFilter rowFilter)
Remove a table row filter from this table.
|
void |
removeRowsByOID(java.util.List oidList)
Remove rows by a list of row OIDs.
|
void |
removeSelectedRows()
Delete all selected table rows from table.
|
void |
removeTableListener(TTableListener l)
Remove a table listener from this model.
|
void |
reset()
Resets the whole table.
|
protected void |
resetPublishedDataMap() |
void |
setEditable(boolean isEditable)
Set whether this table is cell editable.
|
void |
setSelectedRows(java.util.List newSelectedRows)
Set selected rows.
|
void |
setTableRawData(java.util.Vector data)
Set table raw data.
|
void |
setValueAt(java.lang.Object value,
int rowIndex,
int columnIndex)
Sets the object value for the cell at
columnIndex and
rowIndex . |
void |
sortColumn(int columnIndex,
boolean multiColumnSort)
Sorts column.
|
void |
sortColumn(java.lang.String columnName,
int sortMode)
Sorts column by column name
|
void |
sortColumn(java.lang.String columnName,
int sortMode,
boolean multiColumnSort)
Sort column.
|
void |
sortColumn(TTableColumn sortedColumn,
int sortMode,
boolean multiColumnSort)
Sort column.
|
void |
sortNoneColumn()
Calls this method to cancel columns sorting.
|
void |
uncheckCurrentPageRows()
Uncheck all table rows on current table page.
|
void |
uncheckPublishedRows()
Uncheck all published rows.
|
void |
unlock()
Call this method to unlock table model.
|
void |
unlockAndPublish()
Unlock and publish data.
|
protected void |
updateSelectedRows()
update selected rows.
|
addPageListener, firePageChanged, firstPage, getCurrentPageIndex, getFirstRowIndex, getLastRowIndex, getPageRowSize, getPageTotalCount, lastPage, nextPage, previousPage, removePageListener, setCurrentPageIndex, setPageRowSize, update
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
public static final int SORT_NONE
public static final int SORT_ASCENDING
public static final int SORT_DESCENDING
protected static int currentSortColumnIndex
protected static TTableColumn currentSortColumn
protected boolean isEditable
protected boolean locked
protected boolean isAdjusting
protected boolean isInitingColumn
protected java.util.List selectedRows
protected java.util.List tableListeners
protected TTable table
protected java.util.Vector rawData
protected java.util.Vector publishedData
protected java.util.List rawColumn
protected java.util.List publishedColumn
protected java.util.Map publishedColumnMap
protected java.util.List rowFilters
protected java.util.List sortColumnList
protected java.util.Map rawColumnIndexMap
protected TTableColumn oidColumn
protected TTableColumn checkColumn
protected java.util.Map rawColumnMap
protected static final java.util.Comparator ROWDATA_COMPARATOR
protected TTableModel(TTable table)
table
- TTable connected table.public void addTableListener(TTableListener l)
l
- TTableListener the listener to be addedremoveTableListener(twaver.table.TTableListener)
public void removeTableListener(TTableListener l)
l
- TTableListener the listener to be removedaddTableListener(twaver.table.TTableListener)
protected void createPredefindedColumn()
protected void initColumnIndexMap()
protected void fireCellUpdate(java.util.Vector rowData, int columnIndex, java.lang.Object oldValue, java.lang.Object newValue)
rowData
- VectorcolumnIndex
- intoldValue
- ObjectnewValue
- Objectprotected void fireRowDataAdded(java.util.Vector rowData)
rowData
- Vectorprotected void fireRowDataRemoved(java.util.Vector rowData)
rowData
- Vectorprotected void fireColumnRemoved(TTableColumn tableColumn)
tableColumn
- TTableColumnprotected void fireColumnSorted(TTableColumn tableColumn, boolean multiColumnSort)
tableColumn
- TTableColumnprotected void fireColumnAdded(TTableColumn tableColumn)
tableColumn
- TTableColumnprotected void fireTableDataCleared()
protected void fireLockedChanged()
public void fireRowClicked(int clickCount, int rowIndex, int columnIndex)
clickCount
- int mouse click count.rowIndex
- int clicked row indexcolumnIndex
- int clicked column indexprotected void fireRowSelectionChanged(boolean isSelectionAdjusting)
isSelectionAdjusting
- booleanpublic int getColumnCount()
getColumnCount
in interface javax.swing.table.TableModel
public int getRowCount()
getRowCount
in interface javax.swing.table.TableModel
public java.lang.String getColumnName(int columnIndex)
getColumnName
in interface javax.swing.table.TableModel
getColumnName
in class javax.swing.table.AbstractTableModel
columnIndex
- int column indexpublic boolean isCellEditable(int rowIndex, int columnIndex)
columnIndex
and
rowIndex
is editable.isCellEditable
in interface javax.swing.table.TableModel
isCellEditable
in class javax.swing.table.AbstractTableModel
public void setValueAt(java.lang.Object value, int rowIndex, int columnIndex)
columnIndex
and
rowIndex
. value
is the new value. This method
will generate a tableChanged
notification.setValueAt
in interface javax.swing.table.TableModel
setValueAt
in class javax.swing.table.AbstractTableModel
value
- the new value; this can be nullrowIndex
- the row whose value is to be changedcolumnIndex
- the column whose value is to be changedpublic java.lang.Object getValueAt(int rowIndex, int columnIndex)
columnIndex
and
rowIndex
.getValueAt
in interface javax.swing.table.TableModel
rowIndex
- the row whose value is to be queriedcolumnIndex
- the column whose value is to be queriedprotected void publishColumn()
public void sortColumn(java.lang.String columnName, int sortMode)
columnName
- String column name to be sortedsortMode
- int the sort mode.
Legal values are:
public void sortColumn(java.lang.String columnName, int sortMode, boolean multiColumnSort)
columnName
- String column name to be sortedsortMode
- int sort mode.
Legal values are:
multiColumnSort
- boolean true if enable multi columns sort,
false otherwisepublic void sortColumn(TTableColumn sortedColumn, int sortMode, boolean multiColumnSort)
sortedColumn
- TTableColumn column to be sortedsortMode
- int sort mode.
Legal values are:
multiColumnSort
- boolean true if multi columns sort enabled,
false otherwise.public void sortNoneColumn()
public void sortColumn(int columnIndex, boolean multiColumnSort)
columnIndex
- the column index to be sortmultiColumnSort
- boolean true if multi column sort
enabled, false otherwise.public void publishData()
protected void resetPublishedDataMap()
public int getRowIndex(java.util.Vector rowData)
rowData
- the row data.public int getRowIndexAtPage(java.util.Vector rowData)
rowData
- Vector the table row data.getRowIndex(java.util.Vector)
public int getPageIndex(java.util.Vector rowData)
rowData
- Vector a table row dataprotected void updateSelectedRows()
public void setSelectedRows(java.util.List newSelectedRows)
newSelectedRows
- List a list contained all new selected rows.protected boolean isVisible(java.util.Vector rowData)
rowData
- Vector a table rowpublic java.util.Vector getAllCheckedRowData()
public int getTotalRowCount()
getTotalRowCount
in interface TablePaging
#getPublishedRowCount
public void addRowFilter(TTableRowFilter rowFilter)
rowFilter
- TTableRowFilter the table row filter to be addedremoveRowFilter(twaver.table.TTableRowFilter)
public void removeRowFilter(TTableRowFilter rowFilter)
rowFilter
- TTableRowFilter the table filter to be removed.addRowFilter(twaver.table.TTableRowFilter)
public void clearRawData()
public void clearPublishedData()
public void setTableRawData(java.util.Vector data)
data
- Vector the new table raw data. This
is a vector contains row data vectorspublic void addRow(java.util.Vector rowData)
rowData
- Vector row data to be addedinsertRow(int, java.util.Vector)
public void insertRow(int row, java.util.Vector rowData)
row
in the model.
Notification of the rowData will be inserted two
new element in front, the first one is inner id,
the other one is for checked state of the row.row
- int row index to be insert before itrowData
- the row data to be insert.addRow(java.util.Vector)
public void removeRow(int row)
row
- int the row index to be removed.addRow(java.util.Vector)
public void removeRow(java.util.Vector rowData)
rowData
- Vector the row data to be removed.addRow(java.util.Vector)
public void removeRowByOID(java.lang.Integer oid)
row
- Integer the row OID to be removedaddRow(java.util.Vector)
,
removeRow(int)
public void removeRowsByOID(java.util.List oidList)
oidList
- List a list contains a set of row OIDs.removeRow(int)
public void removeCheckedRows()
public void removeSelectedRows()
public void checkPublishedRows()
public java.util.Vector getCurrentPageData()
public void checkCurrentPageRows()
public void checkSelectedRows()
public void uncheckPublishedRows()
public void uncheckCurrentPageRows()
public TTableColumn getPublishedColumn(int columnIndex)
columnIndex
- int column indexpublic void reset()
public java.util.Vector getPublishedData()
public java.util.Vector getRawData()
public boolean isLocked()
public void lock()
public void unlock()
public void unlockAndPublish()
unlock()
,
publishData()
public java.util.List getSelectedRows()
public void addColumn(javax.swing.table.TableColumn column)
column
- TableColumn the column to be addedremoveColumn(javax.swing.table.TableColumn)
public void removeColumn(javax.swing.table.TableColumn column)
column
- TableColumn the column to be removed.addColumn(javax.swing.table.TableColumn)
public void removeColumnByName(java.lang.String columnName)
columnName
- String the column name to be removedremoveColumn(javax.swing.table.TableColumn)
public void clearAllColumns()
public void addColumns(java.util.List columnList)
columnList
- List a list contains all columns to be addedpublic boolean isInitingColumn()
public java.util.List getRawColumn()
getPublishedColumn(int)
public java.util.List getPublishedColumn()
getRawColumn()
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange
in interface java.beans.PropertyChangeListener
public TTableColumn getColumnByName(java.lang.String name)
name
- String a column namepublic int getRawColumnIndexByName(java.lang.String columnName)
columnName
- String column namepublic TTableColumn getOIDColumn()
public TTableColumn getCheckColumn()
public boolean isEditable()
setEditable(boolean)
public void setEditable(boolean isEditable)
isEditable
- boolean true if cell is editable, false otherwise.isEditable
public java.util.List getSortColumnList()
public TTable getTable()
protected java.lang.Integer getNextOID()
protected int getCurrentOID()
Copyright © 2002 - 2010 Serva Software. All Rights Reserved.