java.lang.Object
org.eclipse.swt.browser.BrowserFunction
com.developer.nefarious.zjoule.plugin.core.functions.PromptHandler

public class PromptHandler extends org.eclipse.swt.browser.BrowserFunction
Handles user prompts from the browser and communicates with the chat orchestrator to generate responses.

This class extends BrowserFunction to enable JavaScript interaction with the Eclipse SWT Browser component. It uses the ChatOrchestrator to process user input and generate AI-driven responses.

  • Constructor Summary

    Constructors
    Constructor
    Description
    PromptHandler(org.eclipse.swt.browser.Browser browser, String name)
    Constructs a new PromptHandler instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    create(org.eclipse.swt.browser.Browser browser, String name)
    Factory method to create a new PromptHandler instance.
    function(Object[] arguments)
    Handles the JavaScript function call from the browser.

    Methods inherited from class org.eclipse.swt.browser.BrowserFunction

    dispose, getBrowser, getName, isDisposed

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PromptHandler

      public PromptHandler(org.eclipse.swt.browser.Browser browser, String name)
      Constructs a new PromptHandler instance.
      Parameters:
      browser - the Browser instance associated with this function.
      name - the name of the JavaScript function exposed to the browser.
  • Method Details

    • create

      public static PromptHandler create(org.eclipse.swt.browser.Browser browser, String name)
      Factory method to create a new PromptHandler instance.
      Parameters:
      browser - the Browser instance associated with this function.
      name - the name of the JavaScript function exposed to the browser.
      Returns:
      a new PromptHandler instance.
    • function

      public Object function(Object[] arguments)
      Handles the JavaScript function call from the browser.

      This method takes the first argument as the user prompt, passes it to the ChatOrchestrator.getAnswer(String) method, and returns the generated AI response.

      Overrides:
      function in class org.eclipse.swt.browser.BrowserFunction
      Parameters:
      arguments - the arguments passed from the JavaScript function call.
      Returns:
      the AI-generated response as an Object.