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()- See Also:
-
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.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 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_OFFstatic final PropertyValue<Boolean> Specifies whether columns can be rearranged Value type: Boolean Default value: truestatic final PropertyValue<Boolean> Specifies whether columns can be resized Value type: Boolean Default value: truestatic final PropertyValue<Boolean> Specifies whether the table resizes the row being edited to fit the editor component.Fields 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'.builder()booleancellVisible(int row, int column) Returns true if the given cell is visible.voidCopies the contents of the selected cell to the clipboard.voidCopies the contents of the selected column cells to the clipboard.voidCopies the table data as a TAB delimited string, with header, to the clipboard.protected JTableHeaderTheActionis only triggered if enabled.filters()getModel()booleanisCellEditable(int row, int column) model()voidscrollToColumn(C identifier) Scrolls horizontally so that the column identified by the given identifier becomes visible.voidscrollToRowColumn(int row, int column, FilterTable.CenterOnScroll centerOnScroll) Scrolls to the given coordinate.search()voidDisplays 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) sortable()static <T extends Number,C>
SummaryModel.SummaryValues<T> summaryValues(C identifier, FilterTableModel<?, C> tableModel, Format format) Instantiates a newSummaryModel.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, 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
-
COLUMN_REORDERING
Specifies whether columns can be rearranged- Value type: Boolean
- Default value: true
-
COLUMN_RESIZING
Specifies whether columns can be resized- Value type: Boolean
- Default value: true
-
RESIZE_ROW_TO_FIT_EDITOR
Specifies whether the table resizes the row being edited to fit the editor component. Only applicable toFilterTableCellEditor.- 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
-
isCellEditable
public boolean isCellEditable(int row, int column) - Overrides:
isCellEditablein classJTable
-
setColumnModel
- Overrides:
setColumnModelin classJTable
-
setSelectionModel
- Overrides:
setSelectionModelin classJTable
-
filters
- Returns:
- the filter
TableConditionPanel
-
search
- Returns:
- the search model
-
summaries
- Returns:
- the summary model
-
searchField
- Returns:
- the search field
-
doubleClick
The
Actionis only triggered if enabled.The
ActionEventpropagated when this action is performed, contains the associatedMouseEventas source.public void actionPerformed(ActionEvent event) { MouseEvent mouseEvent = (MouseEvent) event.getSource(); Point location = mouseEvent.getLocationOnScreen(); // ... }- Returns:
- the
Valuecontrolling the action to perform when a double click is performed on the table
-
sortable
- Returns:
- the
Statecontrolling whether sorting via the table header is enabled
-
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:
identifier- the column identifier
-
scrollToRowColumn
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. -
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
- 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
-
createToggleAutoResizeModeControls
- Returns:
- Controls containing
ToggleControls for choosing the auto resize mode.
-
createSingleSelectionControl
- Returns:
- a ToggleControl controlling whether single selection mode is enabled
-
createCopyCellControl
- Returns:
- a Control for copying the contents of the selected cell
-
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
- 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 newSummaryModel.SummaryValuesinstance.- Type Parameters:
T- the column value typeC- the column identifier type- Parameters:
identifier- the column identifiertableModel- the table modelformat- the format- Returns:
- a new
SummaryModel.SummaryValuesinstance
-
builder
- Returns:
- a
FilterTable.Builder.ModelStepinstance
-
createDefaultTableHeader
- Overrides:
createDefaultTableHeaderin classJTable
-