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 interfaceHandles displaying confirmation messages for common actions to the user.static enumThe standard controls available in a edit panelNested classes/interfaces inherited from class is.codion.swing.framework.ui.EntityEditComponentPanel
EntityEditComponentPanel.DefaultsNested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested 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 is.codion.common.property.PropertyValue<Boolean>Specifies whether to include aEntityPopupMenuon this edit panel, triggered with CTRL-ALT-V.
Value type: Boolean
Default value: truestatic final is.codion.common.property.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 is.codion.common.property.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
DEFAULT_TEXT_FIELD_COLUMNS, MODIFIED_INDICATOR, MODIFIED_INDICATOR_UNDERLINE_STYLEFields 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 -
Constructor Summary
ConstructorsConstructorDescriptionEntityEditPanel(is.codion.swing.framework.model.SwingEntityEditModel editModel) Instantiates a new EntityEditPanel based on the givenEntityEditModelEntityEditPanel(is.codion.swing.framework.model.SwingEntityEditModel editModel, EntityComponents entityComponents) Instantiates a new EntityEditPanel based on the givenEntityEditModelEntityEditPanel(is.codion.swing.framework.model.SwingEntityEditModel editModel, EntityComponents entityComponents, EntityEditPanel.EditControl... editControls) Instantiates a new EntityEditPanel based on the givenEntityEditModelEntityEditPanel(is.codion.swing.framework.model.SwingEntityEditModel editModel, EntityEditPanel.EditControl... editControls) Instantiates a new EntityEditPanel based on the givenEntityEditModel -
Method Summary
Modifier and TypeMethodDescriptionfinal is.codion.common.state.Stateactive()final is.codion.common.state.Statefinal voidClears the underlying edit model and requests the initial focus.protected final booleanfinal is.codion.common.value.Value<EntityEditPanel.Confirmer>Controls the confirmer to use for the given action, the default confirmer is used if this is set to null.protected final booleanprotected final booleanfinal is.codion.common.value.Value<is.codion.swing.common.ui.control.Control>control(EntityEditPanel.EditControl editControl) Returns aValuecontaining the control associated withcontrolCode, an emptyValueif no such control is available.final is.codion.swing.common.ui.control.Controlscontrols()Returns aControlsinstance containing all the controls this edit panel provides viacreateControls().protected is.codion.swing.common.ui.control.ControlsCreates a Controls instance containing all the controls available in this edit panelfinal booleandelete()Performs delete on the active entity without asking for confirmationfinal booleanPerforms delete on the active entity after asking for confirmation using theEntityEditPanel.Confirmerassociated with theEntityEditPanel.Confirmer.Action.DELETEaction.final EntityEditPanelInitializes this EntityEditPanel.final booleanprotected abstract voidInitializes this EntityEditPanel UI, that is, creates and lays out the components required for editing the underlying entity type.final booleaninsert()Performs insert on the active entity without asking for confirmationfinal booleanPerforms insert on the active entity after asking for confirmation using theEntityEditPanel.Confirmerassociated with theEntityEditPanel.Confirmer.Action.INSERTaction.protected voidonException(Throwable exception) Propagates the exception toonValidationException(ValidationException)oronReferentialIntegrityException(ReferentialIntegrityException)depending on type, otherwise forwards to the super implementation.protected voidonReferentialIntegrityException(is.codion.common.db.exception.ReferentialIntegrityException exception) Called when aReferentialIntegrityExceptionoccurs.protected voidonValidationException(is.codion.framework.domain.entity.exception.ValidationException exception) Displays the exception message after which the component involved receives the focus.final is.codion.common.value.Value<ReferentialIntegrityErrorHandling>final is.codion.common.state.Stateprotected voidOverride to setup any custom controls.final StringtoString()final booleanupdate()Performs update on the active entity without asking for confirmation.final booleanPerforms update on the active entity after asking for confirmation using theEntityEditPanel.Confirmerassociated with theEntityEditPanel.Confirmer.Action.UPDATEaction.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, defaults, displayException, editModel, excludeComponentsFromSelection, getAfterInsertFocusComponent, getInitialFocusComponent, initialFocusAttribute, initialFocusComponent, modifiedIndicator, requestAfterInsertFocus, requestAfterUpdateFocus, requestComponentFocus, requestInitialFocus, selectComponentAttributes, selectInputComponent, transferFocusOnEnterMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods 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, updateMethods 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, 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, 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 aEntityPopupMenuon this edit panel, triggered with CTRL-ALT-V.
Value type: Boolean
Default value: true
-
-
Constructor Details
-
EntityEditPanel
public EntityEditPanel(is.codion.swing.framework.model.SwingEntityEditModel editModel) Instantiates a new EntityEditPanel based on the givenEntityEditModel- Parameters:
editModel- theEntityEditModelinstance to base this EntityEditPanel on
-
EntityEditPanel
public EntityEditPanel(is.codion.swing.framework.model.SwingEntityEditModel editModel, EntityComponents entityComponents) Instantiates a new EntityEditPanel based on the givenEntityEditModel- Parameters:
editModel- theEntityEditModelinstance to base this EntityEditPanel onentityComponents- the entity components instance to use when creating components
-
EntityEditPanel
public EntityEditPanel(is.codion.swing.framework.model.SwingEntityEditModel editModel, EntityEditPanel.EditControl... editControls) Instantiates a new EntityEditPanel based on the givenEntityEditModel- Parameters:
editModel- theEntityEditModelinstance to base this EntityEditPanel oneditControls- if specified only controls with those keys are initialized, null or an empty array will result in no controls being initialized
-
EntityEditPanel
public EntityEditPanel(is.codion.swing.framework.model.SwingEntityEditModel editModel, EntityComponents entityComponents, EntityEditPanel.EditControl... editControls) Instantiates a new EntityEditPanel based on the givenEntityEditModel- Parameters:
editModel- theEntityEditModelinstance to base this EntityEditPanel onentityComponents- the entity components instance to use when creating componentseditControls- 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
public final is.codion.common.state.State active()- Returns:
- a
Statecontrolling 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:
-
EntityEditModel.set(Entity)EntityEditComponentPanel.requestInitialFocus()
-
clearAfterInsert
public final is.codion.common.state.State clearAfterInsert()- Returns:
- the State controlling whether the UI should be cleared after insert has been performed
-
requestFocusAfterInsert
public final is.codion.common.state.State requestFocusAfterInsert()- Returns:
- the State controlling whether the UI should request focus after insert has been performed
- See Also:
-
referentialIntegrityErrorHandling
public final is.codion.common.value.Value<ReferentialIntegrityErrorHandling> referentialIntegrityErrorHandling()- Returns:
- the Value controlling the action to take on a referential integrity error on delete
-
confirmer
public final is.codion.common.value.Value<EntityEditPanel.Confirmer> confirmer(EntityEditPanel.Confirmer.Action action) Controls the confirmer to use for the given action, the default confirmer is used if this is set to null.- Parameters:
action- the confirmation action- Returns:
- the
Valuecontrolling the given confirmer
-
control
public final is.codion.common.value.Value<is.codion.swing.common.ui.control.Control> control(EntityEditPanel.EditControl editControl) Returns aValuecontaining the control associated withcontrolCode, an emptyValueif no such control is available. Note that standard controls are populated during initialization, so until then, these values may be empty.- Parameters:
editControl- the control code- Returns:
- the
Valuecontaining the control associated withcontrolCode
-
controls
public final is.codion.swing.common.ui.control.Controls controls()Returns aControlsinstance containing all the controls this edit panel provides viacreateControls().- Returns:
- the
Controlsprovided by this edit panel - Throws:
IllegalStateException- in case the panel has not been initialized- 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.Confirmerassociated with theEntityEditPanel.Confirmer.Action.INSERTaction. Note that the default insertEntityEditPanel.Confirmersimply returns true, so in order to implement a insert confirmation you must set theEntityEditPanel.Confirmerviaconfirmer(Confirmer.Action).- 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
-
deleteWithConfirmation
public final boolean deleteWithConfirmation()Performs delete on the active entity after asking for confirmation using theEntityEditPanel.Confirmerassociated with theEntityEditPanel.Confirmer.Action.DELETEaction.- 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
-
updateWithConfirmation
public final boolean updateWithConfirmation()Performs update on the active entity after asking for confirmation using theEntityEditPanel.Confirmerassociated with theEntityEditPanel.Confirmer.Action.UPDATEaction.- 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
-
initialized
public final boolean initialized()- Returns:
- true if this panel has been initialized
- See Also:
-
confirmInsert
protected final boolean confirmInsert()- Returns:
- true if confirmed
- See Also:
-
confirmUpdate
protected final boolean confirmUpdate()- Returns:
- true if confirmed
- See Also:
-
confirmDelete
protected final boolean confirmDelete()- Returns:
- true if confirmed
- See Also:
-
onException
Propagates the exception toonValidationException(ValidationException)oronReferentialIntegrityException(ReferentialIntegrityException)depending on type, otherwise forwards to the super implementation.- Overrides:
onExceptionin classEntityEditComponentPanel- Parameters:
exception- the exception to handle- See Also:
-
onReferentialIntegrityException
protected void onReferentialIntegrityException(is.codion.common.db.exception.ReferentialIntegrityException exception) Called when aReferentialIntegrityExceptionoccurs. If aDatabase.Operation.DELETEoperation is being performed and the referential integrity error handling isReferentialIntegrityErrorHandling.DISPLAY_DEPENDENCIES, the dependencies of the entity involved are displayed to the user, otherwiseonException(Throwable)is called.- Parameters:
exception- the exception- See Also:
-
onValidationException
protected void onValidationException(is.codion.framework.domain.entity.exception.ValidationException exception) Displays the exception message after which the component involved receives the focus.- Parameters:
exception- the exception
-
createControls
protected is.codion.swing.common.ui.control.Controls createControls()Creates a Controls instance containing all the controls available in this edit panel- Returns:
- the Controls available in this edit panel
-
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:
-
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); }
-