feat(fx): move live tabs with checked destinations and drag previews

This commit is contained in:
2026-11-15 20:20:50 +01:00
parent 39261de098
commit af5a4278fd
18 changed files with 1077 additions and 17 deletions
+28
View File
@@ -0,0 +1,28 @@
# Moving tabs in the main window
Drag a tab header to another group's content area to append it. Dropping on
a tab strip inserts at the displayed marker, including when reordering within
the same group. The tab's text/icon bindings and its live content stay intact.
All four tab sides are supported.
The move preview uses the same `checkMove` rules as an application command.
Placement is checked again on release. A rejected location has no marker;
a move that would leave the tab where it is uses a muted marker. Escape
cancels a pending gesture. Releasing over another part of the managed window,
outside the docking groups, leaves the Dockable in place.
Every tab also provides a **Move to** context submenu. It lists the currently
available groups and the selected content's current title. Rejected targets
are disabled with their reason; selecting an enabled item invokes the same
manager move operation and rechecks the destination.
The preview is mouse-transparent and has CSS class `dock-drop-indicator`.
Its `no-change` pseudo-class identifies a preview that leaves the current
placement intact. Applications may style its fill and stroke using JavaFX CSS.
This slice covers the main window. Splitting, floating, cross-window pointer
delivery and edge overlays extend these gestures in their respective tickets.
The gesture regression tests fire JavaFX events at visible tab headers and
observe the public manager state. Those tests do not by themselves establish
native mouse delivery across windows; that has a separate desktop acceptance
sequence.
+52 -6
View File
@@ -11,8 +11,8 @@ to a `DockPane`, and embed that pane in your main Stage's Scene. Then call
`DockingManager.attach(stage, pane, new DockingOptions())`. Attachment is allowed
before showing the Stage. A pane and main Stage can each have one active manager.
The initial definition is captured; later changes to the definition do not alter
the attached layout. `DockingOptions` currently has no policy fields in this
first implementation slice.
the attached layout. The manager also captures the placement rule from
`DockingOptions`; replacing that option later does not replace the live policy.
A Dockable consists of a stable `DockableId` and the existing content Node.
Use `open(dockable, DockTarget.area("editors"))` to open it. Opening an ID that
@@ -36,14 +36,60 @@ destinations are included. A selected-tab change publishes its completed state.
application actions. Moving keyboard focus to a global button preserves it.
`activate(id)` selects the Dockable and requests focus within its content.
The content instance remains owned by the application. Future docking slices
extend this API with movement, splits, close consent and restoration.
The content instance remains owned by the application. A supplied
`setFocusTarget` chooses a Node within the content; otherwise the manager tries
the previously focused descendant. Future slices add splits, close consent
and restoration.
## Move and check placement
The [pointer and context-menu guide](docking-drag.md) describes drag previews,
relative insertion and cancellation in the main window.
`move(id, target)` transfers the same content instance to a named area or a
concrete group. An area's default insertion position is the end. Group targets
also accept `TabPosition.before(id)` and `after(id)` for exact ordering.
```java
var destination = DockTarget.group(toolsGroupId, TabPosition.before(projectId));
MoveCheck check = manager.checkMove(notesId, destination);
if (check instanceof MoveCheck.Allowed) {
ActionResult result = manager.move(notesId, destination);
// Handle Applied, NoChange or Rejected in application presentation code.
}
```
The check reports the currently resolved insertion, no change or a rejection.
It does not mutate the layout. Execution resolves and checks again, so menus
must handle a later rejection. Missing groups and missing reference tabs have
distinct failure codes. One successful move publishes its completed layout
once and selects, activates and focuses the destination content.
Set `DockingOptions.setPlacementRule` before attachment to supply a policy.
It receives the Dockable and concrete proposed destination, returning an empty
Optional to permit it or a DockFailure to reject it. The rule must be
side-effect-free. Opening and moving use the same policy; a thrown policy
exception becomes a diagnostic rejection without a layout change.
## Lazy content and rejected opens
`open(id, factory, target)` calls the factory on the FX thread only when the
ID is not already open. Reopening an ID activates its existing content, even
when the caller specifies a different destination. Use move to change placement.
If the manager-created content is rejected, its `onDiscarded` callback releases
resources exactly once for that preparation. A directly supplied Dockable
stays with the caller on rejection. A failed discard is reported through the
original rejection: its diagnostic cause retains any original cause and lists
the cleanup exception as a suppressed exception. Moving does not discard content.
Factory load failures and mismatched IDs are rejected with diagnostics; a
factory cannot discard an instance that is already open.
## Java and FXML example
The `fx-example` module includes `de.neitzel.fx.example.docking.DockingMain`.
Its Java-built layout and `--fxml` variant open the same editor and right-side
tool groups. It demonstrates unsaved editor text, tab selection and a global
Activate Notes action without MVVM. Build the reactor with Java 25, then launch
tool groups. It demonstrates unsaved editor text, tab selection, activation and
movement without MVVM. Build the reactor with Java 25, then launch
that main class using the example's runtime dependencies; no Designer build is
required.