Class AbstractTextResourceViewer
- All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
- Direct Known Subclasses:
IntellijTextResourceViewer, NetBeansTextResourceViewer, RSyntaxTextAreaTextResourceViewer
This class provides the integrated control strip containing the Edit/Save toggle.
Capability Purity: The Capability View (this component) always displays the full source content of the resource. Semantic processing like Tail, Grep, or Viewport-injected line numbers are reserved exclusively for the 'Model Perspective' (RAG) to ensure the user always has a clean, authoritative view of the source.
- Author:
- anahata
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceContract for handling the persistent write of the editor content.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 JPanelThe panel hosting the edit and save buttons.protected final AgiPanelThe parent AgiPanel providing the session context.protected JButtonThe button to cancel editing without saving.protected final CardLayoutThe layout manager for swapping between preview and editor views.protected final JPanelThe container panel for the card layout.protected final AbstractAsiContainerThe parent AbstractAsiContainer providing the container context.protected JToolBarThe integrated toolbar for edit actions.protected JButtonThe button to copy the current content to clipboard.protected JButtonThe button to toggle between View and Edit modes.protected booleanFlag indicating the current UI mode (view vs edit).protected booleanIf true, the 'Preview' mode uses the high-fidelity editor component (read-only) instead of the viewport.protected final ResourceThe resource orchestrator being viewed.private EdtPropertyChangeListenerThe reactive listener for resource state changes.protected AbstractTextResourceViewer.SaveActionThe delegate responsible for persistence.private booleanFlag used to disable listeners during UI synchronization to prevent recursive feedback loops.protected booleanFlag indicating if vertical scrolling is enabled.Fields 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
ConstructorsModifierConstructorDescriptionprotectedAbstractTextResourceViewer(AbstractAsiContainer container, Resource resource) Constructs a new AbstractTextResourceViewer bound to a container context.protectedAbstractTextResourceViewer(AgiPanel agiPanel, Resource resource) Constructs a new AbstractTextResourceViewer bound to a session context. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDiscovers the internal JScrollPane and applies the current scroll behavior settings.protected abstract JComponentCreates the editable high-fidelity component for full-file modifications.protected abstract JComponentCreates the read-only preview component for displaying processed resource content.abstract StringRetrieves the current text content from the editor component for persistence.Returns the managed resource orchestrator.abstract JScrollPaneReturns the internal scroll pane used by the concrete implementation.private voidInitializes the UI components and assemblies the integrated control strip.protected abstract voidHook invoked when switching to the editor card.protected abstract voidHook invoked when returning to the preview card.protected abstract voidsetComponentEditable(boolean editable) Authoritatively toggles the editability of the internal text component.voidsetEditButtonVisible(boolean visible) Controls the visibility of the Edit button in the control strip.voidsetEditing(boolean editing) Updates the UI to reflect the current editing state.voidsetReadOnly(boolean readOnly) Authoritatively configures the viewer for read-only mode.voidsetToolbarVisible(boolean visible) Controls the visibility of the entire integrated control strip.voidsetVerticalScrollEnabled(boolean enabled) Configures whether vertical scrolling is enabled in the internal scroll pane.protected voidSynchronizes UI controls with current resource state.voidToggles between read-only viewport view and high-fidelity editor.protected abstract voidupdatePreviewContent(String content) Pushes incremental or full content updates to the preview component.Methods inherited from class JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class JComponent
addAncestorListener, addNotify, 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, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, 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, setOpaque, 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 AgiPanel providing the session context. -
container
The parent AbstractAsiContainer providing the container context. -
resource
The resource orchestrator being viewed. -
cardLayout
The layout manager for swapping between preview and editor views. -
cardPanel
The container panel for the card layout. -
controlStrip
The integrated toolbar for edit actions. -
actionNexus
The panel hosting the edit and save buttons. -
editBtn
The button to toggle between View and Edit modes. -
cancelBtn
The button to cancel editing without saving. -
copyBtn
The button to copy the current content to clipboard. -
editing
protected boolean editingFlag indicating the current UI mode (view vs edit). -
syncing
private boolean syncingFlag used to disable listeners during UI synchronization to prevent recursive feedback loops. -
verticalScrollEnabled
protected boolean verticalScrollEnabledFlag indicating if vertical scrolling is enabled. Defaults to true (Resource Panel). Should be set to false for Chat Snippets. -
previewAsEditor
protected boolean previewAsEditorIf true, the 'Preview' mode uses the high-fidelity editor component (read-only) instead of the viewport. This ensures snippets don't lose text when saving.Clean-Room Default: snippets (virtual resources) default to true.
-
saveAction
The delegate responsible for persistence. -
resourceListener
The reactive listener for resource state changes.
-
-
Constructor Details
-
AbstractTextResourceViewer
-
AbstractTextResourceViewer
Constructs a new AbstractTextResourceViewer bound to a container context.- Parameters:
container- The parent AbstractAsiContainer.resource- The text resource.
-
-
Method Details
-
getResource
Returns the managed resource orchestrator.- Returns:
- The resource instance.
-
initComponents
private void initComponents()Initializes the UI components and assemblies the integrated control strip. -
toggleEditMode
public void toggleEditMode()Toggles between read-only viewport view and high-fidelity editor. -
setEditing
public void setEditing(boolean editing) Updates the UI to reflect the current editing state.For snippets, this method ensures we stay on the high-fidelity card but toggle component editability.
- Parameters:
editing- true to enable editing.
-
setEditButtonVisible
public void setEditButtonVisible(boolean visible) Controls the visibility of the Edit button in the control strip.- Parameters:
visible- true to show the edit button, false to hide it.
-
setReadOnly
public void setReadOnly(boolean readOnly) Authoritatively configures the viewer for read-only mode. This hides the edit button and ensures the component is not in edit mode.- Parameters:
readOnly- true to force read-only mode.
-
setToolbarVisible
public void setToolbarVisible(boolean visible) Controls the visibility of the entire integrated control strip.- Parameters:
visible- true to show the toolbar.
-
setVerticalScrollEnabled
public void setVerticalScrollEnabled(boolean enabled) Configures whether vertical scrolling is enabled in the internal scroll pane.High-Fidelity Scroll Passthrough: If vertical scrolling is disabled (e.g., in chat snippets), this method recursively finds the innermost text component and installs a boundary-aware mouse wheel redispatcher.
- Parameters:
enabled- true to enable standard vertical scrolling.
-
configureScrollBehavior
protected void configureScrollBehavior()Discovers the internal JScrollPane and applies the current scroll behavior settings.Implementation details: Finds the JScrollPane inside the assembled host frame and installs the boundary-aware redispatcher on the "Event Leaf" component.
-
getScrollPane
Returns the internal scroll pane used by the concrete implementation.- Returns:
- The JScrollPane instance.
-
createPreviewComponent
Creates the read-only preview component for displaying processed resource content.- Returns:
- The preview component.
-
createEditorComponent
Creates the editable high-fidelity component for full-file modifications.- Returns:
- The editor component.
-
setComponentEditable
protected abstract void setComponentEditable(boolean editable) Authoritatively toggles the editability of the internal text component.- Parameters:
editable- true to allow input.
-
onEditorActivated
protected abstract void onEditorActivated()Hook invoked when switching to the editor card. -
onPreviewActivated
protected abstract void onPreviewActivated()Hook invoked when returning to the preview card. -
getEditorContent
Retrieves the current text content from the editor component for persistence.- Returns:
- The content string.
-
updatePreviewContent
Pushes incremental or full content updates to the preview component. Used for streaming fidelity during generation.- Parameters:
content- The new preview content.
-
syncWithResource
protected void syncWithResource()Synchronizes UI controls with current resource state.SENSING PURITY: The Capability View always displays the full, authoritative source content from the handle. Semantic viewport processing (tail/grep) is only visible to the model in the RAG view.
-

