Class AbstractContextNode<T>
java.lang.Object
uno.anahata.asi.swing.agi.context.AbstractContextNode<T>
- Type Parameters:
T- The type of the underlying domain object wrapped by this node.
- Direct Known Subclasses:
ContextManagerNode, ContextProviderNode, HistoryNode, MessageNode, PartNode, ResourceNode, ResourcesNode, ToolkitNode, ToolManagerNode, ToolNode, ToolsNode
The base class for all nodes in the hierarchical context tree.
This class provides a unified interface for the ContextTreeTableModel
to interact with different types of domain objects (Providers, Toolkits,
Tools) while maintaining a consistent JNDI-style view.
It implements a hierarchical token aggregation system and an identity-preserving child synchronization mechanism to ensure UI stability during refreshes.
- Author:
- anahata
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AgiPanelThe parent agi panel.protected List<AbstractContextNode<?>> The cached list of child nodes.protected intCached declaration token count (including children).protected intCached history token count (including children).protected intCached instruction token count (including children).protected intCached RAG token count (including children).protected StringCached status string.protected final TThe underlying domain object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidCalculates the token counts for this node's own content (excluding children).protected abstract AbstractContextNode<?> createChildNode(Object userObject) Creates a new child node for the given domain object.booleanEquality is based on the underlying userObject and the node class.protected abstract List<?> Fetches the current list of domain objects that should be represented as children of this node.getAgi()Gets the parent agi session.final List<AbstractContextNode<?>> Gets the list of child nodes for this node.abstract StringGets a detailed description of the node's purpose or content.getIcon()Gets an optional icon for this node by delegating to theIconProviderconfigured in the agi session.abstract StringgetName()Gets the human-readable display name for this node.inthashCode()abstract booleanisActive()Checks if the underlying domain object is currently active in the context.final voidrefresh()Refreshes the node's state, including its child list and token counts.final voidRecursively recalculates token counts and status for this node and its descendants.final voidDeprecated.toString()Returns the display name of the node.protected abstract voidUpdates the status string for this node.
-
Field Details
-
agiPanel
The parent agi panel. -
userObject
The underlying domain object. -
children
The cached list of child nodes. -
instructionsTokens
protected int instructionsTokensCached instruction token count (including children). -
declarationsTokens
protected int declarationsTokensCached declaration token count (including children). -
historyTokens
protected int historyTokensCached history token count (including children). -
ragTokens
protected int ragTokensCached RAG token count (including children). -
status
Cached status string.
-
-
Constructor Details
-
AbstractContextNode
public AbstractContextNode()
-
-
Method Details
-
getAgi
-
getName
Gets the human-readable display name for this node.- Returns:
- The name to be displayed in the tree.
-
getDescription
Gets a detailed description of the node's purpose or content.- Returns:
- The description string.
-
getChildren
Gets the list of child nodes for this node. Implementation details: Returns the cached child list, initializing it viarefresh()if necessary.- Returns:
- A list of child AbstractContextNodes.
-
refresh
public final void refresh()Refreshes the node's state, including its child list and token counts.This method implements an identity-preserving synchronization logic: it updates the child list by reusing existing node instances for domain objects that are still present.
-
refreshData
public final void refreshData()Recursively recalculates token counts and status for this node and its descendants. This method is designed to be called from a background thread via SwingTask. -
fetchChildObjects
Fetches the current list of domain objects that should be represented as children of this node.- Returns:
- A list of domain objects.
-
createChildNode
Creates a new child node for the given domain object.- Parameters:
userObject- The domain object to wrap.- Returns:
- A new AbstractContextNode, or null if the object type is not supported.
-
refreshTokens
Deprecated.Userefresh()instead for a unified update.Recalculates and caches the token counts and status for this node and all its descendants. -
calculateLocalTokens
protected abstract void calculateLocalTokens()Calculates the token counts for this node's own content (excluding children). -
updateStatus
protected abstract void updateStatus()Updates the status string for this node. -
getIcon
Gets an optional icon for this node by delegating to theIconProviderconfigured in the agi session.- Returns:
- The icon, or null if no specialized icon is available.
-
isActive
public abstract boolean isActive()Checks if the underlying domain object is currently active in the context.Subclasses override this method to define their specific active-state policy, allowing for clean, polymorphic evaluation without dirty instanceof chains.
- Returns:
trueif active,falseotherwise.
-
equals
-
hashCode
-
toString
-


refresh()instead for a unified update.