Class DeclarativeGui

java.lang.Object
com.ultikits.ultitools.abstracts.gui.declarative.engine.DeclarativeGui
Direct Known Subclasses:
StatefulDeclarativeGui

public abstract class DeclarativeGui extends Object
A state-derived screen shown through UiService. Subclasses only describe widgets; backend selection, clicks and close reasons belong to the UI service.
Since:
6.2.0
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • id

      protected final String id
    • ui

      private final UiService ui
    • viewer

      private final org.bukkit.entity.Player viewer
    • rows

      private final int rows
    • renderer

      private final GuiRenderer renderer
    • firstGrid

      private Grid firstGrid
    • session

      private GridSession session
    • initialized

      private boolean initialized
  • Constructor Details

    • DeclarativeGui

      protected DeclarativeGui(UiService ui, Scheduler scheduler, org.bukkit.entity.Player viewer, String id, Text title, int rows)
      Parameters:
      ui - the screen owner's UI service
      scheduler - the module's own injected scheduler
      viewer - the viewer
      id - the build-context identifier
      title - deferred screen title
      rows - fixed row count, 1..6
  • Method Details

    • build

      @NotNull public abstract @NotNull Widget build(@NotNull @NotNull BuildContext context)
      Parameters:
      context - the root build context @return a widget tree derived from current state
    • open

      public final GridSession open()
      Synchronously builds the first complete frame, then shows it. Later frames update the same session. Calling this while the page is open returns that session; after its result arrives the page may reopen.
      Returns:
      the grid session
      Throws:
      IllegalStateException - if not on the viewer's owning thread, or called re-entrantly during opening
    • acceptGrid

      private void acceptGrid(Grid grid)
    • finished

      private void finished(UiResult<Ack> result)
    • logCloseFailure

      private void logCloseFailure(String phase, Throwable failure)
    • markNeedsBuild

      protected void markNeedsBuild()
      Requests a later frame while this page is mounted.
    • setState

      protected void setState(@NotNull @NotNull Runnable action)
      Parameters:
      action - modifies state before requesting a later frame
    • onGuiClose

      protected void onGuiClose(@NotNull @NotNull UiResult<Ack> result)
      Parameters:
      result - the service's final close result; resources have already been disposed
    • getRenderer

      @NotNull protected @NotNull GuiRenderer getRenderer()
      Returns:
      the renderer owning this page's elements
    • isInitialized

      public boolean isInitialized()
      Returns:
      whether the page is mounted and awaiting its session result
    • viewer

      @NotNull public @NotNull org.bukkit.entity.Player viewer()
      Returns:
      the viewer