Class EntityEditPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public abstract class EntityEditPanel extends EntityEditComponentPanel
A UI component based on a EntityEditModel.
See Also:
  • Field Details

    • USE_FOCUS_ACTIVATION

      public static final PropertyValue<Boolean> 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

      public static final PropertyValue<Boolean> 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

      public static final PropertyValue<Boolean> INCLUDE_ENTITY_MENU
      Specifies whether to include a EntityPopupMenu on this edit panel, triggered with CTRL-ALT-V.
      Value type: Boolean
      Default value: true
  • Constructor Details

    • EntityEditPanel

      public EntityEditPanel(SwingEntityEditModel editModel)
      Instantiates a new EntityEditPanel based on the given EntityEditModel
      Parameters:
      editModel - the EntityEditModel instance to base this EntityEditPanel on
    • EntityEditPanel

      public EntityEditPanel(SwingEntityEditModel editModel, EntityComponents entityComponents)
      Instantiates a new EntityEditPanel based on the given EntityEditModel
      Parameters:
      editModel - the EntityEditModel instance to base this EntityEditPanel on
      entityComponents - the entity components instance to use when creating components
    • EntityEditPanel

      public EntityEditPanel(SwingEntityEditModel editModel, EntityEditPanel.EditControl... editControls)
      Instantiates a new EntityEditPanel based on the given EntityEditModel
      Parameters:
      editModel - the EntityEditModel instance to base this EntityEditPanel on
      editControls - 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.EditControl... editControls)
      Instantiates a new EntityEditPanel based on the given EntityEditModel
      Parameters:
      editModel - the EntityEditModel instance to base this EntityEditPanel on
      entityComponents - the entity components instance to use when creating components
      editControls - if specified only controls with those keys are initialized, null or an empty array will result in no controls being initialized
  • Method Details

    • toString

      public final String toString()
      Overrides:
      toString in class Component
    • active

      public final State 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:
    • clearAfterInsert

      public final State clearAfterInsert()
      Returns:
      the State controlling whether the UI should be cleared after insert has been performed
    • requestFocusAfterInsert

      public final State requestFocusAfterInsert()
      Returns:
      the State controlling whether the UI should request focus after insert has been performed
      See Also:
    • referentialIntegrityErrorHandling

      public final Value<ReferentialIntegrityErrorHandling> referentialIntegrityErrorHandling()
      Returns:
      the Value controlling the action to take on a referential integrity error on delete
    • confirmer

      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 Value controlling the given confirmer
    • control

      public final Value<Control> control(EntityEditPanel.EditControl editControl)
      Returns a Value containing the control associated with controlCode, an empty Value if 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 Value containing the control associated with controlCode
    • controls

      public final Controls controls()
      Returns a Controls instance containing all the controls this edit panel provides via createControls().
      Returns:
      the Controls provided by this edit panel
      Throws:
      IllegalStateException - in case the panel has not been initialized
      See Also:
    • initialize

      public final EntityEditPanel 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 the EntityEditPanel.Confirmer associated with the EntityEditPanel.Confirmer.Action.INSERT action. Note that the default insert EntityEditPanel.Confirmer simply returns true, so in order to implement a insert confirmation you must set the EntityEditPanel.Confirmer via confirmer(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 the EntityEditPanel.Confirmer associated with the EntityEditPanel.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
    • updateWithConfirmation

      public final boolean updateWithConfirmation()
      Performs update on the active entity after asking for confirmation using the EntityEditPanel.Confirmer associated with the EntityEditPanel.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
    • 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

      protected void onException(Throwable exception)
      Propagates the exception to onValidationException(ValidationException) or onReferentialIntegrityException(ReferentialIntegrityException) depending on type, otherwise forwards to the super implementation.
      Overrides:
      onException in class EntityEditComponentPanel
      Parameters:
      exception - the exception to handle
      See Also:
    • onReferentialIntegrityException

      protected void onReferentialIntegrityException(ReferentialIntegrityException exception)
      Called when a ReferentialIntegrityException occurs during a delete operation on the active entity. If the referential integrity error handling is ReferentialIntegrityErrorHandling.DISPLAY_DEPENDENCIES, the dependencies of the entity involved are displayed to the user, otherwise onException(Throwable) is called.
      Parameters:
      exception - the exception
      See Also:
    • onValidationException

      protected void onValidationException(ValidationException exception)
      Displays the exception message after which the component involved receives the focus.
      Parameters:
      exception - the exception
    • createControls

      protected 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);
        }