Class FloatPolicyManager
- java.lang.Object
-
- org.flexdock.docking.event.DockingListener.Stub
-
- org.flexdock.docking.floating.policy.FloatPolicyManager
-
- All Implemented Interfaces:
java.util.EventListener
,DockingListener
public class FloatPolicyManager extends DockingListener.Stub
This class provides centralized control over the framework's floating behavior. This includes global behavior and behavior local to each individual docking operation.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 ofFloatPolicy
implementations.The default setting for global floating support is
false
. This, however, may be controlled by the system propertyFLOATING_ALLOWED
. If the framework starts up with a case-sensitiveString
value of"true"
for this system property, then global floating support will be turned on by default. Otherwise, global floating support may be modified viasetGlobalFloatingEnabled(boolean globalFloatingEnabled)
.This class provides methods
addPolicy(FloatPolicy policy)
andremovePolicy(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, theFloatPolicyManager
has a singleFloatPolicy
installed of typeDefaultFloatPolicy
.- Author:
- Christopher Butler
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.flexdock.docking.event.DockingListener
DockingListener.Stub
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FLOATING_ALLOWED
Key constant used within the drag contextMap
to indicate whether floating is allowed for a given drag operation.static java.lang.String
GLOBAL_FLOATING_ENABLED
System property key used during framework initialization to determine the default setting for global floating support.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
getInstance()
Returns a singleton instance of theFloatPolicyManager
class.static boolean
isFloatingAllowed(Dockable dockable)
Indicates whether floating is allowed for the specifiedDockable
.static boolean
isGlobalFloatingEnabled()
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 Detail
-
FLOATING_ALLOWED
public static final java.lang.String FLOATING_ALLOWED
Key constant used within the drag contextMap
to indicate whether floating is allowed for a given drag operation.
-
GLOBAL_FLOATING_ENABLED
public static final java.lang.String GLOBAL_FLOATING_ENABLED
System property key used during framework initialization to determine the default setting for global floating support.- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static FloatPolicyManager getInstance()
Returns a singleton instance of theFloatPolicyManager
class.- Returns:
- a singleton instance of the
FloatPolicyManager
class.
-
dragStarted
public 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. 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:
DockingEvent.getDragContext()
,DockingEvent.getDockable()
,isPolicyFloatingSupported(Dockable)
,FLOATING_ALLOWED
-
dropStarted
public 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.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:
DockingEvent.isOverWindow()
,DockingEvent.getDockable()
,DockingEvent.consume()
,isFloatingAllowed(Dockable)
,FloatPolicy.isFloatDropAllowed(DockingEvent)
-
isFloatingAllowed
public static boolean isFloatingAllowed(Dockable dockable)
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:
DragManager.getDragContext(Dockable)
,getInstance()
,isPolicyFloatingSupported(Dockable)
,FLOATING_ALLOWED
-
isPolicyFloatingSupported
public boolean isPolicyFloatingSupported(Dockable dockable)
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:
FloatPolicy.isFloatingAllowed(Dockable)
-
addPolicy
public void addPolicy(FloatPolicy policy)
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(FloatPolicy)
-
removePolicy
public void removePolicy(FloatPolicy policy)
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:
addPolicy(FloatPolicy)
-
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(boolean)
-
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:
isGlobalFloatingEnabled()
-
-