Class FullTextFileCreateRenderer

java.lang.Object
uno.anahata.asi.swing.agi.message.part.tool.param.FullTextFileCreateRenderer
All Implemented Interfaces:
ParameterRenderer<FullTextFileCreate>

public class FullTextFileCreateRenderer extends Object implements ParameterRenderer<FullTextFileCreate>
A unified, strategy-driven renderer for file creation operations.

This renderer manages the entire UI for a FullTextFileCreate parameter. It leverages the V2 ResourceUI strategy to provide high-fidelity editing by wrapping the proposed file in a virtual StringHandle.

Authoritative Navigation: Once a file is created, the header provides a clickable hyperlink to the real resource and an 'Edit' toggle to refine the proposal.

Author:
anahata
  • Field Details

    • agiPanel

      private AgiPanel agiPanel
      The agi panel instance providing session context.
    • call

      private AbstractToolCall<?,?> call
      The tool call containing the parameter being rendered.
    • paramName

      private String paramName
      The technical name of the parameter.
    • value

      private FullTextFileCreate value
      The current creation DTO containing path and content.
    • container

      private final JPanel container
      The main container panel for the renderer.
    • actionPanel

      private final JPanel actionPanel
      The toolbar for post-execution actions (Open/Edit).
    • viewer

      The high-fidelity text viewer component.
    • ephemeralHandle

      private StringHandle ephemeralHandle
      The virtual handle used to simulate the file before it exists on disk.
    • lastRenderedValue

      private FullTextFileCreate lastRenderedValue
      Cache of the last rendered state to prevent redundant UI updates.
    • lastRenderedStatus

      private ToolExecutionStatus lastRenderedStatus
      Cache of the last rendered status to track transitions (Proposed -> Created).
  • Constructor Details

    • FullTextFileCreateRenderer

      public FullTextFileCreateRenderer()
  • Method Details

    • init

      public void init(AgiPanel agiPanel, AbstractToolCall<?,?> call, String paramName, FullTextFileCreate value)
      Initializes the renderer with its context.

      Implementation details: Initializes the renderer with the necessary session and tool call context. Configures the container panels for role-neutral rendering.

      Specified by:
      init in interface ParameterRenderer<FullTextFileCreate>
      Parameters:
      agiPanel - The parent agi panel.
      call - The tool call being rendered.
      paramName - The name of the parameter.
      value - The initial value.
    • getComponent

      public JComponent getComponent()
      Returns the Swing component that performs the rendering.

      Implementation details: Returns the main container panel which will host either the high-fidelity editor or a validation error message.

      Specified by:
      getComponent in interface ParameterRenderer<FullTextFileCreate>
      Returns:
      The rendering component.
    • updateContent

      public void updateContent(FullTextFileCreate value)
      Updates the renderer with a new value.

      Implementation details: Updates the underlying DTO and pushes the new content into the ephemeral virtual resource to support bit-by-bit streaming in the UI.

      Specified by:
      updateContent in interface ParameterRenderer<FullTextFileCreate>
      Parameters:
      value - The new value to render.
    • validatePreFlight

      private boolean validatePreFlight()
      Performs authoritative pre-flight validation using the DTO's internal logic.
      Returns:
      true if valid.
    • render

      public boolean render()
      Triggers the rendering logic.

      Implementation details: Executes the main render logic. It performs pre-flight validation, initializes the high-fidelity viewer if necessary, and assembles the final UI with host-specific actions and clickable file hyperlinks.

      Specified by:
      render in interface ParameterRenderer<FullTextFileCreate>
      Returns:
      True if a visual update occurred.
    • initViewer

      private void initViewer()
      Initializes the host-native high-fidelity viewer via a virtual StringHandle.
    • createHeaderPanel

      private JPanel createHeaderPanel(ToolExecutionStatus status, Resource resource)
      Creates the header panel including status label and post-execution actions.
      Parameters:
      status - The current execution status.
      resource - The ephemeral resource instance.
      Returns:
      The configured header JPanel.
    • renderError

      private void renderError(String message)
      Renders an error message in the center of the container.
      Parameters:
      message - The error text.