Class RSyntaxTextAreaTextResourceViewer
- All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
This viewer implements the AbstractTextResourceViewer contract,
providing high-fidelity syntax highlighting and a professional Edit/Save
experience for standalone environments.
Fidelity Singularity: For virtual resources (snippets), this viewer uses a single RSyntax component pair for both View and Edit modes to prevent library-level gutter duplication and layout desyncs.
- Author:
- anahata
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractTextResourceViewer
AbstractTextResourceViewer.SaveActionNested 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 TypeFieldDescriptionprivate org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaThe RSyntax area used for the editor card.private org.fife.ui.rtextarea.RTextScrollPaneThe scroll pane wrapping the editor area.private org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaThe RSyntax area used for the preview/viewport card.private org.fife.ui.rtextarea.RTextScrollPaneThe scroll pane wrapping the preview area.Fields inherited from class AbstractTextResourceViewer
actionNexus, agiPanel, cancelBtn, cardLayout, cardPanel, container, controlStrip, copyBtn, editBtn, editing, previewAsEditor, resource, saveAction, verticalScrollEnabledFields 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
ConstructorsConstructorDescriptionRSyntaxTextAreaTextResourceViewer(AbstractAsiContainer container, Resource resource) Constructs a new RSyntaxTextAreaTextResourceViewer bound to a container context.RSyntaxTextAreaTextResourceViewer(AgiPanel agiPanel, Resource resource) Constructs a new RSyntaxTextAreaTextResourceViewer. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDiscovers the internal JScrollPane and applies the current scroll behavior settings.protected JComponentCreates the editable high-fidelity component for full-file modifications.protected JComponentCreates the read-only preview component for displaying processed resource content.private org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaInternal factory for RSyntaxTextArea with standard ASI styling.Retrieves the current text content from the editor component for persistence.Returns the internal scroll pane used by the concrete implementation.private voidinstallWheelForwarder(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea area) Installs the boundary-aware wheel redispatcher on an RSyntaxTextArea.static StringmapLanguageToSyntax(String language) Maps a language string or file name to an RSyntaxTextArea syntax style constant.protected voidHook invoked when switching to the editor card.protected voidHook invoked when returning to the preview card.protected voidsetComponentEditable(boolean editable) Authoritatively toggles the editability of the internal text component.protected voidSynchronizes UI controls with current resource state.protected voidupdatePreviewContent(String content) Pushes incremental or full content updates to the preview component.Methods inherited from class AbstractTextResourceViewer
getResource, setEditButtonVisible, setEditing, setReadOnly, setToolbarVisible, setVerticalScrollEnabled, toggleEditModeMethods 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, 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
-
previewArea
private org.fife.ui.rsyntaxtextarea.RSyntaxTextArea previewAreaThe RSyntax area used for the preview/viewport card. -
editorArea
private org.fife.ui.rsyntaxtextarea.RSyntaxTextArea editorAreaThe RSyntax area used for the editor card. -
previewScrollPane
private org.fife.ui.rtextarea.RTextScrollPane previewScrollPaneThe scroll pane wrapping the preview area. -
editorScrollPane
private org.fife.ui.rtextarea.RTextScrollPane editorScrollPaneThe scroll pane wrapping the editor area.
-
-
Constructor Details
-
RSyntaxTextAreaTextResourceViewer
-
RSyntaxTextAreaTextResourceViewer
Constructs a new RSyntaxTextAreaTextResourceViewer bound to a container context.- Parameters:
container- The parent container.resource- The resource to render.
-
-
Method Details
-
createPreviewComponent
Creates the read-only preview component for displaying processed resource content.Implementation details: Creates a read-only RSyntaxTextArea wrapped in an RTextScrollPane. If
previewAsEditoris true, this method returns a dummy panel as the editor component will handle both modes to prevent gutter duplication.- Specified by:
createPreviewComponentin classAbstractTextResourceViewer- Returns:
- The preview component.
-
createEditorComponent
Creates the editable high-fidelity component for full-file modifications.Implementation details: Creates an editable RSyntaxTextArea wrapped in an RTextScrollPane for full-file modifications. In snippet mode, this component is used for both View and Edit states.
- Specified by:
createEditorComponentin classAbstractTextResourceViewer- Returns:
- The editor component.
-
createRSyntaxArea
private org.fife.ui.rsyntaxtextarea.RSyntaxTextArea createRSyntaxArea()Internal factory for RSyntaxTextArea with standard ASI styling.- Returns:
- A styled RSyntaxTextArea instance.
-
setComponentEditable
protected void setComponentEditable(boolean editable) Authoritatively toggles the editability of the internal text component.Implementation details: Authoritatively toggles the editability of the internal components. If snippets are using the single-component strategy, it only affects the editorArea.
- Specified by:
setComponentEditablein classAbstractTextResourceViewer- Parameters:
editable- true to allow input.
-
onEditorActivated
protected void onEditorActivated()Hook invoked when switching to the editor card.Implementation details: Loads the full text content from the resource handle into the editor area and resets the caret position to ensure a clean editing start.
- Specified by:
onEditorActivatedin classAbstractTextResourceViewer
-
onPreviewActivated
protected void onPreviewActivated()Hook invoked when returning to the preview card.Implementation details: Disables the editor's editability and triggers a synchronization with the resource's latest viewport data.
- Specified by:
onPreviewActivatedin classAbstractTextResourceViewer
-
getEditorContent
Retrieves the current text content from the editor component for persistence.Implementation details: Returns the current text from the underlying RSyntaxTextArea.
- Specified by:
getEditorContentin classAbstractTextResourceViewer- Returns:
- The content string.
-
updatePreviewContent
Pushes incremental or full content updates to the preview component. Used for streaming fidelity during generation.Implementation details: Authoritative streaming ingestion point. Updates the active RSyntax area with incremental content, ensuring bit-by-bit generation fidelity.
- Specified by:
updatePreviewContentin classAbstractTextResourceViewer- 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.
Implementation details: Performs a complete UI synchronization with the resource state. Ensures snippets are visible immediately by falling back to the handle's text if the viewport cache is not yet populated.
- Overrides:
syncWithResourcein classAbstractTextResourceViewer
-
getScrollPane
Returns the internal scroll pane used by the concrete implementation.- Specified by:
getScrollPanein classAbstractTextResourceViewer- Returns:
- The JScrollPane instance.
-
getPreferredSize
When vertical scrolling is disabled, ensures sufficient height so the horizontal scrollbar does not obscure the bottom line of text.
- Overrides:
getPreferredSizein classJComponent
-
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.
Implementation details: Recursively finds the internal RSyntaxTextArea and installs the boundary-aware mouse wheel redispatcher to enable scroll passthrough.
- Overrides:
configureScrollBehaviorin classAbstractTextResourceViewer
-
installWheelForwarder
private void installWheelForwarder(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea area) Installs the boundary-aware wheel redispatcher on an RSyntaxTextArea.- Parameters:
area- The text area component.
-
mapLanguageToSyntax
-

