Skip to content

Show a caller-owned component in a composition with movableComponentOf - #49

Merged
Ivan Matkov (MatkovIvan) merged 1 commit into
masterfrom
ivan.matkov/movable-component-of
Nov 23, 2026
Merged

Ivan Matkov (MatkovIvan) merged 1 commit into
masterfrom
ivan.matkov/movable-component-of

Conversation

@MatkovIvan

Copy link
Copy Markdown
Collaborator
  • API
    • movableComponentOf(component) returns a MovableComponent that places a component the caller built and keeps. Call it with a SwingModifier where the component should stand.
    • A changed key, an if/else between containers or a move into a nested content composition relocates the component instead of replacing it.
    • PlacingNodeHolder is the new shared base of CreatedNodeHolder.
    • SwingNode and ExistingSwingNode point to it in their KDoc, and the SwingNodeFactoryReusesComponent message names it.
  • Behavior
    • Placing takes the component out of the container it stands in. Ending the placement restores what the modifier wrote and takes the component out of the container the placement put it in. The caller adds it back where it keeps it, and does not add it to another container while its call stays composed.
    • Two calls standing at once in one Recomposer throw IllegalStateException. Under independent roots, such as two windows, the call composed last takes the component over.

@MatkovIvan
Ivan Matkov (MatkovIvan) force-pushed the ivan.matkov/movable-component-of branch from e7a551b to 1b2720c Compare November 23, 2026 18:09
…ovableComponentOf

Code that builds a component in a plain Swing tree and lends it to composed UI had no correct path. ExistingSwingNode never places the component, and a SwingNode factory that returns an existing component is replaced, not moved, when a key or branch changes, so the component ends in the wrong parent.

movableComponentOf(component) returns a MovableComponent whose call places the component with a modifier. One component has one MovableComponent, so a key change, an if/else or a nested content composition relocates the same node. When the placement ends, the modifier's writes are given back and the component leaves the container the placement put it in; the caller puts it back where it keeps it. Two calls composed at once in one Recomposer are refused before anything is written. Across Recomposers the newer call takes the component over, and the superseded call stays empty until it is inserted again.

CreatedNodeHolder and the new caller holder share placement through PlacingNodeHolder.

No dedicated unwind runs when apply fails: a claim that survives the failure is cleared when the component is next placed from another Recomposer, as for the rest of a dead composition.
@MatkovIvan
Ivan Matkov (MatkovIvan) force-pushed the ivan.matkov/movable-component-of branch from 1b2720c to 7e207fe Compare November 23, 2026 18:22
@MatkovIvan
Ivan Matkov (MatkovIvan) merged commit 7e207fe into master Nov 23, 2026
4 checks passed
@MatkovIvan
Ivan Matkov (MatkovIvan) deleted the ivan.matkov/movable-component-of branch November 23, 2026 18:33

This branch was successfully deployed

1 active deployment
github-pages — 7e207fe7 Deployed Nov 23, 2026 by MatkovIvan via Publish API Reference #59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant