Class TreeStateStore

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

public final class TreeStateStore extends Object
State holder for SJTree (SD_sjtree).

Holds only R_vaadin_first-legitimate state — UI-functionality source-of-truth (the two models), navigation machinery (the identity parent map backing Vaadin's getParent/getItemIndex contract + the SD_sjtree_selection_bridge selection-path bridge), the SD_sjtree_hierarchy_render hierarchy-column render seam, behaviour gates and live registrations. No round-trip shadow caches: JTree's no-Vaadin-counterpart knobs (showsRootHandles, rowHeight, toggleClickCount, visibleRowCount, …) round-trip on the emulator layer per R_swing_is_truth — the asymmetric split SJToolBar (SD_sjtoolbar) / SJSplitPane (SD_sjsplitpane) / SJList (SD_sjlist) established.

Source-of-truth fields per R_swing_is_truth:

Both are JDK types reused per D_event_port_policy — the entire javax.swing.tree.* model/path/selection surface touches no java.awt.Component.
  • Field Details

    • model

      public TreeModel model
      Source of truth for the tree's nodes (R_swing_is_truth). Never null after ctor.
    • selectionModel

      public TreeSelectionModel selectionModel
      Source of truth for path-set selection state. Never null after ctor.
    • selectionModeListener

      public PropertyChangeListener selectionModeListener
      Listener installed on selectionModel that watches the "selectionMode" PCE (DefaultTreeSelectionModel fires it from setSelectionMode) and re-maps the Vaadin Grid selection mode. JDK code idiomatically calls tree.getSelectionModel().setSelectionMode(...) — there is no JTree.setSelectionMode — so the surrogate must observe the model, not a setter of its own. Moved across setSelectionModel swaps.
    • parentMap

      public final IdentityHashMap<Object,Object> parentMap
      child → parent identity map, recorded on every fetchChildrenFromBackEnd walk (SD_sjtree_lazy_provider). Legitimate machinery, not an R_vaadin_first shadow cache: Vaadin's HierarchicalDataProvider requires getParent/getItemIndex for TreeGrid.scrollToItem, and the SD_sjtree_selection_bridge selection bridge needs node→TreePath reconstruction — the JDK TreeModel has no getParent, so this map is the only way to walk up. Identity-keyed to match SD_sjtree_node_identity's node-identity stance.
    • componentProvider

      public Function<Object, com.vaadin.flow.component.Component> componentProvider
      SD_sjtree_hierarchy_render hierarchy-column render seam. The single addComponentHierarchyColumn installed in the SJTree ctor reads this function live per render call — TreeGrid's expand/collapse toggle chrome lives in HierarchyColumnComponentRenderer's template, so the renderer itself is never re-installed; swapping render behaviour (the emulator's D_jtree_renderer_registry JDK-TreeCellRenderer bridge) swaps this function instead. Defaults to a fresh-per-call Span of the node's text (D_jcombobox DOM-adoption guard).
    • rootVisible

      public boolean rootVisible
      Whether the model root renders as a Vaadin top-level item (JDK default true). false reshapes the data provider's root level: the root hides and its children become top-level (SD_sjtree_lazy_provider). Drives real data- provider behaviour — a gate, not a round-trip shadow.
    • preventPeerEvents

      public boolean preventPeerEvents
      R_swing_is_truth feedback-loop guard. Set during selection pushes in both directions (JDK model → Grid, Grid → JDK model) so the cascade doesn't double-fire. Same shape SJTable / SJList take.
    • clickNodeStash

      public Object clickNodeStash
      Node / visible-row-index of the item whose click is currently being dispatched, or null/-1 outside a dispatch. Set/cleared around the SMouseListener fan-out in SJTree.addMouseListener's item-click wire so getRowForLocation / getPathForLocation resolve during the user's mousePressed/mouseClicked handler (R_layouts_close_enough — no server-side pixel→row map; the CaseTreeView.selectOnRightClick idiom). Fields, not thread-locals: the emulator re-source may drain the dispatch in a UI fiber, and shared state survives that boundary (SD_sjlist's stash rationale).
    • clickRowStash

      public int clickRowStash
    • vaadinSelectionRegistration

      public com.vaadin.flow.shared.Registration vaadinSelectionRegistration
      Vaadin Grid SelectionListener registration that mirrors browser-side selection edits into the selectionModel. Re-installed on every selection-mode re-map since Vaadin re-creates the Grid's internal selection backing on mode swap (SD_sjtable_selection_bridge/SD_sjlist).
  • Method Details

    • of

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