feat(fx): add overlay groups and atomic floating window close

This commit is contained in:
2026-11-15 23:06:34 +01:00
parent 0aa9f7fae3
commit bff6257dfe
32 changed files with 2220 additions and 142 deletions
+44 -2
View File
@@ -1,4 +1,4 @@
# Asynchronous tab close
# Asynchronous tab and floating-window close
Use `Dockable.setCloseCheck` to supply a `CompletionStage<CloseConsent>`.
The callback receives the request scope and the JavaFX window hosting the
@@ -25,5 +25,47 @@ The `CloseDockingMain` launcher in the example module shows a pending close
without a nested event loop. Choose Close Notes, then Keep open and continue
editing. Request close again and choose Allow close. Until that decision, Notes
remains open; after approval its resource callback runs. The same demonstration
works through the tab's close control. Window-wide shutdown is added by the
works through the tab's close control. Main-window shutdown is added by the
later lifecycle slices; this example demonstrates individual tab consent.
## Closing a floating window
`requestFloatingWindowClose(windowId)` and the floating Stage's window close
control use one atomic workflow. The manager snapshots the window's Dockables
in layout/tab order and asks each sequentially, including after a veto or failed
check. Every callback receives the same `FLOATING_WINDOW` scope and the owning
floating Stage. No tab is detached before all answers allow closure. Application
saves already completed by a callback remain saved if a later callback vetoes.
The running scope protects the entire window against structural changes.
Duplicate window requests and tab requests covered by that running window
request share its outcome. Independent requests queue in order; a veto does not
cancel the next independent window. Content remains editable while decisions
are pending. There is no blocking wait or nested JavaFX event loop.
After unanimous consent, all affected content is detached and the completed
layout is published once. Then every `onClosed` callback runs, even if an earlier
cleanup fails. `Closed.cleanupFailures()` reports those failures. The scope stays
observable until cleanup finishes. Unknown/already closed floating IDs return
`NoChange`; the main-window ID is rejected by this floating-only entry point.
Main-window and manager shutdown, including the shutdown snapshot callback,
belong to the later shutdown slices.
The example launcher is
`de.neitzel.fx.example.docking.FloatingCloseDockingMain`. It creates First and
Second in one floating window plus Other in an independent window. Its saves
are in-memory demonstration snapshots in the log, not filesystem writes.
1. Choose **Close Editors**, then **Save and allow** for First and **Keep open**
for Second. Both editors remain open and First's saved text stays in the log.
2. Close Editors again; veto First. Second is still asked. Answer it to finish
the request without closing either editor.
3. While a decision is pending, use **Repeat Editors close** and **Close Second
tab**. They report the same result without additional prompts.
4. During that pending request, choose **Close Other window**. Its prompt starts
after the Editors request ends, including when Editors was vetoed.
5. Approve both Editors. The window disappears before either release log entry.
The floating window's native close control follows the same sequence.
The demo's main Stage is only a control panel; closing it hides its demonstration
windows. This is separate from the future application-wide shutdown protocol.