Package adams.gui.core
Class KeyValuePairTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- adams.gui.core.AbstractBaseTableModel
-
- adams.gui.core.KeyValuePairTableModel
-
- All Implemented Interfaces:
LoggingLevelHandler,LoggingSupporter,SpreadSheetSupporter,CustomSearchTableModel,Serializable,TableModel
- Direct Known Subclasses:
MapTableModel,PropertiesTableModel
public class KeyValuePairTableModel extends AbstractBaseTableModel implements CustomSearchTableModel
The model for displaying key-value pairs. It is assumed that the key is always a string.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String[]m_ColumnNamesthe names of the columns.protected Object[][]m_Datathe data to display.protected booleanm_Editablewhether the values can be edited.protected booleanm_Modifiedwhether the values were modified.-
Fields inherited from class adams.gui.core.AbstractBaseTableModel
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description KeyValuePairTableModel(Object[][] data)Initializes the table model.KeyValuePairTableModel(Object[][] data, String[] colNames)Initializes the table model with custom column names.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassgetColumnClass(int column)Returns the class for the column.intgetColumnCount()Returns the number of columns in the table.StringgetColumnName(int column)Returns the name of the column.StringgetKeyAt(int row)Returns the key at the given position.intgetRowCount()Returns the number of rows.ObjectgetValueAt(int row)Returns the value at the given position.ObjectgetValueAt(int row, int column)Returns the value at the given position.booleanisCellEditable(int rowIndex, int columnIndex)Returns whether the values are editable.booleanisEditable()Returns whether the values are editable or not.booleanisModified()Returns whether the values were modified.booleanisSearchMatch(SearchParameters params, int row)Tests whether the search matches the specified row.voidsetEditable(boolean value)Sets whether the values will be editable or not.voidsetModified(boolean value)Sets whether the values will were modified.voidsetValueAt(Object aValue, int rowIndex, int columnIndex)Updates the value.-
Methods inherited from class adams.gui.core.AbstractBaseTableModel
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, setLoggingLevel, toSpreadSheet, toString
-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, removeTableModelListener
-
-
-
-
Constructor Detail
-
KeyValuePairTableModel
public KeyValuePairTableModel(Object[][] data)
Initializes the table model. The key is always assumed to be of type string.- Parameters:
data- the key-value pairs to display
-
-
Method Detail
-
setEditable
public void setEditable(boolean value)
Sets whether the values will be editable or not.- Parameters:
value- if true the values will be editable
-
isEditable
public boolean isEditable()
Returns whether the values are editable or not.- Returns:
- true if the value are editable
-
setModified
public void setModified(boolean value)
Sets whether the values will were modified.- Parameters:
value- if true the values were modified
-
isModified
public boolean isModified()
Returns whether the values were modified.- Returns:
- true if the values were modified
-
getRowCount
public int getRowCount()
Returns the number of rows.- Specified by:
getRowCountin interfaceTableModel- Returns:
- the number of rows
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the table.- Specified by:
getColumnCountin interfaceTableModel- Returns:
- always 2
-
getColumnName
public String getColumnName(int column)
Returns the name of the column.- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel- Parameters:
column- the column to retrieve the name for- Returns:
- the name of the column
-
getValueAt
public Object getValueAt(int row, int column)
Returns the value at the given position. Multi-line content gets shortened.- Specified by:
getValueAtin interfaceTableModel- Parameters:
row- the row in the tablecolumn- the column in the table- Returns:
- the value
- See Also:
getValueAt(int, int)
-
getKeyAt
public String getKeyAt(int row)
Returns the key at the given position.- Parameters:
row- the row in the table- Returns:
- the key
-
getValueAt
public Object getValueAt(int row)
Returns the value at the given position.- Parameters:
row- the row in the table- Returns:
- the value
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)Returns whether the values are editable.- Specified by:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein classAbstractTableModel- Parameters:
rowIndex- the row being queriedcolumnIndex- the column being queried- Returns:
- true if editable
-
setValueAt
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
Updates the value.- Specified by:
setValueAtin interfaceTableModel- Overrides:
setValueAtin classAbstractTableModel- Parameters:
aValue- value to assign to cellrowIndex- row of cellcolumnIndex- column of cell
-
getColumnClass
public Class getColumnClass(int column)
Returns the class for the column.- Specified by:
getColumnClassin interfaceTableModel- Overrides:
getColumnClassin classAbstractTableModel- Parameters:
column- the column to retrieve the class for- Returns:
- the class
-
isSearchMatch
public boolean isSearchMatch(SearchParameters params, int row)
Tests whether the search matches the specified row.- Specified by:
isSearchMatchin interfaceCustomSearchTableModel- Parameters:
params- the search parametersrow- the row of the underlying, unsorted model- Returns:
- true if the search matches this row
-
-