java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
is.codion.swing.framework.ui.EntityEditComponentPanel
is.codion.swing.framework.ui.EntityEditPanel
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
A UI component based on a
EntityEditModel
.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Handles displaying confirmation messages for common actions to the user.static enum
The standard controls available to the EditPanelNested 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
FieldsModifier and TypeFieldDescriptionstatic final PropertyValue<Boolean>
Specifies whether to include aEntityPopupMenu
on this edit panel, triggered with CTRL-ALT-V.
Value type: Boolean
Default value: truestatic final PropertyValue<Boolean>
Specifies whether edit panels should be activated when the panel (or its parent EntityPanel) receives focus
Value type: Boolean
Default value: truestatic final PropertyValue<Boolean>
Specifies whether the add/insert button caption should be 'Save' (mnemonic S), instead of 'Add' (mnemonic A)
Value type: Boolean
Default value: falseFields inherited from class is.codion.swing.framework.ui.EntityEditComponentPanel
MODIFIED_INDICATOR_UNDERLINE_STYLE, USE_MODIFIED_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, EntityComponents entityComponents) Instantiates a new EntityEditPanel based on the givenEntityEditModel
EntityEditPanel
(SwingEntityEditModel editModel, EntityComponents entityComponents, EntityEditPanel.ControlCode... controlCodes) Instantiates a new EntityEditPanel based on the givenEntityEditModel
EntityEditPanel
(SwingEntityEditModel editModel, EntityEditPanel.ControlCode... controlCodes) Instantiates a new EntityEditPanel based on the givenEntityEditModel
-
Method Summary
Modifier and TypeMethodDescriptionfinal State
active()
protected void
Called before delete is performed.protected void
Called before insert is performed.protected void
Called before update is performed.final State
final void
Clears the underlying edit model and requests the initial focus.final boolean
containsControl
(EntityEditPanel.ControlCode controlCode) final Control
control
(EntityEditPanel.ControlCode controlCode) protected Controls
Creates a Controls instance containing all the controls available in this edit panelfinal boolean
delete()
Performs delete on the active entity without asking for confirmationfinal boolean
Performs delete on the active entity after asking for confirmation using theEntityEditPanel.Confirmer
associated with theEntityEditPanel.Confirmer.Action.DELETE
action.final 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 boolean
insert()
Performs insert on the active entity without asking for confirmationfinal boolean
Performs insert on the active entity after asking for confirmation using theEntityEditPanel.Confirmer
associated with theEntityEditPanel.Confirmer.Action.INSERT
action.protected void
Called when aReferentialIntegrityException
occurs during a delete operation on the active entity.protected void
onValidationException
(ValidationException exception) Displays the exception message after which the component involved receives the focus.final State
final void
setConfirmer
(EntityEditPanel.Confirmer.Action action, EntityEditPanel.Confirmer confirmer) Sets the confirmer to use for the given action.protected final void
setControl
(EntityEditPanel.ControlCode controlCode, Control control) Associatescontrol
withcontrolCode
final String
toString()
final boolean
update()
Performs update on the active entity without asking for confirmation.final boolean
Performs update on the active entity after asking for confirmation using theEntityEditPanel.Confirmer
associated with theEntityEditPanel.Confirmer.Action.UPDATE
action.Methods inherited from class is.codion.swing.framework.ui.EntityEditComponentPanel
addInputPanel, addInputPanel, addInputPanel, addInputPanel, afterInsertFocusAttribute, afterInsertFocusComponent, attribute, attributes, component, createBigDecimalField, createBooleanComboBox, createCheckBox, createComboBox, createComboBox, createDoubleField, createDoubleSpinner, createForeignKeyComboBox, createForeignKeyComboBoxPanel, createForeignKeyLabel, createForeignKeySearchField, createForeignKeySearchFieldPanel, createForeignKeyTextField, createInputPanel, createInputPanel, createInputPanel, createInputPanel, createInputPanel, createInputPanel, createIntegerField, createIntegerSpinner, createItemComboBox, createItemSpinner, createLabel, createListSpinner, createLongField, createMaskedTextField, createSlider, createTemporalField, createTemporalField, createTemporalFieldPanel, createTemporalFieldPanel, createTextArea, createTextField, createTextFieldPanel, displayException, editModel, excludeComponentsFromSelection, getAfterInsertFocusComponent, getInitialFocusComponent, initialFocusAttribute, initialFocusComponent, onException, requestAfterInsertFocus, requestAfterUpdateFocus, requestComponentFocus, requestInitialFocus, selectComponentAttributes, selectInputComponent, setComponent, setDefaultTextFieldColumns, setTransferFocusOnEnter, setUseModifiedIndicator
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
-
Field Details
-
USE_FOCUS_ACTIVATION
Specifies whether edit panels should be activated when the panel (or its parent EntityPanel) receives focus
Value type: Boolean
Default value: true -
USE_SAVE_CAPTION
Specifies whether the add/insert button caption should be 'Save' (mnemonic S), instead of 'Add' (mnemonic A)
Value type: Boolean
Default value: false -
INCLUDE_ENTITY_MENU
Specifies whether to include aEntityPopupMenu
on this edit panel, triggered with CTRL-ALT-V.
Value type: Boolean
Default value: true
-
-
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 onentityComponents
- the entity components instance to use when creating components
-
EntityEditPanel
Instantiates a new EntityEditPanel based on the givenEntityEditModel
- Parameters:
editModel
- theEntityEditModel
instance to base this EntityEditPanel oncontrolCodes
- if specified only controls with those keys are initialized, null or an empty array will result in no controls being initialized
-
EntityEditPanel
public EntityEditPanel(SwingEntityEditModel editModel, EntityComponents entityComponents, EntityEditPanel.ControlCode... controlCodes) Instantiates a new EntityEditPanel based on the givenEntityEditModel
- Parameters:
editModel
- theEntityEditModel
instance to base this EntityEditPanel onentityComponents
- the entity components instance to use when creating componentscontrolCodes
- if specified only controls with those keys are initialized, null or an empty array will result in no controls being initialized
-
-
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. -
clearAfterInsert
- Returns:
- the State controlling whether the UI should be cleared after insert has been performed
-
requestFocusAfterInsert
- Returns:
- the State controlling whether the UI should request focus after insert has been performed
- See Also:
-
referentialIntegrityErrorHandling
- Returns:
- the Value controlling the action to take on a referential integrity error on delete
-
setConfirmer
public final void setConfirmer(EntityEditPanel.Confirmer.Action action, EntityEditPanel.Confirmer confirmer) Sets the confirmer to use for the given action.- Parameters:
action
- the confirmation actionconfirmer
- the confirmer to use for the given action, null for the default one
-
containsControl
- Parameters:
controlCode
- the control code- Returns:
- true if this edit panel contains a control assocated with the given
controlCode
-
control
- Parameters:
controlCode
- the control code- Returns:
- the control associated with
controlCode
- Throws:
IllegalArgumentException
- in case no control is associated with the givencontrolCode
- 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
-
insertWithConfirmation
public final boolean insertWithConfirmation()Performs insert on the active entity after asking for confirmation using theEntityEditPanel.Confirmer
associated with theEntityEditPanel.Confirmer.Action.INSERT
action. Note that the default insertEntityEditPanel.Confirmer
simply returns true, so in order to implement a insert confirmation you must set theEntityEditPanel.Confirmer
viasetConfirmer(Confirmer.Action, Confirmer)
.- Returns:
- true in case of successful insert, false otherwise
- See Also:
-
insert
public final boolean insert()Performs insert on the active entity without asking for confirmation- Returns:
- true in case of successful insert, false otherwise
- See Also:
-
deleteWithConfirmation
public final boolean deleteWithConfirmation()Performs delete on the active entity after asking for confirmation using theEntityEditPanel.Confirmer
associated with theEntityEditPanel.Confirmer.Action.DELETE
action.- Returns:
- true if the delete operation was successful
- See Also:
-
delete
public final boolean delete()Performs delete on the active entity without asking for confirmation- Returns:
- true if the delete operation was successful
- See Also:
-
updateWithConfirmation
public final boolean updateWithConfirmation()Performs update on the active entity after asking for confirmation using theEntityEditPanel.Confirmer
associated with theEntityEditPanel.Confirmer.Action.UPDATE
action.- Returns:
- true if the update operation was successful
- See Also:
-
update
public final boolean update()Performs update on the active entity without asking for confirmation.- Returns:
- true if the update operation was successful
- See Also:
-
initialized
public final boolean initialized()- Returns:
- true if this panel has been initialized
- See Also:
-
beforeInsert
Called before insert is performed. To cancel the insert throw aCancelException
.- Throws:
ValidationException
- in case of a validation failure
-
beforeUpdate
Called before update is performed. To cancel the update throw aCancelException
.- Throws:
ValidationException
- in case of a validation failure
-
beforeDelete
protected void beforeDelete()Called before delete is performed. To cancel the delete throw aCancelException
. -
onReferentialIntegrityException
Called when aReferentialIntegrityException
occurs during a delete operation on the active entity. If the referential integrity error handling isReferentialIntegrityErrorHandling.DISPLAY_DEPENDENCIES
, the dependencies of the entity involved are displayed to the user, otherwiseEntityEditComponentPanel.onException(Throwable)
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
-
setControl
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
-
createControls
Creates a Controls instance containing all the controls available in this edit panel- Returns:
- the Controls available in this edit panel
- Throws:
IllegalStateException
- in case the panel has not 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() { initialFocusAttribute().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); }
-