Package docking.widgets.table

# Class TableUtils

java.lang.Object
docking.widgets.table.TableUtils

public class TableUtils extends Object
A utility class for JTables used in Ghidra.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TableUtils()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static 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>
  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.
  `static <ROW_OBJECT>
  void`
  `setSelectedItems(JTable table, List<ROW_OBJECT> items)`
  Select the given row objects.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### TableUtils

    public TableUtils()

- ## Method Details

  - ### setSelectedItems

    public static <ROW_OBJECT> void setSelectedItems(JTable table, List<ROW_OBJECT> items)
    Select the given row objects. No selection will be made if the objects are filtered out of view. Passing a `null` list or an empty list will clear the selection.
    Parameters:
      `table` - the table in which to select the items
      `items` - 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 model
      `rowObject` - the row object for the row being queried
      `column` - the column index in the table model
    Returns:
      the string value; null if no value can be fabricated

  - ### columnSelected

    public static void columnSelected(JTable table, int columnIndex)
    Attempts to sort the given table based upon the given column index. If the `TableModel` of the given table is not a `SortedTableModel`, 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:

    1. 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
    2. 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

    public static void columnAlternativelySelected(JTable table, int columnIndex)
    Attempts to sort the given table based upon the given column index. If the `TableModel` of the given table is not a `SortedTableModel`, 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:

    1. 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
    2. if the column is sorted, then:
       1. if there are other sorted columns, this column will no longer be sorted
       2. 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.