Class AgiCard
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
uno.anahata.asi.swing.AgiCard
- All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
A "sticky note" style card representing an active AI session.
It provides a visual summary of the session's state, metrics, and quick actions.
This component listens for property changes on the
Agi object to
update its display in real-time.- Author:
- anahata
- See Also:
-
Nested Class Summary
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 AgiThe agi session represented by this card.private final EdtPropertyChangeListenerThe listener for changes in the agi session's properties.private final JButtonThe button to close the session's tab/window.private final AbstractAsiContainerThe container for handling session actions.private final EdtPropertyChangeListenerThe listener for history changes in the context manager.private final JLabelThe label displaying the total number of messages in the conversation.private final JLabelThe label displaying the agi's nickname.private final JLabelThe label displaying the total number of active resources.private final EdtPropertyChangeListenerThe listener for resource changes in the resource manager.private booleanWhether the card is currently selected in the container.private final JLabelThe label displaying the current status of the agi.private final EdtPropertyChangeListenerThe listener for status changes in the agi session.private final JTextAreaThe text area displaying the agi's summary.private SwingAgiConfig.UIThemeThe UI theme derived from the agi's configuration.private final JLabelThe label displaying the context window usage percentage.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
ConstructorsConstructorDescriptionAgiCard(@NonNull Agi agi, @NonNull AbstractAsiContainer container) Constructs a new AgiCard for the given agi session. -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()Cleans up resources and removes listeners.private voidHandles property change events from the agi session.private voidHandles history change events from the context manager.private voidHandles resource change events from the resource manager.private voidHandles status change events from the agi status manager.voidsetSelected(boolean selected) Sets the selection state of the card and updates its visual appearance.private voidSynchronizes the UI state with the agi's 'open' status and updates the background.private voidUpdates the card's background color based on selection, hover, and open state.private voidUpdates the card's border thickness and color based on the selection state.private voidRecalculates and updates the labels for message count and context usage.voidupdateUI()Methods inherited from class JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUIMethods 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, 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
-
agi
The agi session represented by this card. -
container
The container for handling session actions. -
nameLabel
The label displaying the agi's nickname. -
summaryArea
The text area displaying the agi's summary. -
statusLabel
The label displaying the current status of the agi. -
messageCountLabel
The label displaying the total number of messages in the conversation. -
resourceCountLabel
The label displaying the total number of active resources. -
usageLabel
The label displaying the context window usage percentage. -
closeBtn
The button to close the session's tab/window. -
agiListener
The listener for changes in the agi session's properties. -
statusListener
The listener for status changes in the agi session. -
historyListener
The listener for history changes in the context manager. -
resourceListener
The listener for resource changes in the resource manager. -
selected
private boolean selectedWhether the card is currently selected in the container. -
theme
The UI theme derived from the agi's configuration.
-
-
Constructor Details
-
AgiCard
Constructs a new AgiCard for the given agi session.- Parameters:
agi- The agi session to represent.container- The container for session actions.
-
-
Method Details
-
syncState
private void syncState()Synchronizes the UI state with the agi's 'open' status and updates the background. -
updateBackground
private void updateBackground()Updates the card's background color based on selection, hover, and open state. -
getPreferredSize
- Overrides:
getPreferredSizein classJComponent
-
setSelected
public void setSelected(boolean selected) Sets the selection state of the card and updates its visual appearance.- Parameters:
selected- true if the card is selected.
-
updateBorder
private void updateBorder()Updates the card's border thickness and color based on the selection state. -
handleAgiChange
Handles property change events from the agi session.- Parameters:
evt- The property change event.
-
handleStatusChange
Handles status change events from the agi status manager.- Parameters:
evt- The property change event.
-
handleHistoryChange
Handles history change events from the context manager.- Parameters:
evt- The property change event.
-
handleResourceChange
Handles resource change events from the resource manager.- Parameters:
evt- The property change event.
-
updateMetrics
private void updateMetrics()Recalculates and updates the labels for message count and context usage. -
updateUI
-
cleanup
public void cleanup()Cleans up resources and removes listeners. Should be called when the card is no longer needed.
-

