java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
is.codion.swing.common.ui.component.table.FilterTable<R,C>
Type Parameters:
R - the type representing rows
C - the type used to identify columns
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable

public final class FilterTable<R,C> extends JTable
A JTable implementation for FilterTableModel. Note that for the table header to display you must add this table to a JScrollPane. For instances use the builder builder()
See Also:
  • Field Details

    • AUTO_RESIZE_MODE

      public static final PropertyValue<Integer> AUTO_RESIZE_MODE
      Specifies the default table column resize mode for tables in the application
    • COLUMN_REORDERING

      public static final PropertyValue<Boolean> COLUMN_REORDERING
      Specifies whether columns can be rearranged
      • Value type: Boolean
      • Default value: true
    • COLUMN_RESIZING

      public static final PropertyValue<Boolean> COLUMN_RESIZING
      Specifies whether columns can be resized
      • Value type: Boolean
      • Default value: true
    • RESIZE_ROW_TO_FIT_EDITOR

      public static final PropertyValue<Boolean> RESIZE_ROW_TO_FIT_EDITOR
      Specifies whether the table resizes the row being edited to fit the editor component. Only applicable to FilterTableCellEditor.
      • Value type: Boolean
      • Default value: true
  • Method Details

    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JTable
    • getModel

      public FilterTableModel<R,C> getModel()
      Overrides:
      getModel in class JTable
    • model

      public FilterTableModel<R,C> model()
      Returns:
      the table model
    • getColumnModel

      public FilterTableColumnModel<C> getColumnModel()
      Overrides:
      getColumnModel in class JTable
    • columnModel

      public FilterTableColumnModel<C> columnModel()
      Returns:
      the column model
    • setModel

      public void setModel(TableModel dataModel)
      Overrides:
      setModel in class JTable
    • isCellEditable

      public boolean isCellEditable(int row, int column)
      Overrides:
      isCellEditable in class JTable
    • setColumnModel

      public void setColumnModel(TableColumnModel columnModel)
      Overrides:
      setColumnModel in class JTable
    • setSelectionModel

      public void setSelectionModel(ListSelectionModel selectionModel)
      Overrides:
      setSelectionModel in class JTable
    • filters

      public TableConditionPanel<C> filters()
      Returns:
      the filter TableConditionPanel
    • search

      public FilterTableSearchModel search()
      Returns:
      the search model
    • summaries

      public TableSummaryModel<C> summaries()
      Returns:
      the summary model
    • searchField

      public JTextField searchField()
      Returns:
      the search field
    • doubleClick

      public Value<Action> doubleClick()

      The Action is only triggered if enabled.

      The ActionEvent propagated when this action is performed, contains the associated MouseEvent as source.

         public void actionPerformed(ActionEvent event) {
             MouseEvent mouseEvent = (MouseEvent) event.getSource();
             Point location = mouseEvent.getLocationOnScreen();
             // ...
         }
      
      Returns:
      the Value controlling the action to perform when a double click is performed on the table
    • sortable

      public State sortable()
      Returns:
      the State controlling whether sorting via the table header is enabled
    • scrollToSelectedItem

      public State scrollToSelectedItem()
      Returns:
      the State controlling whether the JTable instance scrolls automatically to the coordinate of the item selected in the underlying table model
    • centerOnScroll

      public Value<FilterTable.CenterOnScroll> centerOnScroll()
      Returns:
      the Value controlling the scrolling behaviour when scrolling to the selected row/column
    • setSelectionMode

      public void setSelectionMode(int selectionMode)
      Overrides:
      setSelectionMode in class JTable
    • selectColumns

      public void selectColumns()
      Shows a dialog for selecting which columns to display
    • selectAutoResizeMode

      public void selectAutoResizeMode()
      Displays a dialog for selecting the column auto-resize mode
    • cellVisible

      public boolean cellVisible(int row, int column)
      Returns true if the given cell is visible.
      Parameters:
      row - the row
      column - the column
      Returns:
      true if this table is contained in a scrollpanel and the cell with the given coordinates is visible.
    • scrollToColumn

      public void scrollToColumn(C identifier)
      Scrolls horizontally so that the column identified by the given identifier becomes visible. Has no effect if this table is not contained in a scrollpanel.
      Parameters:
      identifier - the column identifier
    • scrollToRowColumn

      public void scrollToRowColumn(int row, int column, FilterTable.CenterOnScroll centerOnScroll)
      Scrolls to the given coordinate. Has no effect if this table is not contained in a scrollpanel.
      Parameters:
      row - the row
      column - the column
      centerOnScroll - specifies whether to center the selected row and or column
    • copySelectedCell

      public void copySelectedCell()
      Copies the contents of the selected cell to the clipboard.
    • copySelectedColumn

      public void copySelectedColumn()
      Copies the contents of the selected column cells to the clipboard.
    • copyToClipboard

      public void copyToClipboard()

      Copies the table data as a TAB delimited string, with header, to the clipboard.

      If the selection is empty, all rows are included, otherwise only selected ones.

      If column selection is enabled, only selected columns are included, otherwise all visible columns.

    • createSelectColumnsControl

      public CommandControl createSelectColumnsControl()
      Returns:
      a control for showing the column selection dialog
    • createToggleColumnsControls

      public Controls createToggleColumnsControls()
      Returns:
      Controls containing ToggleControls for showing/hiding columns.
    • createResetColumnsControl

      public CommandControl createResetColumnsControl()
      Returns:
      a Control for resetting the columns to their original location and visibility
    • createSelectAutoResizeModeControl

      public CommandControl createSelectAutoResizeModeControl()
      Returns:
      a Control for selecting the auto-resize mode
    • createToggleAutoResizeModeControls

      public Controls createToggleAutoResizeModeControls()
      Returns:
      Controls containing ToggleControls for choosing the auto resize mode.
    • createSingleSelectionControl

      public ToggleControl createSingleSelectionControl()
      Returns:
      a ToggleControl controlling whether single selection mode is enabled
    • createCopyCellControl

      public CommandControl createCopyCellControl()
      Returns:
      a Control for copying the contents of the selected cell
    • createCopyColumn

      public CommandControl createCopyColumn()
      Returns:
      a Control for copying the contents of the selected column
    • autoStartsEdit

      public void autoStartsEdit(boolean autoStartsEdit)
      A convenience method for setting the client property 'JTable.autoStartsEdit'.
      Parameters:
      autoStartsEdit - the value
    • doubleClicked

      public Observer<MouseEvent> doubleClicked()
      Returns:
      an observer notified each time the table is double-clicked
    • summaryValues

      public static <T extends Number, C> SummaryModel.SummaryValues<T> summaryValues(C identifier, FilterTableModel<?,C> tableModel, Format format)
      Instantiates a new SummaryModel.SummaryValues instance.
      Type Parameters:
      T - the column value type
      C - the column identifier type
      Parameters:
      identifier - the column identifier
      tableModel - the table model
      format - the format
      Returns:
      a new SummaryModel.SummaryValues instance
    • builder

      public static FilterTable.Builder.ModelStep builder()
      Returns:
      a FilterTable.Builder.ModelStep instance
    • createDefaultTableHeader

      protected JTableHeader createDefaultTableHeader()
      Overrides:
      createDefaultTableHeader in class JTable