Class AiModelsPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
uno.anahata.asi.swing.provider.AiModelsPanel
- All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
A high-fidelity visual registry for exploring, configuring, and registering AI models.
This panel utilizes a JXTable and rich filter controls
(provider dropdown with icons, keyword/regex query field, response modality toggles,
and effectively-enabled state filter) to provide advanced discovery and lifecycle management.
Models can be enabled/disabled, added from API discovery caches to local persistent storage,
deleted, or reset when discrepancies occur.
- Author:
- anahata
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classActive cell editor for Column 0.private classStateless cell renderer for Column 0.private classActive cell editor providing Remove and Reset buttons for table rows.private classStateless cell renderer providing Remove and Reset buttons for table rows.Nested classes/interfaces inherited from class JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final JButtonButton to add all unregistered API models to the local database in a single batch.private final AbstractAsiContainerContainer reference for background model fetching and executor pooling.private final JToggleButtonToggle button for filtering by AUDIO response modality.private final JCheckBoxCheckbox to filter models to only effectively enabled providers.private final JTextFieldThe real-time search and filter input field.private final JToggleButtonToggle button for filtering by IMAGE response modality.private final Consumer<AbstractModel> Reactive callback for notifying the system of a user's model selection.private final JProgressBarBottom status bar indeterminate progress bar for async background tasks.private final JComboBox<AbstractAiProvider> The dropdown combo box for selecting/filtering by AI provider.private final JLabelThe label for the provider combo box.private final JButtonRefresh button to reload models from providers' live APIs.private final JButtonButton to remove selected models from local storage.private final JButtonButton to reset selected models with discrepancies back to API specifications.private final JLabelBottom status bar label showing active model counts and operations feedback.private final JXTableThe advanced SwingX table instance for model discovery.private final AiModelTableModelThe technical data model powering the table.private AbstractAiProviderTarget provider lock when embedded in a single provider configuration panel.private final JToggleButtonToggle button for filtering by TEXT response modality.private final JToggleButtonToggle button for filtering by VIDEO response modality.Fields inherited from class JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionAiModelsPanel(List<AbstractModel> models, @NonNull AbstractAsiContainer asiContainer, Consumer<AbstractModel> modelSelectionCallback) Constructs a new AiModelsPanel with container-aware refresh capabilities. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidAdds all newly discovered API models to the local database in a single batch.private voidEvaluates all active filters (provider, search query regex, response modalities, and enabled status) and updates the table row filter accordingly.private StringFormats a clean, bounded HTML tooltip card for a model without overflowing the monitor.private intCalculates the count of models discovered from API that are not yet persisted locally.private voidRefreshes models asynchronously from providers using a SwingTask, updating the table progressively.private voidRefreshes the table view with current models from providers.private voidRemoves all selected registered models from local storage in a single batch.private voidResets all selected registered models with discrepancies back to API specifications.private voidselectModel(AbstractModel model) Dispatches the model selection callback.voidsetTargetProvider(AbstractAiProvider provider) Locks and targets this panel to a specific provider (used when embedding in AiProviderPanel).private voidDisplays a context menu on right-click allowing quick copying of the model ID or inspecting full raw metadata in the environment's native code viewer.private voidUpdates the text and visibility of the "Add X New Models" button based on unregistered API models.private voidUpdates the enabled state of the 'Remove Selected' and 'Reset Selected' buttons based on active table selection.Methods inherited from class JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
table
The advanced SwingX table instance for model discovery. -
tableModel
The technical data model powering the table. -
filterField
The real-time search and filter input field. -
providerLabel
The label for the provider combo box. -
providerComboBox
The dropdown combo box for selecting/filtering by AI provider. -
textToggle
Toggle button for filtering by TEXT response modality. -
imageToggle
Toggle button for filtering by IMAGE response modality. -
audioToggle
Toggle button for filtering by AUDIO response modality. -
videoToggle
Toggle button for filtering by VIDEO response modality. -
effectivelyEnabledCheckbox
Checkbox to filter models to only effectively enabled providers. -
refreshButton
Refresh button to reload models from providers' live APIs. -
addNewModelsButton
Button to add all unregistered API models to the local database in a single batch. -
removeSelectedButton
Button to remove selected models from local storage. -
resetSelectedButton
Button to reset selected models with discrepancies back to API specifications. -
statusLabel
Bottom status bar label showing active model counts and operations feedback. -
progressBar
Bottom status bar indeterminate progress bar for async background tasks. -
asiContainer
Container reference for background model fetching and executor pooling. -
modelSelectionCallback
Reactive callback for notifying the system of a user's model selection. -
targetProvider
Target provider lock when embedded in a single provider configuration panel.
-
-
Constructor Details
-
AiModelsPanel
public AiModelsPanel(List<AbstractModel> models, @NonNull @NonNull AbstractAsiContainer asiContainer, Consumer<AbstractModel> modelSelectionCallback) Constructs a new AiModelsPanel with container-aware refresh capabilities.- Parameters:
models- The initial list of models to display.asiContainer- The parent ASI container providing thread pools and provider registries.modelSelectionCallback- A callback for when a model is double-clicked.
-
-
Method Details
-
formatModelToolTip
Formats a clean, bounded HTML tooltip card for a model without overflowing the monitor.- Parameters:
m- The model entity.- Returns:
- Bounded HTML tooltip string, or null.
-
selectModel
Dispatches the model selection callback. If the selected model is not yet registered in local storage, it is automatically registered and persisted without prompting. If registration fails, anExceptionDialogis displayed to the user and selection does not proceed.- Parameters:
model- The model entity to select.
-
showTableContextMenu
Displays a context menu on right-click allowing quick copying of the model ID or inspecting full raw metadata in the environment's native code viewer.- Parameters:
e- The mouse event.
-
setTargetProvider
Locks and targets this panel to a specific provider (used when embedding in AiProviderPanel).- Parameters:
provider- The target provider to lock to.
-
updateAddNewModelsButton
private void updateAddNewModelsButton()Updates the text and visibility of the "Add X New Models" button based on unregistered API models. -
getUnregisteredApiModelsCount
private int getUnregisteredApiModelsCount()Calculates the count of models discovered from API that are not yet persisted locally.- Returns:
- The count of unregistered API models.
-
addAllNewModels
private void addAllNewModels()Adds all newly discovered API models to the local database in a single batch. -
refreshTableData
private void refreshTableData()Refreshes the table view with current models from providers. -
updateSelectionActionButtons
private void updateSelectionActionButtons()Updates the enabled state of the 'Remove Selected' and 'Reset Selected' buttons based on active table selection. -
removeSelectedModels
private void removeSelectedModels()Removes all selected registered models from local storage in a single batch. -
resetSelectedModels
private void resetSelectedModels()Resets all selected registered models with discrepancies back to API specifications. -
applyFilter
private void applyFilter()Evaluates all active filters (provider, search query regex, response modalities, and enabled status) and updates the table row filter accordingly. -
refreshModelsFromProviders
private void refreshModelsFromProviders()Refreshes models asynchronously from providers using a SwingTask, updating the table progressively.
-

