Class AnahataTopComponent

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
org.openide.windows.TopComponent
uno.anahata.ai.nb.AnahataTopComponent
All Implemented Interfaces:
ImageObserver, MenuContainer, Externalizable, Serializable, Accessible, org.openide.util.HelpCtx.Provider, org.openide.util.Lookup.Provider, StatusListener

public final class AnahataTopComponent extends org.openide.windows.TopComponent implements Externalizable, StatusListener
The main TopComponent for the Anahata AI Assistant plugin. This component hosts the chat interface and manages the lifecycle of the AI session.
See Also:
  • Constructor Details

    • AnahataTopComponent

      public AnahataTopComponent()
      Default constructor for AnahataTopComponent. Initializes the component and adds it to the list of active sessions.
    • AnahataTopComponent

      public AnahataTopComponent(String initialMessage, List<com.google.genai.types.Part> initialParts, String nickname)
      Constructor that allows starting a session with an initial message and optional parts (like images).
      Parameters:
      initialMessage - The first text message to send.
      initialParts - Optional parts (e.g., screenshots) to include in the first message.
      nickname - An optional nickname for the session.
  • Method Details

    • getAllSessions

      public static List<AnahataTopComponent> getAllSessions()
      Returns an unmodifiable list of all active AnahataTopComponent sessions.
      Returns:
      a list of active sessions.
    • disposeSession

      public static void disposeSession(AnahataTopComponent tc)
      Disposes of a specific AnahataTopComponent session, closing its UI and shutting down its chat session.
      Parameters:
      tc - the TopComponent to dispose.
    • getTopComponentId

      public String getTopComponentId()
      Returns the unique ID of this TopComponent as registered in the WindowManager.
      Returns:
      the TopComponent ID.
    • getActions

      public Action[] getActions()
      Overrides:
      getActions in class org.openide.windows.TopComponent
    • componentOpened

      public void componentOpened()
      Overrides:
      componentOpened in class org.openide.windows.TopComponent
    • componentClosed

      public void componentClosed()
      Overrides:
      componentClosed in class org.openide.windows.TopComponent
    • performShutdown

      public void performShutdown()
      Performs the actual shutdown of the chat session. This should only be called when the session is being permanently disposed of.
    • getChat

      public Chat getChat()
      Returns the Chat instance associated with this TopComponent.
      Returns:
      the Chat instance, or null if not initialized.
    • getNetBeansChatConfig

      public NetBeansChatConfig getNetBeansChatConfig()
      Returns the NetBeans-specific chat configuration.
      Returns:
      the NetBeansChatConfig instance.
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Overrides:
      writeExternal in class org.openide.windows.TopComponent
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Overrides:
      readExternal in class org.openide.windows.TopComponent
      Throws:
      IOException
      ClassNotFoundException
    • setSessionUuidForHandoff

      public void setSessionUuidForHandoff(String sessionUuid)
      Sets the session UUID for handoff between components.
      Parameters:
      sessionUuid - the UUID to set.
    • statusChanged

      public void statusChanged(ChatStatus newStatus, String lastExceptionToString)
      Specified by:
      statusChanged in interface StatusListener