Class ContainerModel<M extends AbstractContainerManager,C extends AbstractContainer>
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- adams.gui.core.AbstractBaseTableModel
-
- adams.gui.visualization.container.ContainerModel<M,C>
-
- Type Parameters:
M
- the type of container manager to useC
- the type of container that is used
- All Implemented Interfaces:
CleanUpHandler
,LoggingLevelHandler
,LoggingSupporter
,SpreadSheetSupporter
,DataChangeListener
,Serializable
,TableModel
- Direct Known Subclasses:
InstanceContainerModel
,ReportContainerModel
,SpreadSheetRowContainerModel
,TimeseriesContainerModel
,XYSequenceContainerModel
public class ContainerModel<M extends AbstractContainerManager,C extends AbstractContainer> extends AbstractBaseTableModel implements DataChangeListener, CleanUpHandler
A model for displaying the currently loaded containers.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractContainerTableColumnNameGenerator
m_ColumnNameGenerator
for the column names.protected boolean
m_DisplayDatabaseID
whether to display the database ID column or not (if possible).protected boolean
m_DisplayVisibility
whether to display the visibility column or not (if possible).protected AbstractContainerDisplayStringGenerator
m_Generator
for displaying the containers.protected M
m_Manager
the underlying data.-
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 ContainerModel()
Initializes the model.ContainerModel(ContainerListManager<M> manager)
Initializes the model.ContainerModel(M manager)
Initializes the model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanUp()
Cleans up data structures, frees up memory.void
dataChanged(DataChangeEvent e)
Gets called if the data of the manager noticed a changed.Class
getColumnClass(int columnIndex)
Returns the class of the column.int
getColumnCount()
Returns the number of columns.String
getColumnName(int column)
Returns the name of the column.AbstractContainerTableColumnNameGenerator
getColumnNameGenerator()
Returns the current generator for the column names.int
getColumnWidth(int columnIndex)
Returns the default width for the column.C
getContainerAt(int row)
Returns the container at the specified row.protected int
getDatabaseIDColumn()
Returns the column index of the database ID column.protected int
getDataColumn()
Returns the column index of the data column.boolean
getDisplayDatabaseID()
Returns whether the database ID column will be displayed where possible.AbstractContainerDisplayStringGenerator
getDisplayStringGenerator()
Returns the current display string generator.boolean
getDisplayVisibility()
Returns whether the visibility column will be displayed where possible.M
getManager()
Returns the underlying manager.int
getRowCount()
Returns the number of rows to display.Object
getValueAt(int rowIndex, int columnIndex)
Returns the value at the specified position.protected int
getVisibilityColumn()
Returns the column index of the visibility column.protected void
initialize()
Initializes the members.boolean
isCellEditable(int rowIndex, int columnIndex)
Returns whether a cell is editable or not.void
setColumnNameGenerator(AbstractContainerTableColumnNameGenerator value)
Sets the generator for the column names.void
setDisplayDatabaseID(boolean value)
Whether to display the database ID column (if possible).void
setDisplayStringGenerator(AbstractContainerDisplayStringGenerator value)
Sets the display string generator.void
setDisplayVisibility(boolean value)
Whether to display the visibility column (if possible).void
setValueAt(Object aValue, int rowIndex, int columnIndex)
Sets the value at the given position.protected boolean
showDatabaseIDColumn()
Returns whether the database ID column is to be displayed.protected boolean
showVisibilityColumn()
Returns whether the visibility column is to be displayed.void
unregister()
Unregisters this model as listener.-
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_Manager
protected M extends AbstractContainerManager m_Manager
the underlying data.
-
m_Generator
protected AbstractContainerDisplayStringGenerator m_Generator
for displaying the containers.
-
m_ColumnNameGenerator
protected AbstractContainerTableColumnNameGenerator m_ColumnNameGenerator
for the column names.
-
m_DisplayVisibility
protected boolean m_DisplayVisibility
whether to display the visibility column or not (if possible).
-
m_DisplayDatabaseID
protected boolean m_DisplayDatabaseID
whether to display the database ID column or not (if possible).
-
-
Constructor Detail
-
ContainerModel
public ContainerModel()
Initializes the model.
-
ContainerModel
public ContainerModel(ContainerListManager<M> manager)
Initializes the model.- Parameters:
manager
- the managing object to obtain the data from
-
ContainerModel
public ContainerModel(M manager)
Initializes the model.- Parameters:
manager
- the manager to obtain the data from
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.
-
getManager
public M getManager()
Returns the underlying manager.- Returns:
- the manager or null if not set (e.g., empty model)
-
unregister
public void unregister()
Unregisters this model as listener.
-
setDisplayStringGenerator
public void setDisplayStringGenerator(AbstractContainerDisplayStringGenerator value)
Sets the display string generator.- Parameters:
value
- the new generator
-
getDisplayStringGenerator
public AbstractContainerDisplayStringGenerator getDisplayStringGenerator()
Returns the current display string generator.- Returns:
- the generator
-
setColumnNameGenerator
public void setColumnNameGenerator(AbstractContainerTableColumnNameGenerator value)
Sets the generator for the column names.- Parameters:
value
- the new generator
-
getColumnNameGenerator
public AbstractContainerTableColumnNameGenerator getColumnNameGenerator()
Returns the current generator for the column names.- Returns:
- the generator
-
setDisplayVisibility
public void setDisplayVisibility(boolean value)
Whether to display the visibility column (if possible).- Parameters:
value
- if true then the column will be displayed where possible
-
getDisplayVisibility
public boolean getDisplayVisibility()
Returns whether the visibility column will be displayed where possible.- Returns:
- true if the column will be displayed where possible
-
setDisplayDatabaseID
public void setDisplayDatabaseID(boolean value)
Whether to display the database ID column (if possible).- Parameters:
value
- if true then the column will be displayed where possible
-
getDisplayDatabaseID
public boolean getDisplayDatabaseID()
Returns whether the database ID column will be displayed where possible.- Returns:
- true if the column will be displayed where possible
-
showVisibilityColumn
protected boolean showVisibilityColumn()
Returns whether the visibility column is to be displayed.- Returns:
- true if the column is to be displayed
-
showDatabaseIDColumn
protected boolean showDatabaseIDColumn()
Returns whether the database ID column is to be displayed.- Returns:
- true if the column is to be displayed
-
getColumnCount
public int getColumnCount()
Returns the number of columns.- Checkbox (if manager implements VisibilityContainerManager and m_DisplayVisibility is true) - Database ID (if manager implements DatabaseContainerManager and m_DisplayDatabaseID is true) - Display string
- Specified by:
getColumnCount
in interfaceTableModel
- Returns:
- the number of columns
- See Also:
m_DisplayVisibility
,m_DisplayDatabaseID
,VisibilityContainerManager
-
getVisibilityColumn
protected int getVisibilityColumn()
Returns the column index of the visibility column.- Returns:
- the column index, -1 if not available
-
getDatabaseIDColumn
protected int getDatabaseIDColumn()
Returns the column index of the database ID column.- Returns:
- the column index, -1 if not available
-
getDataColumn
protected int getDataColumn()
Returns the column index of the data column.- Returns:
- the column index, -1 if not available
-
getColumnWidth
public int getColumnWidth(int columnIndex)
Returns the default width for the column.- Parameters:
columnIndex
- the index of the column- Returns:
- the width
-
getRowCount
public int getRowCount()
Returns the number of rows to display.- Specified by:
getRowCount
in interfaceTableModel
- Returns:
- the number of rows
-
getColumnClass
public Class getColumnClass(int columnIndex)
Returns the class of the column.- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
- Parameters:
columnIndex
- 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- Returns:
- the name
-
getValueAt
public Object getValueAt(int rowIndex, int columnIndex)
Returns the value at the specified position.- Specified by:
getValueAt
in interfaceTableModel
- Parameters:
rowIndex
- the rowcolumnIndex
- the column- Returns:
- the value
-
setValueAt
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
Sets the value at the given position.- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classAbstractTableModel
- Parameters:
aValue
- the value to setrowIndex
- the rowcolumnIndex
- the column
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)
Returns whether a cell is editable or not.- Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
- Parameters:
rowIndex
- the rowcolumnIndex
- the column- Returns:
- true if editable
-
dataChanged
public void dataChanged(DataChangeEvent e)
Gets called if the data of the manager noticed a changed.- Specified by:
dataChanged
in interfaceDataChangeListener
- Parameters:
e
- the event that was sent
-
getContainerAt
public C getContainerAt(int row)
Returns the container at the specified row.- Parameters:
row
- the row of the container to retrieve- Returns:
- the container
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceCleanUpHandler
-
-