Class ContextTreeTableModel
java.lang.Object
org.jdesktop.swingx.treetable.AbstractTreeTableModel
uno.anahata.asi.swing.agi.context.ContextTreeTableModel
- All Implemented Interfaces:
TreeModel, org.jdesktop.swingx.treetable.TreeTableModel
public class ContextTreeTableModel
extends org.jdesktop.swingx.treetable.AbstractTreeTableModel
A TreeTableModel that provides a hierarchical, JNDI-style view of the entire
AI context using unified AbstractContextNodes.
This model is designed for high performance and UI stability. It preserves node identity across refreshes, ensuring that the tree view remains stable (no jumping or collapsing) when the underlying context changes.
It uses a single ContextManagerNode as the root of the hierarchy.
- Author:
- anahata
-
Field Summary
FieldsFields inherited from class org.jdesktop.swingx.treetable.AbstractTreeTableModel
modelSupport, root -
Constructor Summary
ConstructorsConstructorDescriptionContextTreeTableModel(AgiPanel agiPanel) Constructs a new ContextTreeTableModel. -
Method Summary
Modifier and TypeMethodDescriptionImplementation details: Delegates to the parent node's getChildren() method.intgetChildCount(Object parent) Implementation details: Delegates to the parent node's getChildren().size().Class<?> getColumnClass(int column) intgetColumnName(int column) intgetIndexOfChild(Object parent, Object child) Implementation details: Performs a standard indexOf search in the child list.getValueAt(Object node, int column) Implementation details: Delegates value retrieval to the AbstractContextNode based on the column index.booleanImplementation details: A node is a leaf if its getChildren() list is empty.final voidrefresh()Refreshes the model's data from the ContextManager and notifies the view of the change.voidrefreshTokens(Runnable onDone) Triggers an asynchronous recalculation of token counts for all nodes in the tree.Methods inherited from class org.jdesktop.swingx.treetable.AbstractTreeTableModel
addTreeModelListener, getHierarchicalColumn, getRoot, getTreeModelListeners, isCellEditable, removeTreeModelListener, setValueAt, valueForPathChanged
-
Field Details
-
agiPanel
The parent agi panel.
-
-
Constructor Details
-
ContextTreeTableModel
Constructs a new ContextTreeTableModel.- Parameters:
agiPanel- The parent agi panel.
-
-
Method Details
-
refresh
public final void refresh()Refreshes the model's data from the ContextManager and notifies the view of the change.Implementation details: It preserves the root node instance if it already exists, triggering a recursive refresh of the node hierarchy.
To prevent the 'jumping' behavior, it uses identity-preserving nodes and fires a structure change event on the root.
-
refreshTokens
Triggers an asynchronous recalculation of token counts for all nodes in the tree. Uses SwingTask to run the calculation pass on a background thread.- Parameters:
onDone- An optional callback to run on the EDT after the refresh is complete.
-
getColumnCount
public int getColumnCount() -
getColumnName
- Specified by:
getColumnNamein interfaceorg.jdesktop.swingx.treetable.TreeTableModel- Overrides:
getColumnNamein classorg.jdesktop.swingx.treetable.AbstractTreeTableModel
-
getColumnClass
- Specified by:
getColumnClassin interfaceorg.jdesktop.swingx.treetable.TreeTableModel- Overrides:
getColumnClassin classorg.jdesktop.swingx.treetable.AbstractTreeTableModel
-
getValueAt
-
getChild
-
getChildCount
Implementation details: Delegates to the parent node's getChildren().size(). -
getIndexOfChild
-
isLeaf
-

