Package docking.widgets.table
Class TableUtils
java.lang.Object
docking.widgets.table.TableUtils
A utility class for JTables used in Ghidra.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
columnAlternativelySelected
(JTable table, int columnIndex) Attempts to sort the given table based upon the given column index.static void
columnSelected
(JTable table, int columnIndex) Attempts to sort the given table based upon the given column index.static <ROW_OBJECT>
StringgetTableCellStringValue
(RowObjectTableModel<ROW_OBJECT> model, ROW_OBJECT rowObject, int column) Uses the given row-based table model, row object and column index to determine what the String value should be for that cell.static <ROW_OBJECT>
voidsetSelectedItems
(JTable table, List<ROW_OBJECT> items) Select the given row objects.
-
Constructor Details
-
TableUtils
public TableUtils()
-
-
Method Details
-
setSelectedItems
Select the given row objects. No selection will be made if the objects are filtered out of view. Passing anull
list or an empty list will clear the selection.- Parameters:
table
- the table in which to select the itemsitems
- the row objects to select
-
getTableCellStringValue
public static <ROW_OBJECT> String getTableCellStringValue(RowObjectTableModel<ROW_OBJECT> model, ROW_OBJECT rowObject, int column) Uses the given row-based table model, row object and column index to determine what the String value should be for that cell.This is used to provide a means for filtering on the text that is displayed to the user.
- Type Parameters:
ROW_OBJECT
- The model's row object type- Parameters:
model
- the modelrowObject
- the row object for the row being queriedcolumn
- the column index in the table model- Returns:
- the string value; null if no value can be fabricated
-
columnSelected
Attempts to sort the given table based upon the given column index. If theTableModel
of the given table is not aSortedTableModel
, then this method will do nothing.If the given column index is not sortable, then this method will not change the state of the model. Otherwise, the sorted model will be sorted on the given column index. The results of calling this method depend upon the current sorted state of the given column:
- if the column is not yet the sorted column, then the column is made the sorted column, if sortable, and any other sorted columns will be made unsorted, or
- if the column is the sorted column and the direction will simply be toggled.
- Parameters:
table
- The table whose model shall be sorted.columnIndex
- The column index upon which to sort.
-
columnAlternativelySelected
Attempts to sort the given table based upon the given column index. If theTableModel
of the given table is not aSortedTableModel
, then this method will do nothing.If the given column index is not sortable, then this method will not change the state of the model. The results of calling this method depend upon the current sorted state of the given column:
- if the column is not yet sorted, then the column is made sorted, if sortable, and any other sorted columns will not be changed, or
- if the column is sorted, then:
- if there are other sorted columns, this column will no longer be sorted
- if there are no other sorted columns, then no action will be taken
- Parameters:
table
- The table whose model shall be sorted.columnIndex
- The column index upon which to sort.
-