Class GuiTable

All Implemented Interfaces:
Workspace, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable
Direct Known Subclasses:
InputOverlayTable, InputRowsTable, IrisTable

public class GuiTable
extends JTable
implements Workspace
A basic UI table backed by a WColumnSet and IrisTableModel
See Also:
Serialized Form
  • Field Details

    • columnSet_

      protected com.fishlib.dataobjects.WColumnSet columnSet_
  • Constructor Details

  • Method Details

    • setModel

      public void setModel​(IrisTableModel model)
    • setModel

      protected void setModel​(IrisTableModel model, TableColumnModel columnModel)
    • getOriginalRenderer

      public TableCellRenderer getOriginalRenderer()
    • setFreezeColumnsManager

      public void setFreezeColumnsManager​(FreezeColumnsManager freezeColumnsManager)
      Sets the FreezeColumnsManager to allow this GuiTable to support Freeze Columns.
      Parameters:
      freezeColumnsManager - the FreezeColumnsManager
    • getFreezeColumnsManager

      public FreezeColumnsManager getFreezeColumnsManager()
      Gets the FreezeColumnsManager. This will be null if the table does no support Freeze Columns.
      Returns:
      the FreezeColumnsManager, null if Freeze Columns are not supported
    • createTransferHandler

      protected TransferHandler createTransferHandler()
      Creates the transfer handler.
      Returns:
      the transfer handler
    • createDefaultColumnModel

      public static HiddenColumnModel createDefaultColumnModel​(com.fishlib.dataobjects.WColumnSet wColumnSet)
    • maybeAddSelectionModel

      protected void maybeAddSelectionModel()
    • changeSelection

      public void changeSelection​(int rowIndex, int columnIndex, boolean toggle, boolean extend)
      Overrides:
      changeSelection in class JTable
    • getSelectedRow

      public int getSelectedRow()
      Overrides:
      getSelectedRow in class JTable
    • createDefaultTableHeader

      protected JTableHeader createDefaultTableHeader()
      Overrides:
      createDefaultTableHeader in class JTable
    • getHeaderToolTipText

      public String getHeaderToolTipText​(MouseEvent e)
    • generateToolTip

      public static String generateToolTip​(int col, TableModel model, GuiColumn column)
    • getColumnSet

      public com.fishlib.dataobjects.WColumnSet getColumnSet()
    • getOriginalTableModel

      public IrisTableModel getOriginalTableModel()
    • createTableColumn

      public static TableColumn createTableColumn​(GuiColumn column, int modelIndex)
    • getGridColor

      public Color getGridColor()
      Overrides:
      getGridColor in class JTable
    • setTableHeader

      public void setTableHeader​(JTableHeader tableHeader)
      Overrides:
      setTableHeader in class JTable
    • getRowHeight

      public int getRowHeight()
      Overrides:
      getRowHeight in class JTable
    • getSelectedRows

      public int[] getSelectedRows()
      Overrides:
      getSelectedRows in class JTable
    • getViewableCells

      public TableBounds getViewableCells()
      Returns:
      TableBounds of the viewable cells or TableBounds.EMPTY if no viewable cells
    • rowAtPoint

      public int rowAtPoint​(@NotNull Point point)
      We want to make sure that if we're actually negative we can differentiate that from running off the end of the table, so instead we return -2 instead of -1 in that case.
      Overrides:
      rowAtPoint in class JTable
    • processSingleClick

      protected void processSingleClick​(int row, int col, MouseEvent e)
      Process a single click. The base method does nothing and may be overridden.
      Parameters:
      row - The row clicked.
      col - The column clicked.
      e - The details of the click event.
    • processDoubleClick

      public void processDoubleClick​(int row, int col, MouseEvent e)
      Process a double click. The base method does nothing and may be overridden.
      Parameters:
      row - The row clicked.
      col - The column clicked.
      e - The details of the click event.
    • processHeaderClick

      protected void processHeaderClick​(int col, MouseEvent e)
      Process a header single or double click. The base method creates a TableHeaderPopup but may be overridden.
      Parameters:
      col - The column clicked.
      e - The details of the click event.
    • isAlertsOn

      public boolean isAlertsOn()
      Get if table changes will alert the user.
    • setAlertsOn

      public void setAlertsOn​(boolean alertsOn)
      Set if table changes should alert the user.
    • isOneClickOn

      public boolean isOneClickOn()
      Get if the table should respond to OneClick events
    • setOneClickOn

      public void setOneClickOn​(boolean oneClickOn)
      Set if the table should respond to OneClick events.
    • isFollowingTable

      public boolean isFollowingTable()
      Get if the table will scroll with new items added.
    • setFollowTable

      public void setFollowTable​(boolean followTable)
      Set if the table view should follow new rows that are added.
      Parameters:
      followTable -
    • getAlertsPropagate

      public boolean getAlertsPropagate()
      Get if alerts should propagate up through the tabs.
      Returns:
    • setAlertsPropagate

      public void setAlertsPropagate​(boolean alertsPropagate)
      Set if the alerts should propagate up through the tabs.
      Parameters:
      alertsPropagate -
    • getAlertStyle

      public GuiTable.AlertStyle getAlertStyle()
    • setAlertsStyle

      public void setAlertsStyle​(GuiTable.AlertStyle alertStyle)
    • shouldSelectAlert

      public boolean shouldSelectAlert​(GuiTable.AlertStyle alertStyle)
    • setDefaultAlert

      public void setDefaultAlert​(boolean defaultAlert)
    • scrollToRow

      public void scrollToRow​(int row)
      Scroll a specific row to the top of the view.
      Parameters:
      row - The row to scroll into view.
    • scrollToCenter

      public void scrollToCenter​(int row)
      Scroll a specific row to the center of the view.
      Parameters:
      row - The roll to center.
    • tableChanged

      public void tableChanged​(TableModelEvent e)
      Specified by:
      tableChanged in interface TableModelListener
      Overrides:
      tableChanged in class JTable
    • updateColumns

      public void updateColumns()

      Called when the table changes in order to properly process updates to columns.

      Handles the following column updates:
      - preserve current order
      - keep hidden columns hidden
      - add new columns to the end
      - replace columns that are the "same"
      - remove missing columns
      - fix renderers of the wrong column type

      Subclasses may override this method to add additional updates to columns. It is recommended to call super.updateColumns() before operating on columns.

    • getWorkspaceInfo

      public org.jdom2.Element getWorkspaceInfo()
      Description copied from interface: Workspace
      Serialize the class into an element to be stored in the workspace
      Specified by:
      getWorkspaceInfo in interface Workspace
      Returns:
      An Element containing the data to persist.
    • setWorkspaceInfo

      public void setWorkspaceInfo​(org.jdom2.Element workspaceInfo)
      Description copied from interface: Workspace
      Restore the class to the state defined by the data persisted in workspaceInfo
      Specified by:
      setWorkspaceInfo in interface Workspace
      Parameters:
      workspaceInfo - An Element containing the persisted state.
    • workspaceHasFreezeColumns

      protected static boolean workspaceHasFreezeColumns​(org.jdom2.Element workspaceInfo)
      Indicates if a workspace element contains freeze columns.
      Parameters:
      workspaceInfo - the workspace element to check
      Returns:
      true if it contains freeze columns, false otherwise
    • convertTableColumns

      protected void convertTableColumns​(org.jdom2.Element tableInfo)
    • handleUnmentionedColumns

      protected void handleUnmentionedColumns​(HiddenColumnModel columnModel, Set<TableColumn> unmentionedColumns, Collection<String> initialHiddenColumns)
      Handle any columns that have not been visited by the current column ordering. When this method is invoked all layout hints including atFront() and atBack() have been evaluated. The default implementation simply places them at the end of the current order.
      Parameters:
      columnModel - The model
      unmentionedColumns - The columns that have not yet been inserted into the order
      initialHiddenColumns - The columns which were explicitly hidden
    • setColumnFormatter

      protected void setColumnFormatter​(String columnName, org.jdom2.Element formatInfo)
      Sets the column formatter from workspace info. The default implementation does nothing but subclasses should override this method to create the correct concrete formatter.
      Parameters:
      columnName - the name of the column
      formatInfo - element containing workspace info
    • resetColumns

      public void resetColumns()
      Reset the state of the columns (order, hidden, locked, etc) to the state defined by the query. It will _not_ respect the same settings from the workspace.
    • areSavedLayoutsAllowed

      protected boolean areSavedLayoutsAllowed()
    • getFrontColumns

      @NotNull protected Set<String> getFrontColumns()
    • getBackColumns

      @NotNull protected Set<String> getBackColumns()
    • getAutoFilterColumns

      @NotNull protected Set<String> getAutoFilterColumns()
    • getFreezeColumns

      @NotNull protected Set<String> getFreezeColumns()
    • setTableDescription

      public void setTableDescription​(String tableDescription)
    • getHiddenColumns

      @NotNull protected Set<String> getHiddenColumns()
    • createFilterMenu

      public JMenu createFilterMenu​(GuiColumn column, FilterStrategyImpl filterStrategy)
      Creates a menu for the Filter by... option.
      Parameters:
      column - the column to filter
      filterStrategy - the filter strategy for the model
      Returns:
      a new filter menu
    • paint

      public void paint​(Graphics g)
      Overrides:
      paint in class JComponent