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 booleanm_DisplayUserOnlywhether to display user-only vars.protected List<String>m_Namesthe sorted list of var names.protected List<String>m_NamesUserOnlythe sorted list of user-only var names.protected Set<String>m_ProgrammaticVarsprogrammatic variables.protected Map<String,String>m_Valuesthe name - actual value relation.protected Variablesm_Variablesthe 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 voidadd(String name, String value)Adds the variable (name-value pair) to the model.Class<?>getColumnClass(int columnIndex)Returns the class of the column.intgetColumnCount()Returns the number of columns in the model.StringgetColumnName(int column)Returns the name of the column.booleangetDisplayUserOnly()Returns whether only user variables are displayed without the programmatic ones.intgetRowCount()Returns the number of rows in the model.ObjectgetValueAt(int rowIndex, int columnIndex)Returns the cell value.protected StringgetVariableNameAt(int rowIndex)Returns the name at the specified row.VariablesgetVariables()Returns the underlying Variables instance.protected voidinitialize()Initializes the model.booleanisCellEditable(int rowIndex, int columnIndex)Checks whether the cell is editable.voidremove(int rowIndex)Removes the variable at the position.voidsetDisplayUserOnly(boolean value)Sets whether only user variables are displayed without the programmatic ones.voidsetValueAt(Object value, int rowIndex, int columnIndex)Sets the value at the specified position.voidvariableChanged(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:
getColumnCountin interfaceTableModel- Returns:
- always 2
-
getRowCount
public int getRowCount()
Returns the number of rows in the model.- Specified by:
getRowCountin interfaceTableModel- Returns:
- the number of variables
-
getColumnClass
public Class<?> getColumnClass(int columnIndex)
Returns the class of the column.- Specified by:
getColumnClassin interfaceTableModel- Overrides:
getColumnClassin 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:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein 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:
getValueAtin 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:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein 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:
setValueAtin interfaceTableModel- Overrides:
setValueAtin 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:
variableChangedin interfaceVariableChangeListener- Parameters:
e- the event
-
-