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 ofFloatPolicyimplementations.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-sensitiveStringvalue 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, theFloatPolicyManagerhas a singleFloatPolicyinstalled 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.StringFLOATING_ALLOWEDKey constant used within the drag contextMapto indicate whether floating is allowed for a given drag operation.static java.lang.StringGLOBAL_FLOATING_ENABLEDSystem 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 voidaddPolicy(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 FloatPolicyManagergetInstance()Returns a singleton instance of theFloatPolicyManagerclass.static booleanisFloatingAllowed(Dockable dockable)Indicates whether floating is allowed for the specifiedDockable.static booleanisGlobalFloatingEnabled()Returns 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 Detail
-
FLOATING_ALLOWED
public static final java.lang.String FLOATING_ALLOWED
Key constant used within the drag contextMapto 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 theFloatPolicyManagerclass.- Returns:
- a singleton instance of the
FloatPolicyManagerclass.
-
dragStarted
public void dragStarted(DockingEvent evt)
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:
DockingEvent.getDragContext(),DockingEvent.getDockable(),isPolicyFloatingSupported(Dockable),FLOATING_ALLOWED
-
dropStarted
public void dropStarted(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.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:
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. 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:
DragManager.getDragContext(Dockable),getInstance(),isPolicyFloatingSupported(Dockable),FLOATING_ALLOWED
-
isPolicyFloatingSupported
public boolean isPolicyFloatingSupported(Dockable dockable)
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:
FloatPolicy.isFloatingAllowed(Dockable)
-
addPolicy
public void addPolicy(FloatPolicy policy)
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(FloatPolicy)
-
removePolicy
public void removePolicy(FloatPolicy policy)
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:
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:
trueif global floating support is enabled;falseotherwise.- See Also:
setGlobalFloatingEnabled(boolean)
-
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:
isGlobalFloatingEnabled()
-
-