Class TextStateStore

java.lang.Object
com.vaadin.swingbridge.surrogates.internal.TextStateStore

public final class TextStateStore extends Object
State holder for JTextComponentMixin (SD_sjtextfield). Same ComponentUtil.setData(Component, SerializableTriConsumer, T, U) pattern as ButtonStateStore — keeps the mixin self-contained without forcing every concrete consumer (SJTextField / future SJPasswordField / SJTextArea) to expose abstract getters/setters as boilerplate.

What does NOT live here

  • editable — read directly from peer.isReadOnly() per the R_vaadin_first Vaadin-first stance (SD_vaadin_first_binding). No shadow store needed.
  • listenerList for ActionListener — JTextField-specific, not shared with JTextArea. Lives on the concrete (SJTextField) per SD_sjpanel's "concrete-specific state stays on the concrete" call.
  • columns / horizontalAlignment / rows / lineWrap — JDK declares these on JTextField and JTextArea individually, not on JTextComponent. Each concrete owns its own.
  • Field Details

    • document

      public Document document
      The installed Document. Lazy-initialised by the mixin's install hook.
    • docToPeer

      public DocumentListener docToPeer
      Single shared DocumentListener that pushes Document mutations into the peer under preventPeerEvents. Created lazily on first install; persists across setDocument swaps. Internal glue, not user-supplied API.
    • preventPeerEvents

      public boolean preventPeerEvents
      R_swing_is_truth feedback-loop guard — same shape SJSlider / SJSpinner / :emulators.JTextComponent use. Set true before peer writes; cleared in finally; checked at the top of both directional listeners.
    • dot

      public int dot
      Swing's two-value caret model — selectionStart = min(dot, mark), selectionEnd = max(dot, mark), and dot == mark means a bare caret with nothing selected.

      Write-only mirror: the mixin pushes these to the browser and never reads them back, so a caret the *user* moved leaves them stale. Reads clamp to the Document length — JTextComponentMixin.getCaretPosition() carries the contract.

    • mark

      public int mark
    • caretListeners

      public final List<CaretListener> caretListeners
      Caret listeners, and the ChangeListeners a Caret takes — both fan out on every dot/mark move, server-initiated or read back from the browser.

      Legitimate under R_vaadin_first (not a shadow cache) because a real Vaadin subscription stands behind them: the emul-selection DOM listener the mixin installs on the peer element.

    • caretChangeListeners

      public final List<ChangeListener> caretChangeListeners
    • selectionBridgeInstalled

      public boolean selectionBridgeInstalled
      Set once the browser-side selection bridge has been wired, so a second install is a no-op.
    • selectionReporterInstalled

      public boolean selectionReporterInstalled
      Set once the client-side selection reporter has been installed on the input element.
    • caret

      public Caret caret
      The one Caret view handed out for this component. Cached because Swing's getCaret() returns a stable instance and code compares against it — e.getSource() == field.getCaret() is a real idiom, and a fresh object per call would make it silently false.
  • Method Details

    • of

      public static TextStateStore of(com.vaadin.flow.component.Component target)