Class FloatPolicyManager
- All Implemented Interfaces:
EventListener,DockingListener
This class contains a method isGlobalFloatingEnabled() that indicates
whether global floating support is enabled. If global floating support is
disabled, then the setting governs all docking operations and blocks floating
in a global sense. If global floating support is enabled, then floating is
allowed or disallowed on an individual operation-by-operation basis through a
set of FloatPolicy implementations.
The default setting for global floating support is false. This,
however, may be controlled by the system property FLOATING_ALLOWED.
If the framework starts up with a case-sensitive String value of
"true" for this system property, then global floating support will be
turned on by default. Otherwise, global floating support may be modified via
setGlobalFloatingEnabled(boolean globalFloatingEnabled).
This class provides methods addPolicy(FloatPolicy policy) and
removePolicy(FloatPolicy policy), allowing the user to implement
custom behavior to control floating support for individual docking operations
on an event-by-event basis. By default, the FloatPolicyManager has a
single FloatPolicy installed of type DefaultFloatPolicy.
- Author:
- Christopher Butler
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.flexdock.docking.event.DockingListener
DockingListener.Stub -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringKey constant used within the drag contextMapto indicate whether floating is allowed for a given drag operation.static final StringSystem property key used during framework initialization to determine the default setting for global floating support. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPolicy(FloatPolicy policy) Adds the specifiedFloatPolicyto the internal policy collection.voiddragStarted(DockingEvent evt) This method catchesDockingEventsper theDockingListenerinterface at the start of a drag operation and initializes floating support within the the contextMapof the drag operation.voiddropStarted(DockingEvent evt) This method catchesDockingEventsper theDockingListenerinterface at the end of a drag operation and determines whether or not to block attempts to float within the docking operation.static FloatPolicyManagerReturns a singleton instance of theFloatPolicyManagerclass.static booleanisFloatingAllowed(Dockable dockable) Indicates whether floating is allowed for the specifiedDockable.static booleanReturns a global setting used to control default framework floating behavior.booleanisPolicyFloatingSupported(Dockable dockable) Indicates whether floating is allowed for the specifiedDockablestrictly by checking the installedFloatPolicies.voidremovePolicy(FloatPolicy policy) Removes the specifiedFloatPolicyfrom the internal policy collection.static voidsetGlobalFloatingEnabled(boolean globalFloatingEnabled) Sets the global setting used to control default framework floating behavior.Methods inherited from class org.flexdock.docking.event.DockingListener.Stub
dockingCanceled, dockingComplete, undockingComplete, undockingStarted
-
Field Details
-
FLOATING_ALLOWED
Key constant used within the drag contextMapto indicate whether floating is allowed for a given drag operation.- See Also:
-
GLOBAL_FLOATING_ENABLED
System property key used during framework initialization to determine the default setting for global floating support.- See Also:
-
-
Method Details
-
getInstance
Returns a singleton instance of theFloatPolicyManagerclass.- Returns:
- a singleton instance of the
FloatPolicyManagerclass.
-
dragStarted
This method catchesDockingEventsper theDockingListenerinterface at the start of a drag operation and initializes floating support within the the contextMapof the drag operation. This method retrieves theDockablefor the event via itsgetDockable()method. It also retrieves the drag contextMapfor theDockingEventby invoking itsgetDragContext()method. This map is the sameMapreturned byDragManager.getDragContext(Dockable dockable). It then callsisPolicyFloatingSupported(Dockable dockable)for theDockableand places eitherBoolean.TRUEorBoolean.FALSEwithin the drag contextMap, caching the value for use throughout the drag operation to avoid successive iterations through the entire installedFloatPolicycollection. TheMap-key used isFLOATING_ALLOWED.- Specified by:
dragStartedin interfaceDockingListener- Overrides:
dragStartedin classDockingListener.Stub- Parameters:
evt- theDockingEventwhose drag context is to be initialized for floating support- See Also:
-
dropStarted
This method catchesDockingEventsper theDockingListenerinterface at the end of a drag operation and determines whether or not to block attempts to float within the docking operation.If
evt.isOverWindow()returnstrue, then the drop operation is over an existing window and will be interpreted as an attempt to dock within the window, not an attempt to float into a new dialog. In this case, this method returns immediately with no action taken.This method calls
isFloatingAllowed(Dockable dockable)using theDockingEvent'sDockable, retrieved fromgetDockable(). If this method returnsfalse, then theDockingEventis consumed and this method returns.If
isFloatingAllowed(Dockable dockable)returnstrue, then the internalFloatPolicycollection is iterated through, allowing each installedFloatPolicyto confirm the drop operation viaisFloatDropAllowed(DockingEvent evt). If any of the installedFloatPoliciesreturnsfalseforisFloatDropAllowed(DockingEvent evt), then theDockingEventis consumed and the method exits.If this method completes without the
DockingEventbeing consumed, then the docking operation will proceed and attempts to float will be allowed.- Specified by:
dropStartedin interfaceDockingListener- Overrides:
dropStartedin classDockingListener.Stub- Parameters:
evt- theDockingEventto be examined for floating support- See Also:
-
isFloatingAllowed
Indicates whether floating is allowed for the specifiedDockable. Ifdockableisnull, this method returnsfalse.This method first calls
DragManager.getDragContext(Dockable dockable)to see if a drag operation is in progress. If so, it returns thebooleanvalue contained within the drag context map using the keyFLOATING_ALLOWED. If no mapping exists for the specified key, this method returnsfalse.If no drag operation is currently in progress and no drag context can be found, this method dispatches to
isPolicyFloatingSupported(Dockable dockable), which iterates through all installedFloatPoliciesto determine whether floating support is allowed.- Parameters:
dockable- theDockablewhose floating support is to be checked- Returns:
trueif floating is allowed for the specifiedDockable;falseotherwise.- See Also:
-
isPolicyFloatingSupported
Indicates whether floating is allowed for the specifiedDockablestrictly by checking the installedFloatPolicies. Ifdockableisnull, this method returnsfalseimmediately without checking through the installedFloatPolicies.This method iterates through all installed
FloatPoliciesto determine whether floating support is allowed. If anyFloatPolicywithin the internal collection returnsfalsefrom itsisFloatingAllowed(Dockable dockable)method, this method returnsfalse. Otherwise, this method returnstrue.- Parameters:
dockable- theDockablewhose floating support is to be checked- Returns:
trueif floating is allowed for the specifiedDockable;falseotherwise.- See Also:
-
addPolicy
Adds the specifiedFloatPolicyto the internal policy collection. ThisFloatPolicywill now take part in framework determinations as to whether floating should be supported during docking operations. Ifpolicyisnull, no action is taken.- Parameters:
policy- theFloatPolicyto add to the system- See Also:
-
removePolicy
Removes the specifiedFloatPolicyfrom the internal policy collection.FloatPolicywill no longer take part in framework determinations as to whether floating should be supported during docking operations. Ifpolicyisnullor was not previously installed, no action is taken.- Parameters:
policy- theFloatPolicyto remove from the system- See Also:
-
isGlobalFloatingEnabled
public static boolean isGlobalFloatingEnabled()Returns a global setting used to control default framework floating behavior. If this method returnsfalse, all floating support for the entire framework is turned off. If this method returnstrue, then floating support for individual docking operations is deferred to the installedFloatPolicies.- Returns:
trueif global floating support is enabled;falseotherwise.- See Also:
-
setGlobalFloatingEnabled
public static void setGlobalFloatingEnabled(boolean globalFloatingEnabled) Sets the global setting used to control default framework floating behavior. IfglobalFloatingEnabledisfalse, all floating support for the entire framework is turned off. IfglobalFloatingEnabledistrue, then floating support for individual docking operations is deferred to the installedFloatPolicies.- Parameters:
globalFloatingEnabled-trueif global floating support is to be enabled;falseotherwise.- See Also:
-