Class AgisTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
uno.anahata.asi.swing.AgisTableModel
- All Implemented Interfaces:
Serializable, TableModel
A reusable table model for displaying active AI agi sessions.
This model tracks the
AbstractAsiContainer and provides real-time updates
on session status, message count, and context usage through reactive listeners.- Author:
- anahata
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AbstractAsiContainerThe container configuration providing session data.private final PropertyChangeListenerThe listener for changes in the container's session list.private final String[]The localized column names for the table.static final intThe column index for context window usage.static final intThe column index for the session ID.static final intThe column index for the message count.private final PropertyChangeListenerThe listener for metric changes in individual sessions.static final intThe column index for the resource count.static final intThe column index for the session name.The list of active agi sessions being tracked.static final intThe column index for the session status.static final intThe column index for the conversation summary.Fields inherited from class AbstractTableModel
listenerList -
Constructor Summary
ConstructorsConstructorDescriptionAgisTableModel(@NonNull AbstractAsiContainer asiConfig) Constructs a new model and registers a listener on the provided container. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidattachListeners(Agi agi) Attaches reactive property change listeners to the given AGI session.private voiddetachListeners(Agi agi) Detaches reactive property change listeners from the given AGI session.voiddispose()Unregisters the listener from the container and cleans up the model.getAgiAt(int row) Retrieves the agi session at the specified row index.Class<?> getColumnClass(int columnIndex) intgetColumnName(int column) intgetValueAt(int rowIndex, int columnIndex) private voidHandles property change events from the ASI container to trigger a refresh.private voidHandles property change events from individual sessions to update specific rows.final voidrefresh()Refreshes the table model by synchronizing with theAbstractAsiContainer.Methods inherited from class AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
-
Field Details
-
sessions
-
columnNames
The localized column names for the table. -
metricsListener
The listener for metric changes in individual sessions. -
asiConfig
The container configuration providing session data. -
asiListener
The listener for changes in the container's session list. -
SESSION_COL
public static final int SESSION_COLThe column index for the session name.- See Also:
-
ID_COL
public static final int ID_COLThe column index for the session ID.- See Also:
-
STATUS_COL
public static final int STATUS_COLThe column index for the session status.- See Also:
-
MESSAGES_COL
public static final int MESSAGES_COLThe column index for the message count.- See Also:
-
RESOURCES_COL
public static final int RESOURCES_COLThe column index for the resource count.- See Also:
-
CONTEXT_COL
public static final int CONTEXT_COLThe column index for context window usage.- See Also:
-
SUMMARY_COL
public static final int SUMMARY_COLThe column index for the conversation summary.- See Also:
-
-
Constructor Details
-
AgisTableModel
Constructs a new model and registers a listener on the provided container.- Parameters:
asiConfig- The container to track.
-
-
Method Details
-
getRowCount
public int getRowCount() -
getColumnCount
public int getColumnCount() -
getColumnName
- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel
-
getColumnClass
- Specified by:
getColumnClassin interfaceTableModel- Overrides:
getColumnClassin classAbstractTableModel
-
getValueAt
-
refresh
public final void refresh()Refreshes the table model by synchronizing with theAbstractAsiContainer. This method manages the attachment and detachment of per-session listeners. -
attachListeners
Attaches reactive property change listeners to the given AGI session. This registers the metrics listener for properties like nickname, summary, history, resources, and current status.- Parameters:
agi- The AGI session to attach listeners to.
-
detachListeners
Detaches reactive property change listeners from the given AGI session. This unregisters the metrics listener to prevent memory leaks.- Parameters:
agi- The AGI session to detach listeners from.
-
handleMetricsChange
Handles property change events from individual sessions to update specific rows.- Parameters:
evt- The property change event.
-
getAgiAt
Retrieves the agi session at the specified row index.- Parameters:
row- The model row index.- Returns:
- The session, or null if the index is out of bounds.
-
handleAsiChange
Handles property change events from the ASI container to trigger a refresh.- Parameters:
evt- The property change event.
-
dispose
public void dispose()Unregisters the listener from the container and cleans up the model.
-

