Class AbstractPartPanel<T extends AbstractPart>

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.jdesktop.swingx.JXPanel
org.jdesktop.swingx.JXTitledPanel
uno.anahata.asi.swing.components.CollapsibleTitledPanel
uno.anahata.asi.swing.agi.message.part.AbstractPartPanel<T>
Type Parameters:
T - The concrete type of AbstractPart that this panel renders.
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable
Direct Known Subclasses:
BlobPartPanel, ModelCodeExecutionCallPartPanel, ModelCodeExecutionResultPartPanel, ModelSearchCallPartPanel, TextPartPanel, ToolCallPanel

public abstract class AbstractPartPanel<T extends AbstractPart> extends CollapsibleTitledPanel
The abstract base class for rendering AbstractPart instances in a diff-based UI component. It leverages JXTitledPanel to provide a styled header with part metadata and pruning controls, and a content area that dynamically renders the part's specific content.
Author:
anahata
See Also:
  • Field Details

    • agiPanel

      protected final AgiPanel agiPanel
      The parent agi panel.
    • part

      protected final T extends AbstractPart part
      The part to be rendered.
    • agiConfig

      protected final SwingAgiConfig agiConfig
      The agi configuration.
    • pinButton

      private final JToggleButton pinButton
      Toggle button for pinning control.
    • pruneButton

      private final JToggleButton pruneButton
      Toggle button for pruning control.
    • copyButton

      private final JButton copyButton
      Button to copy the part content to the clipboard.
    • removeButton

      private final JButton removeButton
      Button to remove the part from the message.
    • remainingDepthLabel

      private final JLabel remainingDepthLabel
      Label to display the remaining depth for this part.
    • centralContainer

      private final org.jdesktop.swingx.JXPanel centralContainer
      Container for the part's specific content ("the beef").
    • footerContainer

      protected final JPanel footerContainer
      Container for part-level metadata and actions.
    • rightButtonPanel

      protected final JPanel rightButtonPanel
      Container for header actions on the right.
    • thoughtSignatureLabel

      private JLabel thoughtSignatureLabel
      Label for the thought signature, if present.
    • forceExpanded

      private boolean forceExpanded
      Flag to force the panel and its content to be visible and expanded regardless of state.
  • Constructor Details

    • AbstractPartPanel

      public AbstractPartPanel(@NonNull @NonNull AgiPanel agiPanel, @NonNull T part)
      Constructs a new AbstractPartPanel.
      Parameters:
      agiPanel - The parent agi panel.
      part - The part to be rendered.
  • Method Details

    • setForceExpanded

      public void setForceExpanded(boolean forceExpanded)
      Sets the forceExpanded flag, if true, the part will be expanded regardless of the expanded attribute of the AbstractPart.
      Parameters:
      forceExpanded - the new value
    • copyToClipboard

      protected void copyToClipboard()
      Copies the part's content to the system clipboard. Subclasses can override this to provide specialized copy behavior.
    • toggleExpanded

      protected void toggleExpanded()
      Invoked when the user clicks the header. Subclasses must implement their specific expand/collapse logic here.

      Toggles the expanded state of the part.

      Specified by:
      toggleExpanded in class CollapsibleTitledPanel
    • updateUI

      public void updateUI()

      Overridden to dynamically re-attach the header click listener whenever the UI delegate is updated (e.g., during a Look and Feel change).

      Overridden to dynamically update background colors and gradients when the Look and Feel changes.

      Overrides:
      updateUI in class CollapsibleTitledPanel
    • addNotify

      public void addNotify()
      Called when the component is added to its parent. Performs the initial render.
      Overrides:
      addNotify in class JComponent
    • render

      public final void render()
      Renders or updates the entire part panel, including its header and content.
    • refreshMetadata

      public void refreshMetadata()
      Refreshes the transient metadata in the header (e.g., remaining depth) without performing a full content re-render. This is called on every turn to ensure mathematical accuracy as the conversation flows.
    • updateBackgroundColors

      protected void updateBackgroundColors()
      Updates the background colors of the header based on the pruned state.
    • updateHeaderButtons

      protected void updateHeaderButtons()
      Updates the visibility of header buttons based on the parent message panel's flags.
    • updateRemainingDepthLabel

      protected void updateRemainingDepthLabel()
      Updates the text and visibility of the remaining depth label.
    • updateHeaderInfoText

      protected void updateHeaderInfoText()
      Updates the text displayed in the header's title.
    • renderFooterInternal

      private void renderFooterInternal()
      Internal method to set up and render the footer container, including the thought signature if present.
    • renderFooter

      protected void renderFooter()
      Template method for subclasses to add components to the part footer. Subclasses should use the footerContainer field directly.
    • renderContent

      protected abstract void renderContent()
      Template method for subclasses to render their specific content. Subclasses should use the centralContainer field directly.
    • updateContentVisibility

      protected void updateContentVisibility()
      Updates the visibility of the content container based on the part's pruned state.
    • updateVisibility

      protected void updateVisibility()
      Updates the visibility of the entire part panel based on the global configuration. If the part is effectively pruned and 'showPruned' is false, the entire component (including the header) is hidden from view.