Class SwingJava

All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable
Direct Known Subclasses:
IntellijJava, NbJava

public class SwingJava extends Java
An extension of the Java toolkit that provides Swing-specific execution utilities, such as EDT synchronization with context propagation.

This toolkit ensures that code running on the Event Dispatch Thread (EDT) can still access the tool execution context (logs, errors, attachments) by capturing and re-applying the thread-local state.

Author:
anahata
  • Constructor Details

    • SwingJava

      public SwingJava()
      Constructs a new instance of the toolkit and adds SwingAgiTool to the list of parentFirstClassess.
  • Method Details

    • getSystemInstructions

      public List<String> getSystemInstructions() throws Exception
      Gets a list of system instruction strings provided by this context provider. These are typically prepended to the conversation as high-level guidance.

      Injects Swing-specific execution helpers into the system instructions, enabling the model to use runInEdt and runInEdtAndWait for safe UI interactions.

      Specified by:
      getSystemInstructions in interface ContextProvider
      Overrides:
      getSystemInstructions in class Java
      Returns:
      A list of system instruction strings.
      Throws:
      Exception - if an error occurs during instruction generation.
    • getConcreteClassModelShouldExtend

      protected Class<? extends ToolContext> getConcreteClassModelShouldExtend()
      The class the model should extend when generating Agi tools.

      In this base implementation, it returns OnTheFlyAgiTool, which provides the necessary context anchors (log, error, etc.) for the script.

      Configures the code generator to produce classes extending SwingAgiTool, which provides the necessary plumbing for EDT-aware context propagation.

      Overrides:
      getConcreteClassModelShouldExtend in class Java
      Returns:
      the base AgiTool class.