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
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:
-
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 TypeFieldDescriptionprotected final SwingAgiConfigThe agi configuration.protected final AgiPanelThe parent agi panel.private final org.jdesktop.swingx.JXPanelContainer for the part's specific content ("the beef").private final JButtonButton to copy the part content to the clipboard.protected final JPanelContainer for part-level metadata and actions.private booleanFlag to force the panel and its content to be visible and expanded regardless of state.protected final TThe part to be rendered.private final JToggleButtonToggle button for pinning control.private final JToggleButtonToggle button for pruning control.private final JLabelLabel to display the remaining depth for this part.private final JButtonButton to remove the part from the message.protected final JPanelContainer for header actions on the right.private JLabelLabel for the thought signature, if present.Fields inherited from class org.jdesktop.swingx.JXTitledPanel
LEFT_DECORATION, RIGHT_DECORATION, uiClassIDFields 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
ConstructorsConstructorDescriptionAbstractPartPanel(@NonNull AgiPanel agiPanel, T part) Constructs a new AbstractPartPanel. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when the component is added to its parent.protected voidCopies the part's content to the system clipboard.voidRefreshes the transient metadata in the header (e.g., remaining depth) without performing a full content re-render.final voidrender()Renders or updates the entire part panel, including its header and content.protected abstract voidTemplate method for subclasses to render their specific content.protected voidTemplate method for subclasses to add components to the part footer.private voidInternal method to set up and render the footer container, including the thought signature if present.voidsetForceExpanded(boolean forceExpanded) Sets the forceExpanded flag, if true, the part will be expanded regardless of the expanded attribute of the AbstractPart.protected voidInvoked when the user clicks the header.protected voidUpdates the background colors of the header based on the pruned state.protected voidUpdates the visibility of the content container based on the part's pruned state.protected voidUpdates the visibility of header buttons based on the parent message panel's flags.protected voidUpdates the text displayed in the header's title.protected voidUpdates the text and visibility of the remaining depth label.voidupdateUI()protected voidUpdates the visibility of the entire part panel based on the global configuration.Methods inherited from class CollapsibleTitledPanel
getHeaderComponentMethods inherited from class org.jdesktop.swingx.JXTitledPanel
getContentContainer, getLeftDecoration, getRightDecoration, getTitle, getTitleFont, getTitleForeground, getTitlePainter, getUI, getUIClassID, setContentContainer, setLeftDecoration, setRightDecoration, setTitle, setTitleFont, setTitleForeground, setTitlePainter, setUIMethods inherited from class org.jdesktop.swingx.JXPanel
getAlpha, getBackgroundPainter, getEffectiveAlpha, getPainterChangeListener, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableHeightHint, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollableWidthHint, isAlpha, isInheritAlpha, isOpaque, isOpaquePatch, isPaintBorderInsets, isPaintingBackground, isPaintingOrigin, isPatch, isTransparentBackground, paint, paintComponent, paintComponentPatch, setAlpha, setBackgroundPainter, setInheritAlpha, setOpaque, setOpaquePatch, setPaintBorderInsets, setScrollableHeightHint, setScrollableTracksViewportHeight, setScrollableTracksViewportWidth, setScrollableWidthHintMethods inherited from class JPanel
getAccessibleContext, paramString, setUIMethods inherited from class JComponent
addAncestorListener, 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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, 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, 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
-
agiPanel
The parent agi panel. -
part
The part to be rendered. -
agiConfig
The agi configuration. -
pinButton
Toggle button for pinning control. -
pruneButton
Toggle button for pruning control. -
copyButton
Button to copy the part content to the clipboard. -
removeButton
Button to remove the part from the message. -
remainingDepthLabel
Label to display the remaining depth for this part. -
centralContainer
private final org.jdesktop.swingx.JXPanel centralContainerContainer for the part's specific content ("the beef"). -
rightButtonPanel
Container for header actions on the right. -
thoughtSignatureLabel
Label for the thought signature, if present. -
forceExpanded
private boolean forceExpandedFlag to force the panel and its content to be visible and expanded regardless of state.
-
-
Constructor Details
-
AbstractPartPanel
-
-
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:
toggleExpandedin classCollapsibleTitledPanel
-
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:
updateUIin classCollapsibleTitledPanel
-
addNotify
public void addNotify()Called when the component is added to its parent. Performs the initial render.- Overrides:
addNotifyin classJComponent
-
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. -
renderContent
protected abstract void renderContent()Template method for subclasses to render their specific content. Subclasses should use thecentralContainerfield 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.
-

