- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
EntityEditModel
.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Contains configuration settings for aEntityEditPanel
which must be set before the panel is initialized.static interface
Handles displaying confirmation messages for common actions to the user.static final class
The controls available forEntityEditPanel
s.protected static final class
static interface
Performs delete.static interface
Performs insert.static interface
Performs update.Nested classes/interfaces inherited from class is.codion.swing.framework.ui.EntityEditComponentPanel
EntityEditComponentPanel.InputFocus, EntityEditComponentPanel.ListBuilderFactory<T>
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 is.codion.swing.framework.ui.EntityEditComponentPanel
DEFAULT_TEXT_FIELD_COLUMNS, MODIFIED_INDICATOR, VALID_INDICATOR
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
ConstructorsConstructorDescriptionEntityEditPanel
(SwingEntityEditModel editModel) Instantiates a new EntityEditPanel based on the givenEntityEditModel
EntityEditPanel
(SwingEntityEditModel editModel, Consumer<EntityEditPanel.Config> config) Instantiates a new EntityEditPanel based on the givenEntityEditModel
-
Method Summary
Modifier and TypeMethodDescriptionfinal State
active()
final void
Clears the underlying edit model and requests the initial focus.protected final void
configureControls
(Consumer<Controls.Layout> controlsConfig) Configures the controls.protected final boolean
protected final boolean
protected final boolean
control
(ControlKey<T> controlKey) protected final Controls
controls()
Returns aControls
instance containing all the controls configured viaconfigureControls(Consumer)
.final void
delete()
Performs delete on the active entity after asking for confirmation using theEntityEditPanel.Confirmer
specified viaEntityEditPanel.Config.deleteConfirmer(Confirmer)
.protected final EntityEditPanel.DeleteCommand.Builder
Returns an async delete command builderfinal EntityEditPanel
Initializes this EntityEditPanel.final boolean
protected abstract void
Initializes this EntityEditPanel UI, that is, creates and lays out the components required for editing the underlying entity type.final void
insert()
Performs insert on the active entity after asking for confirmation using theEntityEditPanel.Confirmer
specified viaEntityEditPanel.Config.insertConfirmer(Confirmer)
.protected final EntityEditPanel.InsertCommand.Builder
Returns an async insert command builderprotected void
onException
(Exception exception) Propagates the exception toonValidationException(ValidationException)
oronReferentialIntegrityException(ReferentialIntegrityException)
depending on type, otherwise forwards to the super implementation.protected void
Called when aReferentialIntegrityException
occurs.protected void
onValidationException
(ValidationException exception) Displays the exception message after which the component involved receives the focus.final void
Displays a dialog allowing the user the select an input component which should receive the keyboard focus.protected void
Override to set up any custom controls.final String
toString()
final void
update()
Performs update on the active entity after asking for confirmation using theEntityEditPanel.Confirmer
specified viaEntityEditPanel.Config.updateConfirmer(Confirmer)
.protected final EntityEditPanel.UpdateCommand.Builder
Returns an async update command builderMethods inherited from class is.codion.swing.framework.ui.EntityEditComponentPanel
addInputPanel, addInputPanel, addInputPanel, addInputPanel, component, components, createBigDecimalField, createBooleanComboBox, createCheckBox, createComboBox, createComboBox, createComboBox, createComboBoxPanel, createDoubleField, createDoubleSpinner, createInputPanel, createInputPanel, createInputPanel, createInputPanel, createInputPanel, createInputPanel, createIntegerField, createIntegerSpinner, createItemComboBox, createItemSpinner, createLabel, createList, createListSpinner, createLongField, createMaskedTextField, createSearchField, createSearchFieldPanel, createSlider, createTemporalField, createTemporalFieldPanel, createTextArea, createTextField, createTextField, createTextFieldPanel, displayException, editModel, focus, modifiedIndicator, validIndicator
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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
-
EntityEditPanel
Instantiates a new EntityEditPanel based on the givenEntityEditModel
- Parameters:
editModel
- theEntityEditModel
instance to base this EntityEditPanel on
-
EntityEditPanel
Instantiates a new EntityEditPanel based on the givenEntityEditModel
- Parameters:
editModel
- theEntityEditModel
instance to base this EntityEditPanel onconfig
- provides access to the panel configuration
-
-
Method Details
-
toString
-
active
- Returns:
- a
State
controlling whether this panel is active, enabled and ready to receive input
-
clearAndRequestFocus
public final void clearAndRequestFocus()Clears the underlying edit model and requests the initial focus.- See Also:
-
selectInputComponent
public final void selectInputComponent()Displays a dialog allowing the user the select an input component which should receive the keyboard focus.
If only one input component is available that component is selected automatically without displaying a selection dialog.
If no component is available, f.ex. when the panel is not visible or none of the available components is focusable, this method does nothing.
Input components can be excluded from this selection using
EntityEditPanel.Config.excludeFromSelection(Collection)
- See Also:
-
initialize
Initializes this EntityEditPanel. This method marks this panel as initialized which prevents it from running again, whether an exception occurs or not.- Returns:
- this EntityEditPanel instance
-
insert
public final void insert()Performs insert on the active entity after asking for confirmation using the
EntityEditPanel.Confirmer
specified viaEntityEditPanel.Config.insertConfirmer(Confirmer)
.Note that the default insert
EntityEditPanel.Confirmer
simply returns true, so in order to implement an insert confirmation you must set theEntityEditPanel.Confirmer
viaEntityEditPanel.Config.insertConfirmer(Confirmer)
.- See Also:
-
delete
public final void delete()Performs delete on the active entity after asking for confirmation using the
EntityEditPanel.Confirmer
specified viaEntityEditPanel.Config.deleteConfirmer(Confirmer)
.- See Also:
-
update
public final void update()Performs update on the active entity after asking for confirmation using the
EntityEditPanel.Confirmer
specified viaEntityEditPanel.Config.updateConfirmer(Confirmer)
.- See Also:
-
initialized
public final boolean initialized()- Returns:
- true if this panel has been initialized
- See Also:
-
confirmInsert
protected final boolean confirmInsert()- Returns:
- true if confirmed
-
confirmUpdate
protected final boolean confirmUpdate()- Returns:
- true if confirmed
-
confirmDelete
protected final boolean confirmDelete()- Returns:
- true if confirmed
-
insertCommandBuilder
Returns an async insert command builder- Returns:
- a new async insert command builder
-
updateCommandBuilder
Returns an async update command builder- Returns:
- a new async update command builder
-
deleteCommandBuilder
Returns an async delete command builder- Returns:
- a new async delete command builder
-
onException
Propagates the exception toonValidationException(ValidationException)
oronReferentialIntegrityException(ReferentialIntegrityException)
depending on type, otherwise forwards to the super implementation.- Overrides:
onException
in classEntityEditComponentPanel
- Parameters:
exception
- the exception to handle- See Also:
-
onReferentialIntegrityException
Called when aReferentialIntegrityException
occurs. If aDatabase.Operation.DELETE
operation is being performed and the referential integrity error handling isReferentialIntegrityErrorHandling.DISPLAY_DEPENDENCIES
, the dependencies of the entity involved are displayed to the user, otherwiseonException(Exception)
is called.- Parameters:
exception
- the exception- See Also:
-
onValidationException
Displays the exception message after which the component involved receives the focus.- Parameters:
exception
- the exception
-
setupControls
protected void setupControls()Override to set up any custom controls. This default implementation is empty. This method is called after all standard controls have been initialized.- See Also:
-
initializeUI
protected abstract void initializeUI()Initializes this EntityEditPanel UI, that is, creates and lays out the components required for editing the underlying entity type.protected void initializeUI() { focus().initial().set(DomainModel.USER_NAME); createTextField(DomainModel.USER_NAME); createTextField(DomainModel.USER_ADDRESS); setLayout(new GridLayout(2, 1, 5, 5)); addInputPanel(DomainModel.USER_NAME); addInputPanel(DomainModel.USER_ADDRESS); }
-
configureControls
Configures the controls.Note that the
Controls.Layout
instance has pre-configured defaults, which must be cleared in order to start with an empty configuration.configureControls(layout -> layout .separator() .control(createCustomControl()))
- Parameters:
controlsConfig
- provides access to the controls configuration- See Also:
-
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
-
controls
Returns aControls
instance containing all the controls configured viaconfigureControls(Consumer)
.- Returns:
- the
Controls
provided by this edit panel - Throws:
IllegalStateException
- in case the panel has not been initialized- See Also:
-