java.lang.Object
com.ultikits.ultitools.abstracts.gui.declarative.core.Element
com.ultikits.ultitools.abstracts.gui.declarative.core.ComponentElement
Direct Known Subclasses:
StatefulElement, StatelessElement

public abstract class ComponentElement extends Element
ComponentElement is the base Element class for Elements that hold a child Widget.

It manages a single child Widget and builds it as needed. Both StatelessWidget and StatefulWidget use this kind of Element.

Since:
6.2.0
Version:
1.0.0
Author:
UltiTools Team
  • Field Details

    • _child

      @Nullable private @Nullable Element _child
  • Constructor Details

    • ComponentElement

      public ComponentElement(@NotNull @NotNull Widget widget)
  • Method Details

    • build

      public abstract Widget build()
      Builds the child Widget.
      Returns:
      the child Widget
    • performRebuild

      public void performRebuild()
      Description copied from class: Element
      Performs a rebuild.

      Subclasses should implement this method to build or rebuild the Widget tree.

      Specified by:
      performRebuild in class Element
    • getChildren

      @NotNull public @NotNull List<Element> getChildren()
      Description copied from class: Element
      Gets the list of child Elements.
      Overrides:
      getChildren in class Element
      Returns:
      the child Element list, or an empty list if there are none
    • mount

      public void mount(@Nullable @Nullable Element parent)
      Description copied from class: Element
      Mounts this Element into the tree.

      Called the first time the Element is inserted into the tree. Subclasses should perform initialization work here and mount their child Elements.

      CR-01 (T-05-62 / #371): every mount(Element) override in this codebase calls super.mount(parent) before doing its own work (mounting children, running the first performRebuild(), etc.) -- this base method is therefore the single choke point through which the ENTIRE mounting recursion passes, one call per Element, regardless of subtype: ContainerElement/GridViewElement.mountChildren() calling childElement.mount(this) for each child, and the mount()->performRebuild()->updateChild()->mount() cascade StatelessElement/StatefulElement drive when composing a child Widget for the first time. Checking the depth HERE, rather than separately in every subclass's own mounting method, guards the mount recursion exactly once per node without needing to duplicate the check at each override. update()/unmount()'s own recursions need no separate guard: they only ever walk a subtree whose depth was already validated here when it was first mounted, so they can never exceed RenderDepthGuard.MAX_DEPTH without first passing through an unguarded mount() call -- which this check closes.

      Overrides:
      mount in class Element
      Parameters:
      parent - the parent Element, or null if this is the root Element
    • unmount

      public void unmount()
      Description copied from class: Element
      Removes this Element from the tree.

      Called when the Element is no longer needed. Subclasses should perform cleanup work here and unmount their child Elements.

      Overrides:
      unmount in class Element