Class ObjectToStringParameterRenderer

java.lang.Object
uno.anahata.asi.swing.agi.message.part.tool.param.ObjectToStringParameterRenderer
All Implemented Interfaces:
ParameterRenderer<Object>
Direct Known Subclasses:
JavaCodeParameterRenderer

public class ObjectToStringParameterRenderer extends Object implements ParameterRenderer<Object>
A specialized parameter renderer that converts any Java object to a string and displays it using a high-fidelity IDE viewer.

This implementation authoritatively leverages the AbstractTextResourceViewer directly, bypassing the markdown segment middle-man to provide a professional, host-aware editor for tool parameters.

Representational Fidelity: Uses the polymorphic TextUtils.resolveContentString(Object) to handle Strings, Enums, Collections, and Arrays with 100% technical purity.

Author:
anahata
  • Field Details

    • agiPanel

      protected AgiPanel agiPanel
      The parent panel.
    • container

      private final JPanel container
      The main container panel.
    • viewer

      The high-fidelity viewer.
    • language

      private String language
      The programming language for syntax highlighting.
    • editable

      private boolean editable
      Whether the user is allowed to edit this parameter.
  • Constructor Details

    • ObjectToStringParameterRenderer

      public ObjectToStringParameterRenderer()
      No-arg constructor for factory instantiation.
  • Method Details

    • createHandle

      protected StringHandle createHandle(String content, AbstractToolCall<?,?> call, String paramName)
      Creates a String handle calling the file "Anahata" if the extension is "java".
      Parameters:
      content - the content of the handle
      call - the tool call that is creating it
      paramName - the parameter name in question
      Returns:
      a new StringHandle configured for syntax highlighting and name matching.
    • init

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

      Implementation details: Initializes the high-fidelity pipeline by resolving the object to a string, wrapping it in a virtual resource, and requesting a viewer.

      Specified by:
      init in interface ParameterRenderer<Object>
      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 central container which encapsulates the action strip and the high-fidelity viewer.

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

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

      Implementation details: Updates the underlying virtual resource handle with the new object's string representation.

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

      public boolean render()
      Triggers the rendering logic.

      Implementation details: Re-validates the container to ensure height adjustments are propagated through the conversation layout.

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