- 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
public class EntityTablePanel extends JPanel
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 (FilteredTable) | | | | | | | | | |____________________________________________________| | summaryPanel | |____________________________________________________| | southPanel | |____________________________________________________|
The condition and summary panels can be hidden Note thatinitializePanel()
must be called to initialize this panel before displaying it.- See Also:
EntityTableModel
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EntityTablePanel.ColumnSelection
Specifies how column selection is presented.static class
EntityTablePanel.ControlCode
The standard controls available-
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 Modifier and Type Field Description static PropertyValue<Boolean>
ALLOW_COLUMN_REORDERING
Specifies whether columns can be rearranged in tables
Value type: Boolean
Default value: truestatic PropertyValue<EntityTablePanel.ColumnSelection>
COLUMN_SELECTION
Specifies how column selection is presented to the user.
Value type:EntityTablePanel.ColumnSelection
Default value:EntityTablePanel.ColumnSelection.DIALOG
static PropertyValue<Boolean>
CONDITION_PANEL_VISIBLE
Specifies whether table condition panels should be visible or not by default
Value type: Boolean
Default value: falsestatic PropertyValue<Boolean>
INCLUDE_CLEAR_CONTROL
Specifies whether to include a 'Clear' control in the popup menu.
Value type: Boolean
Default value: falsestatic PropertyValue<Boolean>
INCLUDE_ENTITY_MENU
Specifies whether to include aEntityPopupMenu
on this table, triggered with CTRL-ALT-V.
Value type: Boolean
Default value: truestatic PropertyValue<Boolean>
REFRESH_TOOLBAR_ALWAYS_VISIBLE
Specifies whether the refresh button toolbar should always be visible or hidden when the condition panel is not visible
Value type: Boolean
Default value: falsestatic PropertyValue<Integer>
TABLE_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-
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
Constructors Constructor Description EntityTablePanel(SwingEntityTableModel tableModel)
Initializes a new EntityTablePanel instanceEntityTablePanel(SwingEntityTableModel tableModel, AbstractEntityTableConditionPanel conditionPanel)
Initializes a new EntityTablePanel instance
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPopupControls(Controls additionalPopupControls)
void
addToolBarControls(Controls additionalToolBarControls)
AbstractEntityTableConditionPanel
conditionPanel()
protected boolean
confirmDelete()
Called before delete is performed, if true is returned the delete action is performed otherwise it is canceledprotected ConfirmationMessage
confirmDeleteMessages()
boolean
containsControl(EntityTablePanel.ControlCode controlCode)
Control
createClearControl()
Control
createDeleteSelectedControl()
static EntityTablePanel
createEntityTablePanel(SwingEntityTableModel tableModel)
Creates an entity table panel based on the given table model.static EntityTablePanel
createEntityTablePanel(Collection<Entity> entities, EntityConnectionProvider connectionProvider)
Creates a static entity table panel showing the given entities, note that this table panel will provide a popup menu for updating and deleting the selected entities unless the underlying entities are read-only.protected Controls
createPopupControls(List<Controls> additionalPopupControls)
Creates a Controls instance containing the controls to include in the table popup menu.protected Controls
createPrintControls()
Control
createPrintTableControl()
static EntityTablePanel
createReadOnlyEntityTablePanel(Collection<Entity> entities, EntityConnectionProvider connectionProvider)
Creates a static read-only entity table panel showing the given entitiesControl
createRefreshControl()
protected JToolBar
createSouthToolBar()
Creates the south panel toolbar, by default based oncreateToolBarControls(List)
protected <T> TableCellEditor
createTableCellEditor(Property<T> property)
Creates a TableCellEditor for the given property, returns null if no editor is availableprotected <T> TableCellRenderer
createTableCellRenderer(Property<T> property)
Creates a TableCellRenderer to use for the given property in this EntityTablePanelprotected Controls
createToolBarControls(List<Controls> additionalToolBarControls)
Controls
createUpdateSelectedControls()
Creates aControls
containing controls for updating the value of a single property for the selected entities.Control
createViewDependenciesControl()
void
deleteWithConfirmation()
Deletes the entities selected in the underlying table modelvoid
displayException(Throwable exception)
Displays the exception in a dialogvoid
excludeFromUpdateMenu(Attribute<?> attribute)
Specifies that the given property should be excluded from the update selected entities menu.Control
getControl(EntityTablePanel.ControlCode controlCode)
EntityTablePanel
initializePanel()
Initializes the UI, while presenting a wait cursor to the user.protected JPanel
initializeSouthPanel()
Initializes the south panel, override and return null for no south panel.boolean
isConditionPanelVisible()
boolean
isRefreshToolbarAlwaysVisible()
boolean
isShowRefreshingProgressBar()
boolean
isSummaryPanelVisible()
protected void
layoutPanel(JPanel tablePanel, JPanel southPanel)
This method simply addstablePanel
at location BorderLayout.CENTER and, if non-null, the givensouthPanel
to theBorderLayout.SOUTH
location.void
onException(Throwable exception)
Handles the given exception, simply displays the error message to the user by default.void
onReferentialIntegrityException(ReferentialIntegrityException exception, List<Entity> entities)
Handles the given exception.void
printTable()
Prints the tablevoid
selectConditionPanel()
Allows the user to select on of the available search condition fieldsvoid
setColumnSelection(EntityTablePanel.ColumnSelection columnSelection)
void
setConditionPanelVisible(boolean visible)
Hides or shows the column condition panel for this EntityTablePanelprotected void
setControl(EntityTablePanel.ControlCode controlCode, Control control)
Associatescontrol
withcontrolCode
void
setIncludeClearControl(boolean includeClearControl)
void
setIncludeConditionPanel(boolean includeConditionPanel)
void
setIncludePopupMenu(boolean includePopupMenu)
void
setIncludeSelectionModeControl(boolean includeSelectionModeControl)
void
setIncludeSouthPanel(boolean includeSouthPanel)
void
setReferentialIntegrityErrorHandling(ReferentialIntegrityErrorHandling referentialIntegrityErrorHandling)
void
setRefreshToolbarAlwaysVisible(boolean refreshToolbarAlwaysVisible)
void
setShowRefreshingProgressBar(boolean showRefreshingProgressBar)
void
setSummaryPanelVisible(boolean visible)
Hides or shows the column summary panel for this EntityTablePanel, if no summary panel is available calling this method has no effect.<T,A extends Attribute<T>,C extends JComponent>
voidsetTableCellEditorComponentFactory(A attribute, EntityComponentFactory<T,A,C> componentFactory)
Sets the table cell editor component factory for the given attribute.<T,A extends Attribute<T>,C extends JComponent>
voidsetUpdateSelectedComponentFactory(A attribute, EntityComponentFactory<T,A,C> componentFactory)
Sets the component factory for the given attribute, used when updating entities viaupdateSelectedEntities(Property)
.protected void
setupKeyboardActions()
Sets up the default keyboard actions.static void
showDependenciesDialog(Collection<Entity> entities, EntityConnectionProvider connectionProvider, JComponent dialogParent)
Shows a dialog containing the entities depending on the given entities.static void
showDependenciesDialog(Collection<Entity> entities, EntityConnectionProvider connectionProvider, JComponent dialogParent, String noDependenciesMessage)
Shows a dialog containing the entities depending on the given entities.FilteredTable<Entity,Attribute<?>,SwingEntityTableModel>
table()
SwingEntityTableModel
tableModel()
void
toggleConditionPanel()
Toggles the condition panel through the states hidden, visible and in case it can, advancedString
toString()
<T> void
updateSelectedEntities(Property<T> propertyToUpdate)
Retrieves a new property value via input dialog and performs an update on the selected entitiesvoid
updateUI()
void
viewSelectionDependencies()
Shows a dialog containing lists of entities depending on the selected entities via foreign key-
Methods 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
-
-
-
-
Field Detail
-
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
-
CONDITION_PANEL_VISIBLE
public static final PropertyValue<Boolean> CONDITION_PANEL_VISIBLE
Specifies whether table condition panels should be visible or not by default
Value type: Boolean
Default value: false
-
TABLE_AUTO_RESIZE_MODE
public static final PropertyValue<Integer> TABLE_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
-
INCLUDE_ENTITY_MENU
public static final PropertyValue<Boolean> INCLUDE_ENTITY_MENU
Specifies whether to include aEntityPopupMenu
on this table, triggered with CTRL-ALT-V.
Value type: Boolean
Default value: true
-
INCLUDE_CLEAR_CONTROL
public static final PropertyValue<Boolean> INCLUDE_CLEAR_CONTROL
Specifies whether to include a 'Clear' control in the popup menu.
Value type: Boolean
Default value: false
-
REFRESH_TOOLBAR_ALWAYS_VISIBLE
public static final PropertyValue<Boolean> REFRESH_TOOLBAR_ALWAYS_VISIBLE
Specifies whether the refresh button toolbar should always be visible or hidden when the condition panel is not visible
Value type: Boolean
Default value: false
-
COLUMN_SELECTION
public static final PropertyValue<EntityTablePanel.ColumnSelection> COLUMN_SELECTION
Specifies how column selection is presented to the user.
Value type:EntityTablePanel.ColumnSelection
Default value:EntityTablePanel.ColumnSelection.DIALOG
-
-
Constructor Detail
-
EntityTablePanel
public EntityTablePanel(SwingEntityTableModel tableModel)
Initializes a new EntityTablePanel instance- Parameters:
tableModel
- the EntityTableModel instance
-
EntityTablePanel
public EntityTablePanel(SwingEntityTableModel tableModel, AbstractEntityTableConditionPanel conditionPanel)
Initializes a new EntityTablePanel instance- Parameters:
tableModel
- the EntityTableModel instanceconditionPanel
- the condition panel, if any
-
-
Method Detail
-
table
public final FilteredTable<Entity,Attribute<?>,SwingEntityTableModel> table()
- Returns:
- the filtered table instance
-
tableModel
public final SwingEntityTableModel tableModel()
- Returns:
- the EntityTableModel used by this EntityTablePanel
-
excludeFromUpdateMenu
public final void excludeFromUpdateMenu(Attribute<?> attribute)
Specifies that the given property should be excluded from the update selected entities menu.- Parameters:
attribute
- the id of the property to exclude from the update menu- Throws:
IllegalStateException
- in case the panel has already been initialized
-
addPopupControls
public final void addPopupControls(Controls additionalPopupControls)
- Parameters:
additionalPopupControls
- a set of controls to add to the table popup menu- Throws:
IllegalStateException
- in case the panel has already been initialized- See Also:
initializePanel()
-
addToolBarControls
public final void addToolBarControls(Controls additionalToolBarControls)
- Parameters:
additionalToolBarControls
- a set of controls to add to the table toolbar menu- Throws:
IllegalStateException
- in case the panel has already been initialized- See Also:
initializePanel()
-
setIncludeSouthPanel
public final void setIncludeSouthPanel(boolean includeSouthPanel)
- Parameters:
includeSouthPanel
- true if the south panel should be included- Throws:
IllegalStateException
- in case the panel has already been initialized- See Also:
initializeSouthPanel()
,initializePanel()
-
setIncludeConditionPanel
public final void setIncludeConditionPanel(boolean includeConditionPanel)
- Parameters:
includeConditionPanel
- true if the condition panel should be included- Throws:
IllegalStateException
- in case the panel has already been initialized- See Also:
initializePanel()
-
setIncludePopupMenu
public final void setIncludePopupMenu(boolean includePopupMenu)
- Parameters:
includePopupMenu
- true if a popup menu should be included- Throws:
IllegalStateException
- in case the panel has already been initialized- See Also:
initializePanel()
-
setIncludeClearControl
public final void setIncludeClearControl(boolean includeClearControl)
- Parameters:
includeClearControl
- true if a 'Clear' control should be included in the popup menu- Throws:
IllegalStateException
- in case the panel has already been initialized- See Also:
initializePanel()
-
setIncludeSelectionModeControl
public final void setIncludeSelectionModeControl(boolean includeSelectionModeControl)
- Parameters:
includeSelectionModeControl
- true if a 'Single Selection' control should be included in the popup menu- Throws:
IllegalStateException
- in case the panel has already been initialized- See Also:
initializePanel()
-
setColumnSelection
public final void setColumnSelection(EntityTablePanel.ColumnSelection columnSelection)
- Parameters:
columnSelection
- specifies how columns are selected
-
isRefreshToolbarAlwaysVisible
public final boolean isRefreshToolbarAlwaysVisible()
- Returns:
- true if the refresh toolbar should always be visible
-
setRefreshToolbarAlwaysVisible
public final void setRefreshToolbarAlwaysVisible(boolean refreshToolbarAlwaysVisible)
- Parameters:
refreshToolbarAlwaysVisible
- true if the refresh toolbar should always be visible, instead of being hidden when the condition panel is not visible
-
isShowRefreshingProgressBar
public final boolean isShowRefreshingProgressBar()
- Returns:
- true if a progress bar is shown while the model is refreshing
-
setShowRefreshingProgressBar
public final void setShowRefreshingProgressBar(boolean showRefreshingProgressBar)
- Parameters:
showRefreshingProgressBar
- true if an indeterminate progress bar should be shown while the model is refreshing
-
setConditionPanelVisible
public final void setConditionPanelVisible(boolean visible)
Hides or shows the column condition panel for this EntityTablePanel- Parameters:
visible
- if true the condition panel is shown, if false it is hidden
-
isConditionPanelVisible
public final boolean isConditionPanelVisible()
- Returns:
- true if the condition panel is visible, false if it is hidden
-
setUpdateSelectedComponentFactory
public final <T,A extends Attribute<T>,C extends JComponent> void setUpdateSelectedComponentFactory(A attribute, EntityComponentFactory<T,A,C> componentFactory)
Sets the component factory for the given attribute, used when updating entities viaupdateSelectedEntities(Property)
.- Type Parameters:
T
- the value typeA
- the attribute typeC
- the component type- Parameters:
attribute
- the attributecomponentFactory
- the component factory
-
setTableCellEditorComponentFactory
public final <T,A extends Attribute<T>,C extends JComponent> void setTableCellEditorComponentFactory(A attribute, EntityComponentFactory<T,A,C> componentFactory)
Sets the table cell editor component factory for the given attribute.- Type Parameters:
T
- the value typeA
- the attribute typeC
- the component type- Parameters:
attribute
- the attributecomponentFactory
- the component factory
-
conditionPanel
public final AbstractEntityTableConditionPanel conditionPanel()
- Returns:
- the condition panel being used by this EntityTablePanel
-
toggleConditionPanel
public final void toggleConditionPanel()
Toggles the condition panel through the states hidden, visible and in case it can, advanced
-
selectConditionPanel
public final void selectConditionPanel()
Allows the user to select on of the available search condition fields
-
setSummaryPanelVisible
public final void setSummaryPanelVisible(boolean visible)
Hides or shows the column summary panel for this EntityTablePanel, if no summary panel is available calling this method has no effect.- Parameters:
visible
- if true then the summary panel is shown, if false it is hidden
-
isSummaryPanelVisible
public final boolean isSummaryPanelVisible()
- Returns:
- true if the column summary panel is visible, false if it is hidden
-
setReferentialIntegrityErrorHandling
public final void setReferentialIntegrityErrorHandling(ReferentialIntegrityErrorHandling referentialIntegrityErrorHandling)
- Parameters:
referentialIntegrityErrorHandling
- the action to take on a referential integrity error during delete
-
containsControl
public final boolean containsControl(EntityTablePanel.ControlCode controlCode)
- Parameters:
controlCode
- the control code- Returns:
- true if this table panel contains the given control
-
getControl
public final Control getControl(EntityTablePanel.ControlCode controlCode)
- Parameters:
controlCode
- the control code- Returns:
- the control associated with
controlCode
- Throws:
IllegalArgumentException
- in case no control is associated with the given control code- See Also:
containsControl(ControlCode)
-
createUpdateSelectedControls
public final Controls createUpdateSelectedControls()
Creates aControls
containing controls for updating the value of a single property for the selected entities. These controls are enabled as long as the selection is not empty andEntityEditModel.updateEnabledObserver()
is enabled.- Returns:
- controls containing a control for each updatable property in the underlying entity, for performing an update on the selected entities
- Throws:
IllegalStateException
- in case the underlying edit model is read only or updating is not enabled- See Also:
excludeFromUpdateMenu(Attribute)
,EntityEditModel.updateEnabledObserver()
-
createViewDependenciesControl
public final Control createViewDependenciesControl()
- Returns:
- a control for showing the dependencies dialog
-
createDeleteSelectedControl
public final Control createDeleteSelectedControl()
- Returns:
- a control for deleting the selected entities
- Throws:
IllegalStateException
- in case the underlying model is read only or if deleting is not enabled
-
createPrintTableControl
public final Control createPrintTableControl()
- Returns:
- a control for printing the table
-
createRefreshControl
public final Control createRefreshControl()
- Returns:
- a Control for refreshing the underlying table data
-
createClearControl
public final Control createClearControl()
- Returns:
- a Control for clearing the underlying table model, that is, removing all rows
-
updateSelectedEntities
public final <T> void updateSelectedEntities(Property<T> propertyToUpdate)
Retrieves a new property value via input dialog and performs an update on the selected entities- Type Parameters:
T
- the property type- Parameters:
propertyToUpdate
- the property to update- See Also:
setUpdateSelectedComponentFactory(Attribute, EntityComponentFactory)
-
viewSelectionDependencies
public final void viewSelectionDependencies()
Shows a dialog containing lists of entities depending on the selected entities via foreign key
-
deleteWithConfirmation
public final void deleteWithConfirmation()
Deletes the entities selected in the underlying table model- See Also:
confirmDelete()
-
printTable
public final void printTable() throws PrinterException
Prints the table- Throws:
PrinterException
- in case of a print exception- See Also:
JTable.print()
-
onReferentialIntegrityException
public void onReferentialIntegrityException(ReferentialIntegrityException exception, List<Entity> entities)
Handles the given exception. If the referential error handling isReferentialIntegrityErrorHandling.DISPLAY_DEPENDENCIES
, the dependencies of the given entity are displayed to the user, otherwiseonException(Throwable)
is called.- Parameters:
exception
- the exceptionentities
- the entities causing the exception- See Also:
setReferentialIntegrityErrorHandling(ReferentialIntegrityErrorHandling)
-
onException
public void onException(Throwable exception)
Handles the given exception, simply displays the error message to the user by default.- Parameters:
exception
- the exception to handle- See Also:
displayException(Throwable)
-
displayException
public final void displayException(Throwable exception)
Displays the exception in a dialog- Parameters:
exception
- the exception to display
-
showDependenciesDialog
public static void showDependenciesDialog(Collection<Entity> entities, EntityConnectionProvider connectionProvider, JComponent dialogParent)
Shows a dialog containing the entities depending on the given entities.- Parameters:
entities
- the entities for which to display dependenciesconnectionProvider
- the connection providerdialogParent
- the dialog parent
-
showDependenciesDialog
public static void showDependenciesDialog(Collection<Entity> entities, EntityConnectionProvider connectionProvider, JComponent dialogParent, String noDependenciesMessage)
Shows a dialog containing the entities depending on the given entities.- Parameters:
entities
- the entities for which to display dependenciesconnectionProvider
- the connection providerdialogParent
- the dialog parentnoDependenciesMessage
- the message to show in case of no dependencies
-
createReadOnlyEntityTablePanel
public static EntityTablePanel createReadOnlyEntityTablePanel(Collection<Entity> entities, EntityConnectionProvider connectionProvider)
Creates a static read-only entity table panel showing the given entities- Parameters:
entities
- the entities to show in the panelconnectionProvider
- the EntityConnectionProvider, in case the returned panel should require one- Returns:
- a static EntityTablePanel showing the given entities
-
createEntityTablePanel
public static EntityTablePanel createEntityTablePanel(Collection<Entity> entities, EntityConnectionProvider connectionProvider)
Creates a static entity table panel showing the given entities, note that this table panel will provide a popup menu for updating and deleting the selected entities unless the underlying entities are read-only.- Parameters:
entities
- the entities to show in the panelconnectionProvider
- the EntityConnectionProvider, in case the returned panel should require one- Returns:
- a static EntityTablePanel showing the given entities
-
createEntityTablePanel
public static EntityTablePanel createEntityTablePanel(SwingEntityTableModel tableModel)
Creates an entity table panel based on the given table model. If the table model is not read only, a popup menu for updating or deleting the selected entities is provided.- Parameters:
tableModel
- the table model- Returns:
- an entity table panel based on the given model
-
initializePanel
public final EntityTablePanel initializePanel()
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
-
initializeSouthPanel
protected JPanel initializeSouthPanel()
Initializes the south panel, override and return null for no south panel. Not called if the south panel has been disabled viasetIncludeSouthPanel(boolean)
.- Returns:
- the south panel, or null if no south panel should be included
-
setupKeyboardActions
protected void setupKeyboardActions()
Sets up the default keyboard actions. CTRL-T transfers focus to the table in case one is available, CTR-S opens a select search condition panel dialog, in case one is available, CTR-F selects the table search field
-
setControl
protected final void setControl(EntityTablePanel.ControlCode controlCode, Control control)
Associatescontrol
withcontrolCode
- Parameters:
controlCode
- the control codecontrol
- the control to associate withcontrolCode
, null for none- Throws:
IllegalStateException
- in case the panel has already been initialized
-
createToolBarControls
protected Controls createToolBarControls(List<Controls> additionalToolBarControls)
-
createPopupControls
protected Controls createPopupControls(List<Controls> additionalPopupControls)
Creates a Controls instance containing the controls to include in the table popup menu. Returns null or an empty Controls instance to indicate that no popup menu should be included.- Parameters:
additionalPopupControls
- any additional controls to include in the popup menu- Returns:
- Controls on which to base the table popup menu, null or an empty Controls instance if no popup menu should be included
-
createPrintControls
protected Controls createPrintControls()
-
confirmDelete
protected boolean confirmDelete()
Called before delete is performed, if true is returned the delete action is performed otherwise it is canceled- Returns:
- true if the delete action should be performed
-
confirmDeleteMessages
protected ConfirmationMessage confirmDeleteMessages()
- Returns:
- Message and title to display in the confirm delete dialog
-
createTableCellRenderer
protected <T> TableCellRenderer createTableCellRenderer(Property<T> property)
Creates a TableCellRenderer to use for the given property in this EntityTablePanel- Type Parameters:
T
- the property type- Parameters:
property
- the property- Returns:
- the TableCellRenderer for the given property
-
createTableCellEditor
protected <T> TableCellEditor createTableCellEditor(Property<T> property)
Creates a TableCellEditor for the given property, returns null if no editor is available- Type Parameters:
T
- the property type- Parameters:
property
- the property- Returns:
- a TableCellEditor for the given property
-
layoutPanel
protected void layoutPanel(JPanel tablePanel, JPanel southPanel)
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:
tablePanel
- the panel containing the table, condition and summary panelsouthPanel
- the south toolbar panel, null if not required- See Also:
initializeSouthPanel()
-
createSouthToolBar
protected JToolBar createSouthToolBar()
Creates the south panel toolbar, by default based oncreateToolBarControls(List)
- Returns:
- the toolbar to add to the south panel, null if none should be included
-
-