public abstract class MidicaTableModel
extends javax.swing.table.DefaultTableModel
This class represents the data model of most tables used in this project.
It supports a headline for each column. However the number and content of the columns and headlines has to be specified in the derived class.
This class also supports tooltip texts for table headers. By default, the column name is also used as the tooltip text. However the tooltips can be customized by the derived class by calling setHeaderToolTip(int, String)
.
Modifier and Type | Field and Description |
---|---|
protected java.lang.Class<?>[] |
columnClasses |
protected java.lang.String[] |
columnNames |
private java.util.TreeMap<java.lang.Integer,java.lang.String> |
headerTooltips |
private static long |
serialVersionUID |
protected java.lang.Boolean[] |
sortableColumns |
Modifier | Constructor and Description |
---|---|
protected |
MidicaTableModel()
Creates a new table model.
|
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<java.util.HashMap<java.lang.String,?>> |
getCategorizedHashMapRows()
Returns null, if not overridden by a child model class.
|
java.util.ArrayList<CategorizedElement> |
getCategorizedRows()
Returns null, if not overridden by a child model class.
|
java.lang.Class<?> |
getColumnClass(int colIndex)
Returns the class of the column’s content.
|
int |
getColumnCount()
Returns the number of columns in the table.
|
java.lang.String |
getColumnName(int index)
Returns the column name according to the given index.
|
java.lang.String |
getHeaderTooltip(int col)
Returns the tooltip text of the specified column index.
|
abstract int |
getRowCount()
Returns the number of table rows.
|
abstract java.lang.Object |
getValueAt(int rowIndex,
int colIndex)
Returns the value of the queried table cell.
|
boolean |
isCellEditable(int row,
int col)
Returns always false because none of the table cells is editable.
|
boolean |
isSortable(int colIndex)
Indicates if the given column is sortable or not.
|
protected void |
setHeaderToolTip(int col,
java.lang.String tooltip)
Sets the tooltip text of the given column index.
|
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getDataVector, insertRow, insertRow, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount, setValueAt
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
private static final long serialVersionUID
protected java.lang.String[] columnNames
protected java.lang.Class<?>[] columnClasses
protected java.lang.Boolean[] sortableColumns
private java.util.TreeMap<java.lang.Integer,java.lang.String> headerTooltips
public java.lang.String getColumnName(int index)
Returns the column name according to the given index. All column names should be initialized in the constructor of the derived class.
getColumnName
in interface javax.swing.table.TableModel
getColumnName
in class javax.swing.table.DefaultTableModel
index
- Table column index.public java.lang.String getHeaderTooltip(int col)
Returns the tooltip text of the specified column index.
If there have not been set any custom tooltip using setHeaderToolTip(int, String)
, the colum name is returned.
col
- The column index, beginning with 0.protected void setHeaderToolTip(int col, java.lang.String tooltip)
Sets the tooltip text of the given column index.
col
- The column index, beginning with 0.tooltip
- The tooltip text to be set.public int getColumnCount()
Returns the number of columns in the table. Same as the column names initialized by the constructor of the derived class.
getColumnCount
in interface javax.swing.table.TableModel
getColumnCount
in class javax.swing.table.DefaultTableModel
public boolean isCellEditable(int row, int col)
Returns always false because none of the table cells is editable.
isCellEditable
in interface javax.swing.table.TableModel
isCellEditable
in class javax.swing.table.DefaultTableModel
row
- Queried row index.col
- Queried column index.public abstract int getRowCount()
Returns the number of table rows.
getRowCount
in interface javax.swing.table.TableModel
getRowCount
in class javax.swing.table.DefaultTableModel
public abstract java.lang.Object getValueAt(int rowIndex, int colIndex)
Returns the value of the queried table cell.
getValueAt
in interface javax.swing.table.TableModel
getValueAt
in class javax.swing.table.DefaultTableModel
rowIndex
- Row index.colIndex
- Column index.public java.lang.Class<?> getColumnClass(int colIndex)
Returns the class of the column’s content. Used for sorting.
getColumnClass
in interface javax.swing.table.TableModel
getColumnClass
in class javax.swing.table.AbstractTableModel
colIndex
- Column index.public boolean isSortable(int colIndex)
Indicates if the given column is sortable or not. By default all columns are sortable. This can be changed if the field sortableColumns is changed by a derived model class.
colIndex
- Column index.public java.util.ArrayList<CategorizedElement> getCategorizedRows()
Returns null, if not overridden by a child model class. Can be overridden to return the underlying data list, if it contains categorized data. That’s needed for the sorter to be able to hide categories, if the sorting is different from the model’s default sorting.
public java.util.ArrayList<java.util.HashMap<java.lang.String,?>> getCategorizedHashMapRows()
Returns null, if not overridden by a child model class. Can be overridden to return the underlying data list, if it contains categorized data. That’s needed for the sorter to be able to hide categories, if the sorting is different from the model’s default sorting.