Class AiProvidersPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class AiProvidersPanel extends JPanel
A dedicated master-detail management panel for AI Providers in the ASI Container.

Implements a high-efficiency Master-Detail architecture consisting of a left-hand sidebar list of all registered providers and exactly one reusable AbstractAiProviderPanel on the right side. This design drastically reduces component overhead by reusing a single form and table instance across all provider switches.

Dirty Tracking: Features integrated unsaved changes detection (checkUnsavedChanges()), automatically intercepting provider switches or dialog closes to prompt the user to save or discard pending modifications.

Author:
anahata
See Also:
  • Field Details

    • container

      private final AbstractSwingAsiContainer container
      The parent Swing ASI container instance managing global providers and thread pools.
    • listModel

      private final DefaultListModel<AbstractAiProvider> listModel
      The list model backing the sidebar provider selection list.
    • providerList

      private final JList<AbstractAiProvider> providerList
      The visual sidebar list component displaying registered AI providers.
    • detailPanelContainer

      private final JPanel detailPanelContainer
      Visual container panel holding the active typed detail panel.
    • detailPanel

      private AbstractAiProviderPanel detailPanel
      The single active detail panel instance hosting provider forms and model tables.
    • currentProvider

      private AbstractAiProvider currentProvider
      The currently selected and displayed AI provider instance.
  • Constructor Details

    • AiProvidersPanel

      public AiProvidersPanel(@NonNull @NonNull AbstractSwingAsiContainer container)
      Constructs a new Master-Detail AiProvidersPanel bound to the specified container.

      Initializes the left sidebar with provider icons and compact add controls, wires the dynamic AbstractAiProviderPanel in the center, and configures reactive selection listeners with dirty checking.

      Parameters:
      container - The parent ASI container instance.
  • Method Details

    • updateDetailPanel

      private void updateDetailPanel(AbstractAiProvider provider)
      Updates the center detail panel with the appropriate typed panel for the given provider.
      Parameters:
      provider - The active provider entity to display.
    • refreshProviderList

      public void refreshProviderList()
      Refreshes the sidebar provider list from the container's registered providers, preserving the current selection if still valid.
    • checkUnsavedChanges

      public boolean checkUnsavedChanges()
      Evaluates whether the currently displayed provider panel has unsaved modifications and prompts the user with a confirmation dialog if dirty.
      Returns:
      true if the operation can proceed (changes saved, discarded, or not modified); false if the user cancelled the transition.
    • showAddProviderDialog

      private void showAddProviderDialog()
      Displays a rich modal selection dialog allowing the user to instantiate, configure, and persist a new AI provider entity.
    • getProviderDescription

      private static String getProviderDescription(Class<? extends AbstractAiProvider> clazz)
      Resolves the human-readable description for an AI provider class.
      Parameters:
      clazz - The provider class to inspect.
      Returns:
      The descriptive text string.
    • removeCurrentProvider

      private void removeCurrentProvider()
      Confirms with the user and permanently removes the currently selected provider entity, deleting its .kryo storage file and unregistering it from the container.