Class DockingContext
FINE level using this class's logger.
Floating windows are tied to the stage hosting the pane they were floated from. When that host
stage is hidden, its floating windows are closed and their dockables are removed and disposed
without consulting close permissions, because the host is already gone at that point.
Applications whose dockables can veto closing, e.g. because of unsaved changes, should call
requestCloseAll() from the host stage's close request handler and consume the event
when it returns false.
-
Property Summary
PropertiesTypePropertyDescriptionfinal javafx.beans.property.BooleanPropertyControls whether users can rearrange existing dockables through docking gestures and built-in docking actions.final javafx.beans.property.BooleanPropertyControls whether dragging a dockable or tab group outside all panes creates a floating window.final javafx.beans.property.ObjectProperty<javafx.util.Callback<DockingContext, DockingPane>> Factory used to create panes for this context, including floating and restored panes.final javafx.beans.property.ObjectProperty<javafx.util.Callback<Dockable, javafx.scene.Node>> Factory creating the entire tab header for each dockable.final javafx.beans.property.ObjectProperty<BiFunction<DockingPane, List<Dockable>, javafx.scene.Node>> Factory for an optional node at the right edge of each tab group's header strip. -
Constructor Summary
ConstructorsConstructorDescriptionDockingContext(DockableFactory dockableFactory, DockingStageFactory stageFactory) Creates a context. -
Method Summary
Modifier and TypeMethodDescriptionfinal <E extends javafx.event.Event>
voidaddEventHandler(javafx.event.EventType<E> eventType, javafx.event.EventHandler<? super E> handler) Registers a handler for a docking event type and its subtypes.final booleancanAcceptDockableDrop(javafx.scene.input.DragEvent event) Tests whether an external drag may create a dockable without invoking the drop factory.final booleancanCloseDockable(Dockable dockable) Evaluates the dockable's close permission and the context's close policy without invoking the dockable's close request callback.final booleancanMoveTabGroup(DockingPane targetPane, String id, String targetId, DockingPosition position) Tests whether a dockable's entire tab group can move to the given target.Creates a pane attached to this context.final javafx.beans.property.BooleanPropertyControls whether users can rearrange existing dockables through docking gestures and built-in docking actions.dropDockable(DockingPane pane, javafx.scene.input.DragEvent event, String targetId, DockingPosition position) Creates and opens a dockable from an accepted drop, selecting it at the requested location.floatDockable(String id, double screenX, double screenY) Creates a new floating pane containing only the given dockable and positions its stage at the screen coordinates from the drag/drop event.final voidfloatDockableInternally(String id, javafx.geometry.Rectangle2D bounds) Moves one open dockable into an internal floating frame in its current pane.final javafx.beans.property.BooleanPropertyControls whether dragging a dockable or tab group outside all panes creates a floating window.final DockingPanefloatTabGroup(String id, double screenX, double screenY) Floats the entire tab group containing the given dockable in one window.final voidfloatTabGroupInternally(String id, javafx.geometry.Rectangle2D bounds) Moves an open dockable's entire tab group into an internal floating frame, preserving tab order and selection.final javafx.util.Callback<javafx.scene.input.DragEvent, Dockable> Returns the factory invoked only when an accepted external drag is dropped at a valid docking location.final Predicate<javafx.scene.input.DragEvent> Returns the predicate recognizing external drags that should create dockables.final DockableFactoryReturns the factory used to resolve dockables by ID.final javafx.collections.ObservableList<Dockable> Returns an unmodifiable view of all open dockables of this context.Captures the complete context-wide docking layout.final javafx.util.Callback<DockingContext, DockingPane> Gets the value of thepaneFactoryproperty.final DockingSelectionModelReturns the selection model spanning all panes in this context.final DockingStageFactoryReturns the factory used to create floating stages.final javafx.util.Callback<Dockable, javafx.scene.Node> Gets the value of thetabFactoryproperty.final BiFunction<DockingPane, List<Dockable>, javafx.scene.Node> Gets the value of thetabPaneHeaderFactoryproperty.final booleanGets the value of thedockingEnabledproperty.final booleanGets the value of thefloatingEnabledproperty.final booleanmoveTabGroup(DockingPane targetPane, String id, String targetId, DockingPosition position) Moves a dockable's entire tab group, preserving its order and selected tab.openDockable(DockingPane pane, String id, DockingPosition position) Opens the dockable with the given ID in the pane.final javafx.beans.property.ObjectProperty<javafx.util.Callback<DockingContext, DockingPane>> Factory used to create panes for this context, including floating and restored panes.final <E extends javafx.event.Event>
voidremoveEventHandler(javafx.event.EventType<E> eventType, javafx.event.EventHandler<? super E> handler) Removes a previously registered event handler.final booleanCloses every open dockable of this context, docked and floating, if all of them permit it.booleanrequestCloseDockable(Dockable dockable) Closes the dockable if its closeable property, close policy, and close request callback permit it.restoreLayout(DockingLayout layout) Restores a complete context-wide docking layout.final voidsetCanCloseDockable(Predicate<Dockable> policy) Sets the policy deciding whether a dockable may close;truemeans it may close.final voidsetDockableDropFactory(javafx.util.Callback<javafx.scene.input.DragEvent, Dockable> factory) Sets the factory creating a new dockable from the drop event.final voidsetDockableDropPredicate(Predicate<javafx.scene.input.DragEvent> predicate) Sets the lightweight predicate evaluated during drag-over and drop.final voidsetDockingEnabled(boolean enabled) Sets the value of thedockingEnabledproperty.final voidsetFloatingEnabled(boolean enabled) Sets the value of thefloatingEnabledproperty.final voidsetPaneFactory(javafx.util.Callback<DockingContext, DockingPane> factory) Sets the value of thepaneFactoryproperty.final voidsetTabFactory(javafx.util.Callback<Dockable, javafx.scene.Node> factory) Sets the value of thetabFactoryproperty.final voidsetTabPaneHeaderFactory(BiFunction<DockingPane, List<Dockable>, javafx.scene.Node> factory) Sets the value of thetabPaneHeaderFactoryproperty.final javafx.beans.property.ObjectProperty<javafx.util.Callback<Dockable, javafx.scene.Node>> Factory creating the entire tab header for each dockable.final javafx.beans.property.ObjectProperty<BiFunction<DockingPane, List<Dockable>, javafx.scene.Node>> Factory for an optional node at the right edge of each tab group's header strip.
-
Property Details
-
dockingEnabled
public final javafx.beans.property.BooleanProperty dockingEnabledPropertyControls whether users can rearrange existing dockables through docking gestures and built-in docking actions. Disabling this property does not restrict programmatic move operations.- See Also:
-
floatingEnabled
public final javafx.beans.property.BooleanProperty floatingEnabledPropertyControls whether dragging a dockable or tab group outside all panes creates a floating window. When disabled, the drop leaves the layout unchanged and the default tab group menu hides its float action. The default istrue. This setting does not restrict explicit programmatic floating operations or layout restoration.- See Also:
-
paneFactory
public final javafx.beans.property.ObjectProperty<javafx.util.Callback<DockingContext, DockingPane>> paneFactoryPropertyFactory used to create panes for this context, including floating and restored panes. The default creates aDockingPane. Each invocation must return a fresh, unparented, non-null pane belonging to the supplied context. The factory itself must not benull. It is invoked on the JavaFX application thread. Changes apply only to subsequently created panes. A primary pane already in use is retained when restoring a layout.- See Also:
-
tabFactory
public final javafx.beans.property.ObjectProperty<javafx.util.Callback<Dockable, javafx.scene.Node>> tabFactoryPropertyFactory creating the entire tab header for each dockable. The default creates aDockingTab, including its title, graphic, optional toolbar, actions menu and help button, and close button. Anullfactory also uses this default.The factory is invoked on the JavaFX application thread whenever tabs are rebuilt and must return a fresh, unparented, non-null node on every invocation. Changing the factory refreshes existing tabs in all panes of this context, including floating panes.
The workspace applies the
docking-tabstyle class, theselectedpseudo-class, accessibility, keyboard actions, and docking drag handlers to the returned node. A custom header supplies its own close button, if desired, invokingrequestCloseDockable(Dockable).- See Also:
-
tabPaneHeaderFactory
public final javafx.beans.property.ObjectProperty<BiFunction<DockingPane, List<Dockable>, javafx.scene.Node>> tabPaneHeaderFactoryPropertyFactory for an optional node at the right edge of each tab group's header strip. It receives the owning pane and an immutable snapshot of the group's dockables in tab order. The returned node is wrapped in a stack pane styled as an unselected tab. The factory or its result may benull; otherwise each invocation must return a fresh, unparented node. The default creates aDockingTabPaneHeaderfor closing, floating internally or in a window, docking internally floating groups back into their pane, and maximizing docked groups.The factory is invoked on the JavaFX application thread when groups are rebuilt, including when their membership changes. Changing it refreshes existing groups in all panes.
- See Also:
-
-
Constructor Details
-
DockingContext
Creates a context. The stage factory is only stored for later floating-window support.- Parameters:
dockableFactory- resolves dockables on explicit open requestsstageFactory- creates stages hosting panes
-
-
Method Details
-
getSelectionModel
Returns the selection model spanning all panes in this context.- Returns:
- the docking selection model
-
addEventHandler
public final <E extends javafx.event.Event> void addEventHandler(javafx.event.EventType<E> eventType, javafx.event.EventHandler<? super E> handler) Registers a handler for a docking event type and its subtypes. Handlers are called synchronously on the JavaFX application thread. They may perform nested docking operations; handler exceptions are logged and do not interrupt other handlers or required cleanup. Layout restoration does not emit docking events.- Type Parameters:
E- the event class- Parameters:
eventType- the event typehandler- the handler- Throws:
IllegalStateException- if called off the JavaFX application thread
-
removeEventHandler
public final <E extends javafx.event.Event> void removeEventHandler(javafx.event.EventType<E> eventType, javafx.event.EventHandler<? super E> handler) Removes a previously registered event handler.- Type Parameters:
E- the event class- Parameters:
eventType- the event typehandler- the handler- Throws:
IllegalStateException- if called off the JavaFX application thread
-
getDockableFactory
Returns the factory used to resolve dockables by ID.- Returns:
- the dockable factory
-
getStageFactory
Returns the factory used to create floating stages.- Returns:
- the stage factory
-
dockingEnabledProperty
public final javafx.beans.property.BooleanProperty dockingEnabledProperty()Controls whether users can rearrange existing dockables through docking gestures and built-in docking actions. Disabling this property does not restrict programmatic move operations.- Returns:
- the docking-enabled property
- See Also:
-
isDockingEnabled
public final boolean isDockingEnabled()Gets the value of thedockingEnabledproperty.- Property description:
- Controls whether users can rearrange existing dockables through docking gestures and built-in docking actions. Disabling this property does not restrict programmatic move operations.
- Returns:
- the value of the
dockingEnabledproperty - See Also:
-
setDockingEnabled
public final void setDockingEnabled(boolean enabled) Sets the value of thedockingEnabledproperty.- Property description:
- Controls whether users can rearrange existing dockables through docking gestures and built-in docking actions. Disabling this property does not restrict programmatic move operations.
- Parameters:
enabled- the value for thedockingEnabledproperty- See Also:
-
floatingEnabledProperty
public final javafx.beans.property.BooleanProperty floatingEnabledProperty()Controls whether dragging a dockable or tab group outside all panes creates a floating window. When disabled, the drop leaves the layout unchanged and the default tab group menu hides its float action. The default istrue. This setting does not restrict explicit programmatic floating operations or layout restoration.- Returns:
- the floating-enabled property
- See Also:
-
isFloatingEnabled
public final boolean isFloatingEnabled()Gets the value of thefloatingEnabledproperty.- Property description:
- Controls whether dragging a dockable or tab group outside all panes creates a floating
window. When disabled, the drop leaves the layout unchanged and the default tab group menu
hides its float action. The default is
true. This setting does not restrict explicit programmatic floating operations or layout restoration. - Returns:
- the value of the
floatingEnabledproperty - See Also:
-
setFloatingEnabled
public final void setFloatingEnabled(boolean enabled) Sets the value of thefloatingEnabledproperty.- Property description:
- Controls whether dragging a dockable or tab group outside all panes creates a floating
window. When disabled, the drop leaves the layout unchanged and the default tab group menu
hides its float action. The default is
true. This setting does not restrict explicit programmatic floating operations or layout restoration. - Parameters:
enabled- the value for thefloatingEnabledproperty- See Also:
-
paneFactoryProperty
public final javafx.beans.property.ObjectProperty<javafx.util.Callback<DockingContext, DockingPane>> paneFactoryProperty()Factory used to create panes for this context, including floating and restored panes. The default creates aDockingPane. Each invocation must return a fresh, unparented, non-null pane belonging to the supplied context. The factory itself must not benull. It is invoked on the JavaFX application thread. Changes apply only to subsequently created panes. A primary pane already in use is retained when restoring a layout.- Returns:
- the pane factory property
- See Also:
-
getPaneFactory
Gets the value of thepaneFactoryproperty.- Property description:
- Factory used to create panes for this context, including floating and restored panes.
The default creates a
DockingPane. Each invocation must return a fresh, unparented, non-null pane belonging to the supplied context. The factory itself must not benull. It is invoked on the JavaFX application thread. Changes apply only to subsequently created panes. A primary pane already in use is retained when restoring a layout. - Returns:
- the value of the
paneFactoryproperty - See Also:
-
setPaneFactory
Sets the value of thepaneFactoryproperty.- Property description:
- Factory used to create panes for this context, including floating and restored panes.
The default creates a
DockingPane. Each invocation must return a fresh, unparented, non-null pane belonging to the supplied context. The factory itself must not benull. It is invoked on the JavaFX application thread. Changes apply only to subsequently created panes. A primary pane already in use is retained when restoring a layout. - Parameters:
factory- the value for thepaneFactoryproperty- See Also:
-
tabFactoryProperty
public final javafx.beans.property.ObjectProperty<javafx.util.Callback<Dockable, javafx.scene.Node>> tabFactoryProperty()Factory creating the entire tab header for each dockable. The default creates aDockingTab, including its title, graphic, optional toolbar, actions menu and help button, and close button. Anullfactory also uses this default.The factory is invoked on the JavaFX application thread whenever tabs are rebuilt and must return a fresh, unparented, non-null node on every invocation. Changing the factory refreshes existing tabs in all panes of this context, including floating panes.
The workspace applies the
docking-tabstyle class, theselectedpseudo-class, accessibility, keyboard actions, and docking drag handlers to the returned node. A custom header supplies its own close button, if desired, invokingrequestCloseDockable(Dockable).- Returns:
- the tab factory property
- See Also:
-
getTabFactory
Gets the value of thetabFactoryproperty.- Property description:
- Factory creating the entire tab header for each dockable. The default creates a
DockingTab, including its title, graphic, optional toolbar, actions menu and help button, and close button. Anullfactory also uses this default.The factory is invoked on the JavaFX application thread whenever tabs are rebuilt and must return a fresh, unparented, non-null node on every invocation. Changing the factory refreshes existing tabs in all panes of this context, including floating panes.
The workspace applies the
docking-tabstyle class, theselectedpseudo-class, accessibility, keyboard actions, and docking drag handlers to the returned node. A custom header supplies its own close button, if desired, invokingrequestCloseDockable(Dockable). - Returns:
- the value of the
tabFactoryproperty - See Also:
-
setTabFactory
Sets the value of thetabFactoryproperty.- Property description:
- Factory creating the entire tab header for each dockable. The default creates a
DockingTab, including its title, graphic, optional toolbar, actions menu and help button, and close button. Anullfactory also uses this default.The factory is invoked on the JavaFX application thread whenever tabs are rebuilt and must return a fresh, unparented, non-null node on every invocation. Changing the factory refreshes existing tabs in all panes of this context, including floating panes.
The workspace applies the
docking-tabstyle class, theselectedpseudo-class, accessibility, keyboard actions, and docking drag handlers to the returned node. A custom header supplies its own close button, if desired, invokingrequestCloseDockable(Dockable). - Parameters:
factory- the value for thetabFactoryproperty- See Also:
-
tabPaneHeaderFactoryProperty
public final javafx.beans.property.ObjectProperty<BiFunction<DockingPane, List<Dockable>, javafx.scene.Node>> tabPaneHeaderFactoryProperty()Factory for an optional node at the right edge of each tab group's header strip. It receives the owning pane and an immutable snapshot of the group's dockables in tab order. The returned node is wrapped in a stack pane styled as an unselected tab. The factory or its result may benull; otherwise each invocation must return a fresh, unparented node. The default creates aDockingTabPaneHeaderfor closing, floating internally or in a window, docking internally floating groups back into their pane, and maximizing docked groups.The factory is invoked on the JavaFX application thread when groups are rebuilt, including when their membership changes. Changing it refreshes existing groups in all panes.
- Returns:
- the tab pane header factory property
- See Also:
-
getTabPaneHeaderFactory
Gets the value of thetabPaneHeaderFactoryproperty.- Property description:
- Factory for an optional node at the right edge of each tab group's header strip.
It receives the owning pane and an immutable snapshot of the group's dockables in tab order.
The returned node is wrapped in a stack pane styled as an unselected tab. The factory or
its result may be
null; otherwise each invocation must return a fresh, unparented node. The default creates aDockingTabPaneHeaderfor closing, floating internally or in a window, docking internally floating groups back into their pane, and maximizing docked groups.The factory is invoked on the JavaFX application thread when groups are rebuilt, including when their membership changes. Changing it refreshes existing groups in all panes.
- Returns:
- the value of the
tabPaneHeaderFactoryproperty - See Also:
-
setTabPaneHeaderFactory
public final void setTabPaneHeaderFactory(BiFunction<DockingPane, List<Dockable>, javafx.scene.Node> factory) Sets the value of thetabPaneHeaderFactoryproperty.- Property description:
- Factory for an optional node at the right edge of each tab group's header strip.
It receives the owning pane and an immutable snapshot of the group's dockables in tab order.
The returned node is wrapped in a stack pane styled as an unselected tab. The factory or
its result may be
null; otherwise each invocation must return a fresh, unparented node. The default creates aDockingTabPaneHeaderfor closing, floating internally or in a window, docking internally floating groups back into their pane, and maximizing docked groups.The factory is invoked on the JavaFX application thread when groups are rebuilt, including when their membership changes. Changing it refreshes existing groups in all panes.
- Parameters:
factory- the value for thetabPaneHeaderFactoryproperty- See Also:
-
getDockableDropPredicate
Returns the predicate recognizing external drags that should create dockables.- Returns:
- the acceptance predicate, initially rejecting all events
-
setDockableDropPredicate
Sets the lightweight predicate evaluated during drag-over and drop. It must not create dockables or mutate the layout. Reject unrelated content drags so their events remain available to dockable content.- Parameters:
predicate- the non-null acceptance predicate
-
getDockableDropFactory
Returns the factory invoked only when an accepted external drag is dropped at a valid docking location.- Returns:
- the drop factory, or
nullif external docking is disabled
-
setDockableDropFactory
public final void setDockableDropFactory(javafx.util.Callback<javafx.scene.input.DragEvent, Dockable> factory) Sets the factory creating a new dockable from the drop event. The dockable must have a unique ID in this context. Returningnulldeclines the drop without changing the layout.- Parameters:
factory- the drop factory, ornullto disable external docking
-
canAcceptDockableDrop
public final boolean canAcceptDockableDrop(javafx.scene.input.DragEvent event) Tests whether an external drag may create a dockable without invoking the drop factory.- Parameters:
event- the drag event- Returns:
trueif a factory is configured and the predicate accepts the event
-
dropDockable
public final Optional<Dockable> dropDockable(DockingPane pane, javafx.scene.input.DragEvent event, String targetId, DockingPosition position) Creates and opens a dockable from an accepted drop, selecting it at the requested location. The factory is called once, after validating the target. Existing dockables are never replaced.- Parameters:
pane- the destination pane belonging to this contextevent- the drop event passed to the factorytargetId- the target dockable ID, ornullfor an outer edge or an empty paneposition- the requested docking position; CENTER with a null target requires an empty pane- Returns:
- the new dockable, or empty if the target or event is rejected or the factory declines
- Throws:
IllegalStateException- if called off the FX thread or the factory returns an already-open ID
-
createPane
-
openDockable
Opens the dockable with the given ID in the pane. If the ID is already open, the existing dockable is activated instead. The dockable factory is only consulted for IDs that are not yet open.- Parameters:
pane- a pane created by this contextid- the dockable IDposition- the requested position- Returns:
- the opened or activated dockable, or empty if the factory cannot resolve the ID
- Throws:
IllegalArgumentException- if the pane belongs to another contextIllegalStateException- if called off the FX thread, the factory returns a dockable with another ID, or the returned instance is currently being closed
-
floatDockable
Creates a new floating pane containing only the given dockable and positions its stage at the screen coordinates from the drag/drop event.- Parameters:
id- the dockable IDscreenX- target screen x coordinatescreenY- target screen y coordinate- Returns:
- the floating pane, or
nullif the source pane has a maximized group
-
floatTabGroup
Floats the entire tab group containing the given dockable in one window. Tab order and the group's selected tab are preserved.- Parameters:
id- a dockable in the group to floatscreenX- target screen x coordinatescreenY- target screen y coordinate- Returns:
- the floating pane, or
nullif the source pane has a maximized group - Throws:
IllegalArgumentException- if the dockable is not open in this context
-
floatDockableInternally
Moves one open dockable into an internal floating frame in its current pane. Does not create a window and is independent offloatingEnabledProperty(). Does nothing while the pane has a maximized group.- Parameters:
id- the open dockable IDbounds- requested bounds relative to the pane's content area- Throws:
IllegalArgumentException- if the ID or geometry is invalid
-
floatTabGroupInternally
Moves an open dockable's entire tab group into an internal floating frame, preserving tab order and selection. Does nothing while the pane has a maximized group.- Parameters:
id- any open dockable in the groupbounds- requested bounds relative to the pane's content area- Throws:
IllegalArgumentException- if the ID or geometry is invalid
-
getLayout
Captures the complete context-wide docking layout.- Returns:
- immutable layout snapshot
-
restoreLayout
Restores a complete context-wide docking layout. Restore replaces the current layout regardless of close permissions and disposes dockable instances that are not reused in the restored layout.- Parameters:
layout- the layout to restore- Returns:
- restore result containing unresolved dockable IDs
-
requestCloseDockable
Closes the dockable if its closeable property, close policy, and close request callback permit it. A veto leaves the panes and this context unchanged. A successfully removed dockable is disposed.- Parameters:
dockable- the dockable to close- Returns:
trueonly if the dockable was open and has been removed- Throws:
IllegalStateException- if called off the FX thread
-
requestCloseAll
public final boolean requestCloseAll()Closes every open dockable of this context, docked and floating, if all of them permit it. Each dockable's closeable property, the close policy, and its close request callback are consulted first; a single veto leaves the context unchanged. Approved dockables are removed and disposed, and emptied floating windows are closed.Call this from the close request handler of the host stage and consume the event when it returns
false; see the class documentation.- Returns:
trueif all dockables have been closed,falseif one of them vetoed- Throws:
IllegalStateException- if called off the FX thread
-
getDockables
Returns an unmodifiable view of all open dockables of this context.- Returns:
- the open dockables
-
setCanCloseDockable
-
canCloseDockable
Evaluates the dockable's close permission and the context's close policy without invoking the dockable's close request callback.- Parameters:
dockable- the dockable- Returns:
trueif the dockable may close
-
canMoveTabGroup
public final boolean canMoveTabGroup(DockingPane targetPane, String id, String targetId, DockingPosition position) Tests whether a dockable's entire tab group can move to the given target. Anulltarget ID addresses a pane-wide edge, or an empty pane for a center drop. Drops back onto the source group are rejected, as are moves involving a pane with a maximized group.- Parameters:
targetPane- the destination pane in this contextid- a dockable in the source grouptargetId- a dockable in the target group, ornullfor the whole paneposition- the docking position- Returns:
- whether the move is valid
-
moveTabGroup
public final boolean moveTabGroup(DockingPane targetPane, String id, String targetId, DockingPosition position) Moves a dockable's entire tab group, preserving its order and selected tab. Center drops append the tabs to the target group; edge drops create one new group. The selected tab's preferred docking size is used for the new group.- Parameters:
targetPane- the destination pane in this contextid- a dockable in the source grouptargetId- a dockable in the target group, ornullfor a pane-wide edge or empty paneposition- the docking position- Returns:
trueif the move completed, orfalsewithout changes for an invalid target
-