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 String
Key constant used within the drag contextMap
to indicate whether floating is allowed for a given drag operation.static final String
System property key used during framework initialization to determine the default setting for global floating support. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPolicy
(FloatPolicy policy) Adds the specifiedFloatPolicy
to the internal policy collection.void
dragStarted
(DockingEvent evt) This method catchesDockingEvents
per theDockingListener
interface at the start of a drag operation and initializes floating support within the the contextMap
of the drag operation.void
dropStarted
(DockingEvent evt) This method catchesDockingEvents
per theDockingListener
interface at the end of a drag operation and determines whether or not to block attempts to float within the docking operation.static FloatPolicyManager
Returns a singleton instance of theFloatPolicyManager
class.static boolean
isFloatingAllowed
(Dockable dockable) Indicates whether floating is allowed for the specifiedDockable
.static boolean
Returns a global setting used to control default framework floating behavior.boolean
isPolicyFloatingSupported
(Dockable dockable) Indicates whether floating is allowed for the specifiedDockable
strictly by checking the installedFloatPolicies
.void
removePolicy
(FloatPolicy policy) Removes the specifiedFloatPolicy
from the internal policy collection.static void
setGlobalFloatingEnabled
(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 contextMap
to 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 theFloatPolicyManager
class.- Returns:
- a singleton instance of the
FloatPolicyManager
class.
-
dragStarted
This method catchesDockingEvents
per theDockingListener
interface at the start of a drag operation and initializes floating support within the the contextMap
of the drag operation. This method retrieves theDockable
for the event via itsgetDockable()
method. It also retrieves the drag contextMap
for theDockingEvent
by invoking itsgetDragContext()
method. This map is the sameMap
returned byDragManager.getDragContext(Dockable dockable)
. It then callsisPolicyFloatingSupported(Dockable dockable)
for theDockable
and places eitherBoolean.TRUE
orBoolean.FALSE
within the drag contextMap
, caching the value for use throughout the drag operation to avoid successive iterations through the entire installedFloatPolicy
collection. TheMap
-key used isFLOATING_ALLOWED
.- Specified by:
dragStarted
in interfaceDockingListener
- Overrides:
dragStarted
in classDockingListener.Stub
- Parameters:
evt
- theDockingEvent
whose drag context is to be initialized for floating support- See Also:
-
dropStarted
This method catchesDockingEvents
per theDockingListener
interface 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's
Dockable
, retrieved fromgetDockable()
. If this method returnsfalse
, then theDockingEvent
is consumed and this method returns.If
isFloatingAllowed(Dockable dockable)
returnstrue
, then the internalFloatPolicy
collection is iterated through, allowing each installedFloatPolicy
to confirm the drop operation viaisFloatDropAllowed(DockingEvent evt)
. If any of the installedFloatPolicies
returnsfalse
forisFloatDropAllowed(DockingEvent evt)
, then theDockingEvent
is consumed and the method exits.If this method completes without the
DockingEvent
being consumed, then the docking operation will proceed and attempts to float will be allowed.- Specified by:
dropStarted
in interfaceDockingListener
- Overrides:
dropStarted
in classDockingListener.Stub
- Parameters:
evt
- theDockingEvent
to be examined for floating support- See Also:
-
isFloatingAllowed
Indicates whether floating is allowed for the specifiedDockable
. Ifdockable
isnull
, this method returnsfalse
.This method first calls
DragManager.getDragContext(Dockable dockable)
to see if a drag operation is in progress. If so, it returns theboolean
value 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 installedFloatPolicies
to determine whether floating support is allowed.- Parameters:
dockable
- theDockable
whose floating support is to be checked- Returns:
true
if floating is allowed for the specifiedDockable
;false
otherwise.- See Also:
-
isPolicyFloatingSupported
Indicates whether floating is allowed for the specifiedDockable
strictly by checking the installedFloatPolicies
. Ifdockable
isnull
, this method returnsfalse
immediately without checking through the installedFloatPolicies
.This method iterates through all installed
FloatPolicies
to determine whether floating support is allowed. If anyFloatPolicy
within the internal collection returnsfalse
from itsisFloatingAllowed(Dockable dockable)
method, this method returnsfalse
. Otherwise, this method returnstrue
.- Parameters:
dockable
- theDockable
whose floating support is to be checked- Returns:
true
if floating is allowed for the specifiedDockable
;false
otherwise.- See Also:
-
addPolicy
Adds the specifiedFloatPolicy
to the internal policy collection. ThisFloatPolicy
will now take part in framework determinations as to whether floating should be supported during docking operations. Ifpolicy
isnull
, no action is taken.- Parameters:
policy
- theFloatPolicy
to add to the system- See Also:
-
removePolicy
Removes the specifiedFloatPolicy
from the internal policy collection.FloatPolicy
will no longer take part in framework determinations as to whether floating should be supported during docking operations. Ifpolicy
isnull
or was not previously installed, no action is taken.- Parameters:
policy
- theFloatPolicy
to 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:
true
if global floating support is enabled;false
otherwise.- See Also:
-
setGlobalFloatingEnabled
public static void setGlobalFloatingEnabled(boolean globalFloatingEnabled) Sets the global setting used to control default framework floating behavior. IfglobalFloatingEnabled
isfalse
, all floating support for the entire framework is turned off. IfglobalFloatingEnabled
istrue
, then floating support for individual docking operations is deferred to the installedFloatPolicies
.- Parameters:
globalFloatingEnabled
-true
if global floating support is to be enabled;false
otherwise.- See Also:
-