Module is.codion.swing.common.ui
Class FilterTable<R,C>
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 rowsC- the type used to identify columns
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,EventListener,Accessible,CellEditorListener,ListSelectionListener,RowSorterListener,TableColumnModelListener,TableModelListener,Scrollable
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, ColumnFactory)-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA builder for aFilterTablestatic enumSpecifies whether to center the scrolled to row and or column.static final classThe controls.static interfaceExports the table data to a String.Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintModeNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final is.codion.common.property.PropertyValue<Boolean>Specifies whether columns can be rearranged in tables
Value type: Boolean
Default value: truestatic final is.codion.common.property.PropertyValue<Integer>Specifies the default table column resize mode for tables in the application
Value type: Integer (JTable.AUTO_RESIZE_*)
Default value:JTable.AUTO_RESIZE_OFFFields inherited from class javax.swing.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeaderFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Method Summary
Modifier and TypeMethodDescriptionvoidautoStartsEdit(boolean autoStartsEdit) A convenience method for setting the client property 'JTable.autoStartsEdit'.static <R,C> FilterTable.Builder<R, C> builder(is.codion.swing.common.model.component.table.FilterTableModel<R, C> tableModel, List<FilterTableColumn<C>> columns) Instantiates a newFilterTable.Builderusing the given modelbooleancellVisible(int row, int column) Returns true if the given cell is visible.is.codion.common.value.Value<FilterTable.CenterOnScroll>voidCopies the contents of the selected cell to the clipboard.voidCopies the table data as a TAB delimited string, with header, to the clipboard.voidCopies the table data as a TAB delimited string, with header, to the clipboard.protected JTableHeaderis.codion.common.value.Value<Action>is.codion.common.event.EventObserver<MouseEvent>export()getModel()model()voidscrollToColumn(C columnIdentifier) Scrolls horizontally so that the column identified by the given identifier becomes visible.voidscrollToCoordinate(int row, int column, FilterTable.CenterOnScroll centerOnScroll) Scrolls to the given coordinate.is.codion.common.state.StatevoidDisplays a dialog for selecting the column auto-resize modevoidShows a dialog for selecting which columns to displayvoidsetColumnModel(TableColumnModel columnModel) voidsetModel(TableModel dataModel) voidsetSelectionMode(int selectionMode) voidsetSelectionModel(ListSelectionModel selectionModel) is.codion.common.state.Stateis.codion.common.model.table.TableSummaryModel<C>static <T extends Number,C>
is.codion.common.model.table.ColumnSummaryModel.SummaryValues<T>summaryValues(C columnIdentifier, is.codion.swing.common.model.component.table.FilterTableModel<?, C> tableModel, Format format) Instantiates a newColumnSummaryModel.SummaryValuesinstance.voidupdateUI()Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, tableChanged, unconfigureEnclosingScrollPane, valueChangedMethods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
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
Specifies whether columns can be rearranged in tables
Value type: Boolean
Default value: true
-
-
Method Details
-
updateUI
public void updateUI() -
getModel
-
model
- Returns:
- the table model
-
getColumnModel
- Overrides:
getColumnModelin classJTable
-
columnModel
- Returns:
- the column model
-
setModel
-
setColumnModel
- Overrides:
setColumnModelin classJTable
-
setSelectionModel
- Overrides:
setSelectionModelin classJTable
-
filterPanel
- Returns:
- the filter panel
-
searchModel
- Returns:
- the search model
-
sortModel
- Returns:
- the sorting model
-
summaryModel
- Returns:
- the summary model
-
searchField
- Returns:
- the search field
-
doubleClickAction
- Returns:
- the
Valuecontrolling the action to perform when a double click is performed on the table
-
sortingEnabled
public is.codion.common.state.State sortingEnabled()- Returns:
- the
Statecontrolling whether sorting via the table header is enabled
-
scrollToSelectedItem
public is.codion.common.state.State scrollToSelectedItem()- Returns:
- the
Statecontrolling whether the JTable instance scrolls automatically to the coordinate of the item selected in the underlying table model
-
centerOnScroll
- Returns:
- the
Valuecontrolling the scrolling behaviour when scrolling to the selected row/column
-
setSelectionMode
public void setSelectionMode(int selectionMode) - Overrides:
setSelectionModein classJTable
-
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 rowcolumn- the column- Returns:
- true if this table is contained in a scrollpanel and the cell with the given coordinates is visible.
-
scrollToColumn
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:
columnIdentifier- the column identifier
-
scrollToCoordinate
Scrolls to the given coordinate. Has no effect if this table is not contained in a scrollpanel.- Parameters:
row- the rowcolumn- the columncenterOnScroll- 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 table data as a TAB delimited string, with header, to the clipboard. -
export
- Returns:
- a
FilterTable.Exportinstance for exporting the table model data
-
createSelectColumnsControl
- Returns:
- a control for showing the column selection dialog
-
createToggleColumnsControls
- Returns:
- Controls containing
ToggleControls for showing/hiding columns.
-
createResetColumnsControl
- Returns:
- a Control for resetting the columns to their original location and visibility
-
createSelectAutoResizeModeControl
- Returns:
- a Control for selecting the auto-resize mode
-
createToggleAutoResizeModelControls
- Returns:
- Controls containing
ToggleControls for choosing the auto resize mode.
-
createSingleSelectionModeControl
- Returns:
- a ToggleControl for toggling the table selection mode (single or multiple)
-
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
-
doubleClickEvent
- Returns:
- an observer notified each time the table is double-clicked
-
summaryValues
public static <T extends Number,C> is.codion.common.model.table.ColumnSummaryModel.SummaryValues<T> summaryValues(C columnIdentifier, is.codion.swing.common.model.component.table.FilterTableModel<?, C> tableModel, Format format) Instantiates a newColumnSummaryModel.SummaryValuesinstance.- Type Parameters:
T- the column value typeC- the column identifier type- Parameters:
columnIdentifier- the column identifiertableModel- the table modelformat- the format- Returns:
- a new
ColumnSummaryModel.SummaryValuesinstance
-
builder
public static <R,C> FilterTable.Builder<R,C> builder(is.codion.swing.common.model.component.table.FilterTableModel<R, C> tableModel, List<FilterTableColumn<C>> columns) Instantiates a newFilterTable.Builderusing the given model- Type Parameters:
R- the type representing rowsC- the type used to identify columns- Parameters:
tableModel- the table modelcolumns- the columns- Returns:
- a new
FilterTable.Builderinstance
-
createDefaultTableHeader
- Overrides:
createDefaultTableHeaderin classJTable
-