Class AbstractSwingAsiContainer

All Implemented Interfaces:
PropertyChangeSource, Rebindable
Direct Known Subclasses:
AsiDesktopAsiContainer, IntellijAsiContainer, NetBeansAsiContainer

public abstract class AbstractSwingAsiContainer extends AbstractAsiContainer
A Swing-specific base class for Anahata ASI containers.

This class bridges the gap between model-agnostic session logic and the Swing UI environment. It provides shared utilities for UI-based session imports and defines the hooks for environment-specific window/tab management.

Author:
anahata
  • Field Details

    • AVAILABLE_PROVIDER_CLASSES

      public static final List<Class<? extends AbstractAiProvider>> AVAILABLE_PROVIDER_CLASSES
      List of all known AI Providers.
    • settingsFrame

      private AsiContainerSettingsFrame settingsFrame
      The single-instance Settings Command Center frame for this container.
    • javaFxVersionInfo

      protected String javaFxVersionInfo
      Cached JavaFX version and conditional features info for this container instance.
  • Constructor Details

    • AbstractSwingAsiContainer

      public AbstractSwingAsiContainer(String hostApplicationId) throws IOException
      Constructs a new Swing ASI container.
      Parameters:
      hostApplicationId - The unique ID of the host application.
      Throws:
      IOException
  • Method Details

    • getDirectory

      public Path getDirectory() throws IOException
      Gets the root working directory for this specific host application instance. e.g., ~/.anahata/asi/netbeans or ~/.anahata/asi/netbeans/1.2.0

      Intercepts container directory resolution prior to creation to detect predecessor version directories. Prompts the user via Swing UI dialog and automatically migrates persistent settings if requested.

      Overrides:
      getDirectory in class AbstractAsiContainer
      Returns:
      The application-specific working directory path.
      Throws:
      IOException - If creating the directory fails.
    • promptUpgrade

      protected boolean promptUpgrade(String previousVersion, String currentVersion)
      Prompts the user via a native Swing dialog asking whether they would like to import persistent settings from an earlier detected version.
      Parameters:
      previousVersion - The predecessor version string.
      currentVersion - The running container version string.
      Returns:
      true if the user elected to import, false to start fresh.
    • showImportSuccess

      protected void showImportSuccess(int count, String prevVerStr)
      Displays an informational dialog confirming that settings were successfully imported from an earlier version.
      Parameters:
      count - The number of entities imported.
      prevVerStr - The predecessor version string.
    • showSettings

      public void showSettings()
      Displays the global ASI settings Command Center in maximized mode.
    • showSettings

      public void showSettings(int initialTabIndex)
      Displays the global ASI settings Command Center with a specific tab selected.

      Reuses the existing AsiContainerSettingsFrame instance if already open, bringing it to front and selecting the requested tab index.

      Parameters:
      initialTabIndex - The index of the tab to open.
    • getAgiPanel

      public AgiPanel getAgiPanel(Agi agi)
      Retrieves the AgiPanel associated with a specific Agi session.
      Parameters:
      agi - The session.
      Returns:
      The AgiPanel instance.
    • onAgiOpened

      protected void onAgiOpened(Agi agi)
      Hook invoked when a session has been logically opened.

      Implementation details: Marshals the logical 'open' intent to the Event Dispatch Thread (EDT) and delegates to the environment-specific focusUI(Agi) method. This guarantees safe UI manipulation regardless of the calling thread.

      Specified by:
      onAgiOpened in class AbstractAsiContainer
      Parameters:
      agi - The opened session.
    • onAgiClosed

      protected void onAgiClosed(Agi agi)
      Hook invoked when a session has been logically closed.

      Implementation details: Marshals the logical 'close' intent to the Event Dispatch Thread (EDT) and delegates to the environment-specific closeUI(Agi) method. This guarantees safe UI manipulation regardless of the calling thread.

      Specified by:
      onAgiClosed in class AbstractAsiContainer
      Parameters:
      agi - The closed session.
    • focusUI

      protected abstract void focusUI(Agi agi)
      Environment-specific logic to visually focus or select the UI component associated with the given session.
      Parameters:
      agi - The session to focus.
    • closeUI

      protected abstract void closeUI(Agi agi)
      Environment-specific logic to visually close or hide the UI component associated with the given session.
      Parameters:
      agi - The session to close.
    • importSessionWithUI

      public void importSessionWithUI(Component parent)
      Opens a standard Swing JFileChooser to allow the user to select a saved session (.kryo) for import.
      Parameters:
      parent - The parent component for the dialog.
    • initJavaFx

      private void initJavaFx()
      Initializes the JavaFX runtime on the container's designated ClassLoader once during startup.
    • getJavaFxClassLoader

      public ClassLoader getJavaFxClassLoader()
      Returns the ClassLoader to search for JavaFX runtime classes. Defaults to the container's own ClassLoader; overridden in NetBeans to query the JavaFX module loader.
      Returns:
      the ClassLoader for JavaFX.
    • isJavaFxAvailable

      public boolean isJavaFxAvailable()
      Checks if JavaFX is available and initialized in this container.
      Returns:
      true if JavaFX version info is resolved.