Interface EntityEditor.EditorEntity

All Superinterfaces:
Observable<Entity>, Observer<Entity>
Enclosing interface:
EntityEditor<R extends EntityEditor<R>>

public static interface EntityEditor.EditorEntity extends Observable<Entity>
Provides access to the entity instance being edited.
  • Method Details

    • get

      Entity get()
      Specified by:
      get in interface Observable<Entity>
      Returns:
      an immutable copy of the entity being edited
    • set

      void set(@Nullable Entity entity)

      Populates this editor entity with the values from the given entity or sets the default value for all attributes in case it is null.

      Use EntityEditor.EditorValues.clear() in order to clear the editor of all values.

      Notifies that the entity is about to change via changing(), then notifies change via Observer.observer(). Detail editors registered via EntityEditor.DetailEditors.add(EditorLink) are reloaded via their link's load action. This is the master-selection path — use replace(Entity) for silent post-persist refreshes that should not re-fire change events.

      For master editors with registered detail editors, the order is bottom-up: changing() fires before the detail subtree is touched; the detail subtree is then set; finally changed fires once every detail editor is in its post-set state. This makes changed the "everything done" signal for the full master/detail tree, suitable for actions that need to inspect aggregate state.

      Parameters:
      entity - the entity to set, if null, then defaults are set
      Throws:
      IllegalArgumentException - in case the entity is not of the correct type
      See Also:
    • changing

      Observer<Entity> changing()

      Throwing a CancelException from a listener will cancel the change.

      For master editors with registered detail editors, this fires before the detail subtree is set, allowing listeners to inspect the pre-change state of the entire master/detail tree. The post-change counterpart is changed.

      Returns:
      an observer notified each time the entity is about to be changed via set(Entity) or EntityEditor.EditorValues.defaults().
      See Also:
    • replaced

      Observer<Entity> replaced()

      Returns an observer notified each time the entity is replaced via replace(Entity).

      For master editors with registered detail editors, this fires after the detail subtree has been replaced — by the time listeners run, every detail editor is in its post-persist state. This makes replaced() the "everything done" signal for the full master/detail tree, suitable for actions that need to inspect aggregate state (e.g., focusing the first empty detail editor, or adjusting which detail editors are visible).

      Returns:
      an observer notified each time the entity is replaced via replace(Entity)
    • replace

      void replace(@Nullable Entity entity)

      Silently replaces the editor entity values without firing changing() or changed events; only replaced() fires. A null argument sets default values.

      If the new entity has the same primary key as the current one (the typical post-persist refresh case), detail editors are not touched — their state is owned by their own persist tasks. If the primary key changes (including null↔non-null transitions), detail editors are reloaded via their link's load action, since the master's identity has changed.

      Parameters:
      entity - the replacement entity, or null to set defaults
      See Also:
    • refresh

      void refresh()
      Refreshes the active Entity from the database, discarding all changes. If the active Entity is new then calling this method has no effect.
      See Also: