java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
is.codion.swing.framework.ui.EntityTablePanel
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
The EntityTablePanel is a UI class based on the EntityTableModel class.
It consists of a JTable as well as filtering/searching and summary panels.
The default layout is as follows
____________________________________________________ | conditionPanel | |____________________________________________________| | | | | | | | | | entityTable (FilterTable) | | | | | | | | | |____________________________________________________| | summaryPanel | |____________________________________________________| | southPanel | |____________________________________________________|The condition and summary panels can be hidden Note that
initialize()
must be called to initialize this panel before displaying it.- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Specifies how auto-resize-mode selection is presented.static enum
Specifies how column selection is presented.static final class
Contains configuration settings for aEntityTablePanel
which must be set before the panel is initialized.static final class
The Controls available in aEntityTablePanel
static enum
Specifies how attribute selection is presented for editing the selected records.static enum
Specifies the refresh button visibility.Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorDescriptionEntityTablePanel
(SwingEntityTableModel tableModel) Instantiates a new EntityTablePanel instanceEntityTablePanel
(SwingEntityTableModel tableModel, EntityEditPanel editPanel) Instantiates a new EntityTablePanel instanceEntityTablePanel
(SwingEntityTableModel tableModel, EntityEditPanel editPanel, Consumer<EntityTablePanel.Config> config) Instantiates a new EntityTablePanel instanceEntityTablePanel
(SwingEntityTableModel tableModel, Consumer<EntityTablePanel.Config> config) Instantiates a new EntityTablePanel instance -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addPopupMenuControls
(Controls additionalPopupMenuControls) final void
addToolBarControls
(Controls additionalToolBarControls) void
Applies any user preferences previously saved viasavePreferences()
final <T extends TableConditionPanel<Attribute<?>>>
Tprotected final void
configurePopupMenu
(Consumer<Controls.Layout> popupMenuLayout) Configures the popup menu controls layout.
Note that theControls.Layout
instance has pre-configured defaults, which must be cleared in order to start with an empty configuration.protected final void
configureToolBar
(Consumer<Controls.Layout> toolBarLayout) Configures the toolbar controls layout.
Note that theControls.Layout
instance has pre-configured defaults, which must be cleared in order to start with an empty configuration.protected final boolean
control
(ControlKey<T> controlKey) final boolean
Deletes the entities selected in the underlying table model without asking for confirmation.final boolean
Deletes the entities selected in the underlying table model after asking for confirmation using the confirmer specified viaEntityTablePanel.Config.deleteConfirmer(Confirmer)
protected final void
displayException
(Exception exception) Displays the exception in a dialog, with the dialog owner as the current focus owner or this panel if none is available.protected <T> EntityDialogs.EditAttributeDialogBuilder<T>
editDialogBuilder
(Attribute<T> attribute) Override to customize the edit dialog used when multiple entities are edited.protected final <T extends EntityEditPanel>
Tfinal void
Displays a selection dialog for selecting an attribute to edit and retrieves a new value via input dialog and performs an update on the selected entities assigning the value to the attributefinal void
editSelected
(Attribute<?> attributeToEdit) Retrieves a new value via input dialog and performs an update on the selected entities assigning the value to the attributefinal EntityTablePanel
Initializes the UI, while presenting a wait cursor to the user.protected JPanel
Initializes the south panel, override and return null for no south panel.protected void
layoutPanel
(JComponent tableComponent, JPanel southPanel) This method simply addstablePanel
at location BorderLayout.CENTER and, if non-null, the givensouthPanel
to theBorderLayout.SOUTH
location.protected void
onException
(Exception exception) Propagates the exception toonValidationException(ValidationException)
oronReferentialIntegrityException(ReferentialIntegrityException)
depending on type, otherwise displays the exception.protected void
Called when aReferentialIntegrityException
occurs during a delete operation on the selected entities.protected void
onValidationException
(ValidationException exception) Displays the exception message.final State
Specifies whether the current sort order is used as a basis for the query order by clause.final State
Returns whether the values of hidden columns are included when querying datavoid
Saves user preferencesprotected void
Override to setup any custom controls.protected void
Sets up the keyboard shortcuts.final State
final FilterTable<Entity,
Attribute<?>> table()
final <T extends SwingEntityTableModel>
Tfinal String
toString()
void
updateUI()
protected String
Returns the key used to identify user preferences for this table panel, that is column positions, widths and such.final void
Displays a dialog containing tables of entities depending on the selected entities via non-soft foreign keysMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, 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, 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, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, 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, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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, validateTree
Methods 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, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
EntityTablePanel
Instantiates a new EntityTablePanel instance- Parameters:
tableModel
- the SwingEntityTableModel instance
-
EntityTablePanel
Instantiates a new EntityTablePanel instance- Parameters:
tableModel
- the SwingEntityTableModel instanceconfig
- provides access to the table panel configuration
-
EntityTablePanel
Instantiates a new EntityTablePanel instance- Parameters:
tableModel
- the SwingEntityTableModel instanceeditPanel
- the edit panel
-
EntityTablePanel
public EntityTablePanel(SwingEntityTableModel tableModel, EntityEditPanel editPanel, Consumer<EntityTablePanel.Config> config) Instantiates a new EntityTablePanel instance- Parameters:
tableModel
- the SwingEntityTableModel instanceeditPanel
- the edit panelconfig
- provides access to the table panel configuration
-
-
Method Details
-
updateUI
public void updateUI() -
table
- Returns:
- the table
- Throws:
IllegalStateException
- in case this method is called during configuration
-
tableModel
- Type Parameters:
T
- the table model type- Returns:
- the EntityTableModel used by this EntityTablePanel
-
conditions
- Type Parameters:
T
- the condition panel type- Returns:
- the condition panel
- Throws:
IllegalStateException
- in case a condition panel is not available- See Also:
-
summaryPanelVisible
- Returns:
- the
State
controlling whether the summary panel is visible
-
orderQueryBySortOrder
Specifies whether the current sort order is used as a basis for the query order by clause. Note that this only applies to column attributes.- Returns:
- the
State
controlling whether the current sort order should be used as a basis for the query order by clause
-
queryHiddenColumns
Returns whether the values of hidden columns are included when querying data- Returns:
- the
State
controlling whether the values of hidden columns are included when querying data
-
addPopupMenuControls
- Parameters:
additionalPopupMenuControls
- a set of controls to add to the table popup menu- Throws:
IllegalStateException
- in case this panel has already been initialized
-
addToolBarControls
- Parameters:
additionalToolBarControls
- a set of controls to add to the table toolbar menu- Throws:
IllegalStateException
- in case this panel has already been initialized
-
toString
-
control
Returns aValue
containing the control associated withcontrolKey
, an emptyValue
if no such control is available.- Type Parameters:
T
- the control type- Parameters:
controlKey
- the control key- Returns:
- the
Value
containing the control associated withcontrolKey
-
editSelected
public final void editSelected()Displays a selection dialog for selecting an attribute to edit and retrieves a new value via input dialog and performs an update on the selected entities assigning the value to the attribute -
editSelected
Retrieves a new value via input dialog and performs an update on the selected entities assigning the value to the attribute- Parameters:
attributeToEdit
- the attribute which value to edit- See Also:
-
viewDependencies
public final void viewDependencies()Displays a dialog containing tables of entities depending on the selected entities via non-soft foreign keys -
deleteSelectedWithConfirmation
public final boolean deleteSelectedWithConfirmation()Deletes the entities selected in the underlying table model after asking for confirmation using the confirmer specified viaEntityTablePanel.Config.deleteConfirmer(Confirmer)
- Returns:
- true if the delete operation was successful
- See Also:
-
deleteSelected
public final boolean deleteSelected()Deletes the entities selected in the underlying table model without asking for confirmation.- Returns:
- true if the delete operation was successful
-
savePreferences
public void savePreferences()Saves user preferences- See Also:
-
applyPreferences
public void applyPreferences()Applies any user preferences previously saved viasavePreferences()
-
initialize
Initializes the UI, while presenting a wait cursor to the user. Note that calling this method more than once has no effect.- Returns:
- this EntityTablePanel instance
-
setupControls
protected void setupControls()Override to setup any custom controls. This default implementation is empty. This method is called after all standard controls have been initialized.- See Also:
-
initializeSouthPanel
Initializes the south panel, override and return null for no south panel. Not called if the south panel has been disabled viaEntityTablePanel.Config.includeSouthPanel(boolean)
.- Returns:
- the south panel, or null if no south panel should be included
- See Also:
-
setupKeyboardActions
protected void setupKeyboardActions()Sets up the keyboard shortcuts.- See Also:
-
EntityTablePanel.ControlKeys.REFRESH
EntityTablePanel.ControlKeys.REQUEST_TABLE_FOCUS
EntityTablePanel.ControlKeys.SELECT_CONDITION
EntityTablePanel.ControlKeys.TOGGLE_CONDITION_VIEW
EntityTablePanel.ControlKeys.SELECT_FILTER
EntityTablePanel.ControlKeys.TOGGLE_FILTER_VIEW
EntityTablePanel.ControlKeys.PRINT
EntityTablePanel.ControlKeys.ADD
EntityTablePanel.ControlKeys.EDIT
EntityTablePanel.ControlKeys.EDIT_SELECTED_ATTRIBUTE
EntityTablePanel.ControlKeys.DELETE
EntityTablePanel.ControlKeys.MOVE_SELECTION_UP
EntityTablePanel.ControlKeys.MOVE_SELECTION_DOWN
EntityTablePanel.ControlKeys.DISPLAY_ENTITY_MENU
EntityTablePanel.ControlKeys.DISPLAY_POPUP_MENU
-
configureToolBar
Configures the toolbar controls layout.
Note that theControls.Layout
instance has pre-configured defaults, which must be cleared in order to start with an empty configuration.configureToolBar(layout -> layout.clear() .standard(ControlKeys.REFRESH) .separator() .control(createCustomControl()) .separator() .defaults())
ControlKeys#TOGGLE_SUMMARY_PANEL
ControlKeys#TOGGLE_CONDITION_VIEW
ControlKeys#TOGGLE_FILTER_VIEW
- Separator
ControlKeys#ADD
(If an EditPanel is available)ControlKeys#EDIT
(If an EditPanel is available)ControlKeys#DELETE
- Separator
ControlKeys#EDIT_SELECTED_ATTRIBUTE
- Separator
ControlKeys#PRINT
- Separator
ControlKeys#ADDITIONAL_TOOLBAR_CONTROLS
- Parameters:
toolBarLayout
- provides access to the toolbar configuration- See Also:
-
configurePopupMenu
Configures the popup menu controls layout.
Note that theControls.Layout
instance has pre-configured defaults, which must be cleared in order to start with an empty configuration.configurePopupMenu(layout -> layout.clear() .standard(ControlKeys.REFRESH) .separator() .control(createCustomControl()) .separator() .defaults())
ControlKeys#REFRESH
ControlKeys#CLEAR
- Separator
ControlKeys#ADD
(If an EditPanel is available)ControlKeys#EDIT
(If an EditPanel is available)ControlKeys#DELETE
- Separator
ControlKeys#EDIT_SELECTED_ATTRIBUTE
orControlKeys#EDIT_ATTRIBUTE_CONTROLS
- Separator
ControlKeys#VIEW_DEPENDENCIES
- Separator
ControlKeys#ADDITIONAL_POPUP_MENU_CONTROLS
- Separator
ControlKeys#PRINT_CONTROLS
- Separator
ControlKeys#COLUMN_CONTROLS
- Separator
ControlKeys#SELECTION_MODE
- Separator
ControlKeys#CONDITION_CONTROLS
- Separator
ControlKeys#FILTER_CONTROLS
- Separator
ControlKeys#COPY_CONTROLS
- Parameters:
popupMenuLayout
- provides access to the popup menu layout- See Also:
-
editPanel
- Type Parameters:
T
- the edit panel type- Returns:
- the edit panel
- Throws:
IllegalStateException
- in case no edit panel is available
-
layoutPanel
This method simply addstablePanel
at location BorderLayout.CENTER and, if non-null, the givensouthPanel
to theBorderLayout.SOUTH
location. By overriding this method you can override the default layout.- Parameters:
tableComponent
- the component containing the table, condition and summary panelsouthPanel
- the south toolbar panel, null if not required- See Also:
-
onException
Propagates the exception toonValidationException(ValidationException)
oronReferentialIntegrityException(ReferentialIntegrityException)
depending on type, otherwise displays the exception.- Parameters:
exception
- the exception to handle- See Also:
-
onReferentialIntegrityException
Called when aReferentialIntegrityException
occurs during a delete operation on the selected entities. If the referential error handling isReferentialIntegrityErrorHandling.DISPLAY_DEPENDENCIES
, the dependencies of the entities involved are displayed to the user, otherwisedisplayException(Exception)
is called.- Parameters:
exception
- the exception- See Also:
-
onValidationException
Displays the exception message.- Parameters:
exception
- the exception
-
editDialogBuilder
Override to customize the edit dialog used when multiple entities are edited.- Type Parameters:
T
- the attribute type- Parameters:
attribute
- the attribute to edit- Returns:
- a edit dialog builder
-
userPreferencesKey
Returns the key used to identify user preferences for this table panel, that is column positions, widths and such. The default implementation is:return tableModel().getClass().getSimpleName() + "-" + entityType();
- Returns:
- the key used to identify user preferences for this table panel
-
displayException
Displays the exception in a dialog, with the dialog owner as the current focus owner or this panel if none is available.- Parameters:
exception
- the exception to display
-
confirmDelete
protected final boolean confirmDelete()- Returns:
- true if confirmed
- See Also:
-