Class GDynamicColumnTableModel<ROW_TYPE, DATA_SOURCE>
- Type Parameters:
ROW_TYPE- the row object class for this table model.DATA_SOURCE- the type of data that will be returned fromgetDataSource(). This object will be given to theDynamicTableColumnobjects used by this table model whenDynamicTableColumn.getValue(Object, ghidra.docking.settings.Settings, Object, ServiceProvider)is called.
- All Implemented Interfaces:
ConfigurableColumnTableModel, DynamicColumnTableModel<ROW_TYPE>, RowObjectTableModel<ROW_TYPE>, SelectionStorage<ROW_TYPE>, SortedTableModel, VariableColumnTableModel, Serializable, EventListener, ChangeListener, TableModel
- Direct Known Subclasses:
AnyObjectTableModel, BSimServerTableModel, DefaultEnumeratedColumnTableModel, SetEquateTableModel, ThemeColorTableModel, ThemeFontTableModel, ThemeIconTableModel, ThreadedTableModel, UserAccessTableModel
createTableColumnDescriptor().
This method specifies which default columns the table should have and whether they should be
visible or hidden. Hidden columns can be made visible through the UI.
This model will also discover other system columns that understand how to render
ROW_TYPE data directly. Also, if you create a mapper(s) for
your row type, then this model will load columns for each type for which a mapper was created,
all as optional, hidden columns.
The various attributes of the columns of this model (visibility, position, size, etc) are saved to disk as tool preferences when the user exits the tool.
Implementation Note: this model loads all columns, specific and discovered, as being visible.
Then, during initialization, the TableColumnModelState class will either hide all
non-default columns, or reload the column state if any previous saved state is found.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<DynamicTableColumn<ROW_TYPE, ?, ?>, Settings> protected ServiceProviderprotected List<DynamicTableColumn<ROW_TYPE, ?, ?>> All currently visible columnsFields inherited from class AbstractSortedTableModel
hasEverSortedFields inherited from class AbstractGTableModel
isDisposed, WIDTH_UNDEFINEDFields inherited from class AbstractTableModel
listenerListFields inherited from interface SortedTableModel
ASCENDING_ORDER, DESCENDING_ORDER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddTableColumn(DynamicTableColumn<ROW_TYPE, ?, ?> column) Adds the given column at the end of the list of columns.protected voidaddTableColumn(DynamicTableColumn<ROW_TYPE, ?, ?> column, int index, boolean isDefault) Adds the given field at the given index to the list of fields in this class.protected voidaddTableColumns(Set<DynamicTableColumn<ROW_TYPE, ?, ?>> columns) Adds the given columns to the end of the list of columns.protected voidaddTableColumns(Set<DynamicTableColumn<ROW_TYPE, ?, ?>> columns, boolean isDefault) Adds the given columns to the end of the list of columns.protected Comparator<ROW_TYPE> createSortComparator(int columnIndex) An extension point for subclasses to insert their own comparator objects for their data.protected Comparator<Object> createSortComparatorForColumn(int columnIndex) This differs fromcreateSortComparator(int)in that the other method creates a comparator that operates on a full row value, whereas this method operates on column values.protected abstract TableColumnDescriptor<ROW_TYPE> voiddispose()Call this when the model will no longer be usedprotected voidgetColumn(int index) Returns the column for the given model indexfinal Class<?> getColumnClass(int column) final intgetColumnDescription(int column) getColumnDisplayName(int columnIndex) intgetColumnIndex(DynamicTableColumn<ROW_TYPE, ?, ?> identifier) Returns the model index for the given columnintgetColumnIndex(Class<?> columnClass) Returns the column index of the given column class, or -1 if not found.final StringgetColumnName(int column) getColumnSettings(int index) Returns settings for the specified column index.getColumnSettingsDefinitions(int index) Returns settings definitions for the specified column index.final ObjectgetColumnValueForRow(ROW_TYPE t, int columnIndex) Implementors are expected to return a value at the given column index for the specified row object.abstract DATA_SOURCEReturns the table's context for the data.intGets the count of the default columns for this model.getEditor(int index) Returns the table cell editor for the given column.getHeaderRenderer(int index) Returns the header cell renderer for the given column.intgetMaxColumnWidth(int column) intgetMaxLines(int index) Returns the maximum number of text display lines needed for any given cell within the specified column.intgetMinColumnWidth(int column) intgetPreferredColumnWidth(int column) getRenderer(int index) Returns the table cell renderer for the given column.protected TableColumnDescriptor<ROW_TYPE> getUniqueIdentifier(int column) Returns a value that is unique for a given table column.booleanisDefaultColumn(int modelIndex) Returns true if the column denoted by the given model index is default (specified initially by the table model).booleanisSortable(int columnIndex) Returns true if the specified columnIndex is sortable.booleanisVisibleByDefault(int modelIndex) Returns true if the column denoted by the given model index is specified by the table model as being visible when the table is loaded for the first time.protected voidprotected voidAllows clients to defer column creation until after this parent class's constructor has been called.protected voidremoveTableColumn(DynamicTableColumn<ROW_TYPE, ?, ?> column) Removes the given column from this modelprotected voidremoveTableColumns(Set<DynamicTableColumn<ROW_TYPE, ?, ?>> columns) Removes the given columns from this model.voidsetAllColumnSettings(Settings[] newSettings) Allows for the bulk setting of Settings.voidCallback when column settings have changedMethods inherited from class AbstractSortedTableModel
addSortListener, cleanupTableSortState, createSortingContext, fireTableChanged, getIndexForRowObject, getIndexForRowObject, getPendingSortState, getPrimarySortColumnIndex, getRowIndex, getRowObject, getTableSortState, getValueAt, initializeSorting, isSorted, isSortPending, notifyModelSorted, reSort, setDefaultTableSortState, setTableSortState, sort, sortCompletedMethods inherited from class AbstractGTableModel
getLastSelectedObjects, getRowCount, isDisposed, refresh, setLastSelectedObjectsMethods inherited from class AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAtMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DynamicColumnTableModel
getPreferenceKeyMethods inherited from interface RowObjectTableModel
fireTableDataChanged, getModelData, getName, getRowIndex, getRowObjectMethods inherited from interface TableModel
addTableModelListener, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
-
Field Details
-
serviceProvider
-
columnSettings
-
tableColumns
All currently visible columns
-
-
Constructor Details
-
GDynamicColumnTableModel
-
-
Method Details
-
createTableColumnDescriptor
-
isSortable
public boolean isSortable(int columnIndex) Description copied from interface:SortedTableModelReturns true if the specified columnIndex is sortable.- Specified by:
isSortablein interfaceSortedTableModel- Parameters:
columnIndex- the column index- Returns:
- true if the specified columnIndex is sortable
-
loadDiscoveredTableColumns
protected void loadDiscoveredTableColumns() -
reloadColumns
protected void reloadColumns()Allows clients to defer column creation until after this parent class's constructor has been called.This method will not restore any column settings that have been changed after construction. Thus, this method is intended only to be called during the construction process.
-
getTableColumnDescriptor
-
createSortComparator
Description copied from class:AbstractSortedTableModelAn extension point for subclasses to insert their own comparator objects for their data. Subclasses can create comparators for a single or multiple columns, as desired.- Overrides:
createSortComparatorin classAbstractSortedTableModel<ROW_TYPE>- Parameters:
columnIndex- the column index- Returns:
- the comparator
-
createSortComparatorForColumn
This differs fromcreateSortComparator(int)in that the other method creates a comparator that operates on a full row value, whereas this method operates on column values.- Parameters:
columnIndex- the column index- Returns:
- a comparator for the specific column values
-
stateChanged
Callback when column settings have changed- Specified by:
stateChangedin interfaceChangeListener
-
addTableColumn
Adds the given column at the end of the list of columns.This method is intended for implementations to add custom column objects, rather than relying on generic, discovered DynamicTableColumn implementations.
Note: this method assumes that the columns have already been sorted
- Parameters:
column- The field to add
-
addTableColumns
Adds the given columns to the end of the list of columns.This method is intended for implementations to add custom column objects, rather than relying on generic, discovered DynamicTableColumn implementations.
Note: this method assumes that the columns have already been sorted.
- Parameters:
columns- The columns to add
-
addTableColumns
Adds the given columns to the end of the list of columns.This method is intended for implementations to add custom column objects, rather than relying on generic, discovered DynamicTableColumn implementations.
Note: this method assumes that the columns have already been sorted.
- Parameters:
columns- The columns to addisDefault- true if these are default columns
-
addTableColumn
protected void addTableColumn(DynamicTableColumn<ROW_TYPE, ?, ?> column, int index, boolean isDefault) Adds the given field at the given index to the list of fields in this class.This method is intended for implementations to add custom column objects, rather than relying on generic, discovered DynamicTableColumn implementations.
Note: this method assumes that the columns have already been sorted.
- Parameters:
column- The field to add.index- The index at which to add the field. If the index value is invalid (negative or greater than the number of columns), then the column will be added to the end of the columns list.isDefault- true if this is a default column
-
removeTableColumn
Removes the given column from this model- Parameters:
column- the column to remove
-
removeTableColumns
Removes the given columns from this model.This method allows the client to remove multiple columns at once, firing only one event when the work is finished.
- Parameters:
columns- the columns to remove
-
getDefaultColumnCount
public int getDefaultColumnCount()Description copied from interface:VariableColumnTableModelGets the count of the default columns for this model. This model may have non-default columns added. This method will return the count of columns that have been setup specifically by the table model. This method can be used to iterate of the firstncolumns of this model in order to get information for the default columns by calling methods likeTableModel.getColumnName(int).- Specified by:
getDefaultColumnCountin interfaceVariableColumnTableModel- Returns:
- Gets the count of the default columns for this model.
-
isVisibleByDefault
public boolean isVisibleByDefault(int modelIndex) Description copied from interface:VariableColumnTableModelReturns true if the column denoted by the given model index is specified by the table model as being visible when the table is loaded for the first time.- Specified by:
isVisibleByDefaultin interfaceVariableColumnTableModel- Parameters:
modelIndex- The index in the column in the column model.- Returns:
- true if the column denoted by the given model index is visible default.
-
isDefaultColumn
public boolean isDefaultColumn(int modelIndex) Description copied from interface:VariableColumnTableModelReturns true if the column denoted by the given model index is default (specified initially by the table model).- Specified by:
isDefaultColumnin interfaceVariableColumnTableModel- Parameters:
modelIndex- The index in the column in the column model.- Returns:
- true if the column denoted by the given model index is default.
-
getColumnCount
public final int getColumnCount()- Specified by:
getColumnCountin interfaceTableModel
-
getColumnClass
- Specified by:
getColumnClassin interfaceTableModel- Overrides:
getColumnClassin classAbstractTableModel
-
getColumnName
- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel
-
getPreferredColumnWidth
public int getPreferredColumnWidth(int column) - Overrides:
getPreferredColumnWidthin classAbstractGTableModel<ROW_TYPE>
-
getMaxColumnWidth
public int getMaxColumnWidth(int column) - Overrides:
getMaxColumnWidthin classAbstractGTableModel<ROW_TYPE>
-
getMinColumnWidth
public int getMinColumnWidth(int column) - Overrides:
getMinColumnWidthin classAbstractGTableModel<ROW_TYPE>
-
getColumnDisplayName
- Specified by:
getColumnDisplayNamein interfaceVariableColumnTableModel
-
getColumnDescription
- Specified by:
getColumnDescriptionin interfaceVariableColumnTableModel
-
getUniqueIdentifier
Description copied from interface:VariableColumnTableModelReturns a value that is unique for a given table column. This is different than getting the display name, which may be shared by different columns.- Specified by:
getUniqueIdentifierin interfaceVariableColumnTableModel- Parameters:
column- the index (in the model space) of the column for which to get the identifier- Returns:
- the identifier
-
getColumnValueForRow
Description copied from interface:RowObjectTableModelImplementors are expected to return a value at the given column index for the specified row object. This is essentially a more specific version of theTableModel.getValueAt(int, int)that allows this class's comparator objects to work.- Specified by:
getColumnValueForRowin interfaceRowObjectTableModel<ROW_TYPE>- Parameters:
t- The object that represents a given row.columnIndex- The column index for which a value is requested.- Returns:
- a value at the given column index for the specified row object.
-
getDataSource
Returns the table's context for the data.- Returns:
- the table's context for the data
-
getColumnIndex
Returns the column index of the given column class, or -1 if not found.- Parameters:
columnClass- the class for the type of DynamicTableColumn you want to find.- Returns:
- the column index of the given column class, or -1 if not found
-
getColumnIndex
Description copied from interface:DynamicColumnTableModelReturns the model index for the given column- Specified by:
getColumnIndexin interfaceDynamicColumnTableModel<ROW_TYPE>- Parameters:
identifier- the column- Returns:
- the model index
-
getColumn
Description copied from interface:DynamicColumnTableModelReturns the column for the given model index- Specified by:
getColumnin interfaceDynamicColumnTableModel<ROW_TYPE>- Parameters:
index- the model index of the column (this can differ from the view index)- Returns:
- the column
-
getColumnSettingsDefinitions
Description copied from interface:ConfigurableColumnTableModelReturns settings definitions for the specified column index.- Specified by:
getColumnSettingsDefinitionsin interfaceConfigurableColumnTableModel- Parameters:
index- column index- Returns:
- settings definitions for the specified column index
-
getColumnSettings
Description copied from interface:ConfigurableColumnTableModelReturns settings for the specified column index.- Specified by:
getColumnSettingsin interfaceConfigurableColumnTableModel- Parameters:
index- column index- Returns:
- settings for the specified column index
-
setAllColumnSettings
Description copied from interface:ConfigurableColumnTableModelAllows for the bulk setting of Settings.This prevents excessive event notification when all settings need to be changed.
- Specified by:
setAllColumnSettingsin interfaceConfigurableColumnTableModel- Parameters:
newSettings- An array of Settings that contains Settings for each column where the index of the Settings in the array is the index of the column in the model
-
getRenderer
Description copied from interface:ConfigurableColumnTableModelReturns the table cell renderer for the given column.A null value indicates this column uses the default cell renderer.
- Specified by:
getRendererin interfaceConfigurableColumnTableModel- Parameters:
index- the index of the column- Returns:
- the table cell renderer for the given column
-
getEditor
Description copied from interface:ConfigurableColumnTableModelReturns the table cell editor for the given column.A null value indicates this column uses the default cell editor.
- Specified by:
getEditorin interfaceConfigurableColumnTableModel- Parameters:
index- the index of the column- Returns:
- the table cell editor for the given column
-
getHeaderRenderer
Description copied from interface:ConfigurableColumnTableModelReturns the header cell renderer for the given column.A null value indicates this column uses the default header renderer.
- Specified by:
getHeaderRendererin interfaceConfigurableColumnTableModel- Parameters:
index- the index of the column- Returns:
- the header cell renderer for the given column
-
getMaxLines
public int getMaxLines(int index) Description copied from interface:ConfigurableColumnTableModelReturns the maximum number of text display lines needed for any given cell within the specified column.- Specified by:
getMaxLinesin interfaceConfigurableColumnTableModel- Parameters:
index- column field index- Returns:
- the maximum number of text display lines needed for any given cell within the specified column
-
dispose
public void dispose()Description copied from class:AbstractGTableModelCall this when the model will no longer be used- Overrides:
disposein classAbstractGTableModel<ROW_TYPE>
-
disposeDynamicColumnData
protected void disposeDynamicColumnData()
-