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(FilterTableModel, List)
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
    • Value type: Integer (JTable.AUTO_RESIZE_*)
    • Default value: JTable.AUTO_RESIZE_OFF
    • ALLOW_COLUMN_REORDERING

      public static final PropertyValue<Boolean> ALLOW_COLUMN_REORDERING
      Specifies whether columns can be rearranged in tables
    • 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
    • setColumnModel

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

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

      public TableConditionPanel<C> conditionPanel()
      Returns:
      the filter condition panel
    • searchModel

      public FilterTableSearchModel searchModel()
      Returns:
      the search model
    • sortModel

      public FilterTableSortModel<R,C> sortModel()
      Returns:
      the sorting model
    • summaryModel

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

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

      public Value<Action> doubleClickAction()
      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
    • sortingEnabled

      public State sortingEnabled()
      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
    • scrollToCoordinate

      public void scrollToCoordinate(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.
    • 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.
    • copySelectedToClipboard

      public void copySelectedToClipboard()
      Copies the selected table rows as a TAB delimited string, with header, to the clipboard.
    • export

      public FilterTable.Export export()
      Returns:
      a FilterTable.Export instance for exporting the table model data
    • 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.
    • createSingleSelectionModeControl

      public ToggleControl createSingleSelectionModeControl()
      Returns:
      a ToggleControl for toggling the table selection mode (single or multiple)
    • createCopyCellControl

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

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

      public Observer<MouseEvent> doubleClick()
      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 <R, C> FilterTable.Builder<R,C> builder(FilterTableModel<R,C> tableModel, List<FilterTableColumn<C>> columns)
      Instantiates a new FilterTable.Builder using the given model
      Type Parameters:
      R - the type representing rows
      C - the type used to identify columns
      Parameters:
      tableModel - the table model
      columns - the columns
      Returns:
      a new FilterTable.Builder instance
      Throws:
      IllegalArgumentException - in case the column identifiers are not unique
    • createDefaultTableHeader

      protected JTableHeader createDefaultTableHeader()
      Overrides:
      createDefaultTableHeader in class JTable