Package adams.gui.tools
Class VariableManagementPanel.VariableTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- adams.gui.core.AbstractBaseTableModel
-
- adams.gui.tools.VariableManagementPanel.VariableTableModel
-
- All Implemented Interfaces:
LoggingLevelHandler
,LoggingSupporter
,SpreadSheetSupporter
,VariableChangeListener
,Serializable
,TableModel
- Enclosing class:
- VariableManagementPanel
public static class VariableManagementPanel.VariableTableModel extends AbstractBaseTableModel implements VariableChangeListener
Specialized table model for the variables.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_DisplayUserOnly
whether to display user-only vars.protected List<String>
m_Names
the sorted list of var names.protected List<String>
m_NamesUserOnly
the sorted list of user-only var names.protected Set<String>
m_ProgrammaticVars
programmatic variables.protected Map<String,String>
m_Values
the name - actual value relation.protected Variables
m_Variables
the underlying variables instance.-
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 VariableTableModel(Variables variables)
Initializes the model with the global variables.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(String name, String value)
Adds the variable (name-value pair) to the model.Class<?>
getColumnClass(int columnIndex)
Returns the class of the column.int
getColumnCount()
Returns the number of columns in the model.String
getColumnName(int column)
Returns the name of the column.boolean
getDisplayUserOnly()
Returns whether only user variables are displayed without the programmatic ones.int
getRowCount()
Returns the number of rows in the model.Object
getValueAt(int rowIndex, int columnIndex)
Returns the cell value.protected String
getVariableNameAt(int rowIndex)
Returns the name at the specified row.Variables
getVariables()
Returns the underlying Variables instance.protected void
initialize()
Initializes the model.boolean
isCellEditable(int rowIndex, int columnIndex)
Checks whether the cell is editable.void
remove(int rowIndex)
Removes the variable at the position.void
setDisplayUserOnly(boolean value)
Sets whether only user variables are displayed without the programmatic ones.void
setValueAt(Object value, int rowIndex, int columnIndex)
Sets the value at the specified position.void
variableChanged(VariableChangeEvent e)
Gets triggered when a variable changed (added, modified, removed).-
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
-
-
-
-
Field Detail
-
m_Variables
protected Variables m_Variables
the underlying variables instance.
-
m_DisplayUserOnly
protected boolean m_DisplayUserOnly
whether to display user-only vars.
-
-
Constructor Detail
-
VariableTableModel
public VariableTableModel(Variables variables)
Initializes the model with the global variables.- Parameters:
variables
- the Variables instance to use
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the model.
-
getVariables
public Variables getVariables()
Returns the underlying Variables instance.- Returns:
- the variables
-
setDisplayUserOnly
public void setDisplayUserOnly(boolean value)
Sets whether only user variables are displayed without the programmatic ones.- Parameters:
value
- true if user-only
-
getDisplayUserOnly
public boolean getDisplayUserOnly()
Returns whether only user variables are displayed without the programmatic ones.- Returns:
- true if user-only
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the model.- Specified by:
getColumnCount
in interfaceTableModel
- Returns:
- always 2
-
getRowCount
public int getRowCount()
Returns the number of rows in the model.- Specified by:
getRowCount
in interfaceTableModel
- Returns:
- the number of variables
-
getColumnClass
public Class<?> getColumnClass(int columnIndex)
Returns the class of the column.- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
- Parameters:
columnIndex
- the index of the column- Returns:
- the class of the column
-
getColumnName
public String getColumnName(int column)
Returns the name of the column.- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
- Parameters:
column
- the index of the column- Returns:
- the name
-
getVariableNameAt
protected String getVariableNameAt(int rowIndex)
Returns the name at the specified row.- Parameters:
rowIndex
- the row to get the variable name for- Returns:
- the name
-
getValueAt
public Object getValueAt(int rowIndex, int columnIndex)
Returns the cell value.- Specified by:
getValueAt
in interfaceTableModel
- Parameters:
rowIndex
- the row of the cellcolumnIndex
- the column of the cell- Returns:
- the value
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)
Checks whether the cell is editable.- Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
- Parameters:
rowIndex
- the row of the cellcolumnIndex
- the column of the cell- Returns:
- always true
-
setValueAt
public void setValueAt(Object value, int rowIndex, int columnIndex)
Sets the value at the specified position.- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classAbstractTableModel
- Parameters:
value
- the value to setrowIndex
- the row of the cellcolumnIndex
- the column of the cell
-
remove
public void remove(int rowIndex)
Removes the variable at the position.- Parameters:
rowIndex
- the row to remove
-
add
public void add(String name, String value)
Adds the variable (name-value pair) to the model.- Parameters:
name
- the name of the variablevalue
- the corresponding value
-
variableChanged
public void variableChanged(VariableChangeEvent e)
Gets triggered when a variable changed (added, modified, removed).- Specified by:
variableChanged
in interfaceVariableChangeListener
- Parameters:
e
- the event
-
-