Class TableUtils


  • public class TableUtils
    extends java.lang.Object
    A utility class for JTables used in Ghidra.
    • Constructor Summary

      Constructors 
      Constructor Description
      TableUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void columnAlternativelySelected​(javax.swing.JTable table, int columnIndex)
      Attempts to sort the given table based upon the given column index.
      static void columnSelected​(javax.swing.JTable table, int columnIndex)
      Attempts to sort the given table based upon the given column index.
      static <ROW_OBJECT>
      java.lang.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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TableUtils

        public TableUtils()
    • Method Detail

      • getTableCellStringValue

        public static <ROW_OBJECT> java.lang.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​(javax.swing.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​(javax.swing.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.