Package org.flexdock.docking
Interface DockingStrategy
-
- All Known Implementing Classes:
DefaultDockingStrategy
public interface DockingStrategy
This interface defines an API used byDockingManager
andDockingPort
to support customizable behaviors during docking operations.DockingManager
will associate aDockingStrategy
with a particularDockingPort
orDockable
class type. Calls toDockingManager.dock()
andDockingManager.undock()
will be deferred to theDockingStrategy
associated with the parameters supplied in the respective method calls.DockingStrategies
are also responsible for creating sub-DockingPorts and split panes for nestedDockingPorts
Implementations ofDockingStrategy
are responsible for managing component relationships betweenDockables
and parent containers. This includes making determinations as to whether a particular docking operation will be allowed for the specified parameters and the specifics of how a particularDockable
may be removed from one parentContainer
orDockingPort
and added to another.DockingStrategy
may determine whether a call todock()
implies an attempt to float aDockable
in a separate window. Because of the potentially large scope of responsibilities associated with aDockingStrategy
, implementations may range from being very simple to highly complex. Although custom implementations ofDockingStrategy
are not discouraged, the recommeded path is to subclassDefaultDockingStrategy
for consistency of behavior.DockingStrategies
are associated with a particular type ofDockable
orDockingPort
by callingDockingManager.setDockingStrategy(Class c, DockingStrategy strategy)
.DefaultDockingStrategy
is the default implementation used for all classes that do not have a customDockingStrategy
registered.- Author:
- Christopher Butler
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DockingPort
createDockingPort(DockingPort base)
Creates and returns a newDockingPort
instance based upon the suppliedDockingPort
parameter.javax.swing.JSplitPane
createSplitPane(DockingPort base, java.lang.String region)
Creates and returns a newJSplitPane
instance based upon the supplied parameters.javax.swing.JSplitPane
createSplitPane(DockingPort base, java.lang.String region, float percent)
Creates and returns a newJSplitPane
instance based upon the supplied parameters.boolean
dock(Dockable dockable, DockingPort dockingPort, java.lang.String dockingRegion)
Attempts to dock the specifiedDockable
into the suppliedDockingPort
in the specified region.boolean
dock(Dockable dockable, DockingPort dockingPort, java.lang.String dockingRegion, DragOperation operation)
Attempts to dock the specifiedDockable
into the suppliedDockingPort
in the specified region based upon the semantics of the specifiedDragOperation
.double
getDividerProportion(DockingPort dockingPort, javax.swing.JSplitPane splitPane)
Returns the desired divider proportion of the specifiedJSplitPane
after rendering.int
getInitialDividerLocation(DockingPort dockingPort, javax.swing.JSplitPane splitPane)
Returns the initial divider location to be used by the specifiedJSplitPane
.boolean
undock(Dockable dockable)
Undocks the specifiedDockable
instance from its containingDockingPort
.
-
-
-
Method Detail
-
dock
boolean dock(Dockable dockable, DockingPort dockingPort, java.lang.String dockingRegion)
Attempts to dock the specifiedDockable
into the suppliedDockingPort
in the specified region. If docking is not possible for the specified parameters, then the method returnsfalse
and no action is taken. Since there is noDragOperation
parameter present, this method implies programmatic docking as opposed to docking as a result of drag-events.- Parameters:
dockable
- theDockable
we wish to dockdockingPort
- theDockingPort
into which we wish to dockdockingRegion
- the region of the specifiedDockingPort
into which we wish to dock.- Returns:
- whether or not the docking operation was successful.
-
dock
boolean dock(Dockable dockable, DockingPort dockingPort, java.lang.String dockingRegion, DragOperation operation)
Attempts to dock the specifiedDockable
into the suppliedDockingPort
in the specified region based upon the semantics of the specifiedDragOperation
. If docking is not possible for the specified parameters, then the method returnsfalse
and no action is taken.- Parameters:
dockable
- theDockable
we wish to dockdockingPort
- theDockingPort
into which we wish to dockdockingRegion
- the region of the specifiedDockingPort
into which we wish to dock.operation
- theDragOperation
describing the state of the application/mouse at the point in time in which we're attempting to dock.- Returns:
- whether or not the docking operation was successful.
-
undock
boolean undock(Dockable dockable)
Undocks the specifiedDockable
instance from its containingDockingPort
.- Parameters:
dockable
- theDockable
we wish to undock- Returns:
true
if theDockable
was successfully undocked. Otherwise, returnsfalse
.
-
createDockingPort
DockingPort createDockingPort(DockingPort base)
Creates and returns a newDockingPort
instance based upon the suppliedDockingPort
parameter. For layouts that support nestedDockingPorts
, this method is useful for creating childDockingPorts
suitable for embedding within the baseDockingPort
- Parameters:
base
- theDockingPort
off of which the returned instance will be based.- Returns:
- a new
DockingPort
instance based upon the supplied parameter.
-
createSplitPane
javax.swing.JSplitPane createSplitPane(DockingPort base, java.lang.String region)
Creates and returns a newJSplitPane
instance based upon the supplied parameters. The returnedJSplitPane
should be suitable for embedding within the baseDockingPort
and its orientation should reflect the suppliedregion
parameter.- Parameters:
base
- theDockingPort
off of which the returnedJSplitPane
will be based.region
- the region within the baseDockingPort
used to determine the orientation of the returnedJSplitPane
.- Returns:
- a new
JSplitPane
suitable for embedding within the baseDockingPort
parameter.
-
createSplitPane
javax.swing.JSplitPane createSplitPane(DockingPort base, java.lang.String region, float percent)
Creates and returns a newJSplitPane
instance based upon the supplied parameters. The returnedJSplitPane
should be suitable for embedding within the baseDockingPort
and its orientation should reflect the suppliedregion
parameter.- Parameters:
base
- theDockingPort
off of which the returnedJSplitPane
will be based.region
- the region within the baseDockingPort
used to determine the orientation of the returnedJSplitPane
.percent
- the percentage used in the split.- Returns:
- a new
JSplitPane
suitable for embedding within the baseDockingPort
parameter.
-
getInitialDividerLocation
int getInitialDividerLocation(DockingPort dockingPort, javax.swing.JSplitPane splitPane)
Returns the initial divider location to be used by the specifiedJSplitPane
. This method assumes that theJSplitPane
parameter is embedded within the specifiedDockingPort
and that is has been validated and its current dimensions are non-zero.- Parameters:
dockingPort
- theDockingPort
that contains, or will contain the specifiedJSplitPane
.splitPane
- theJSplitPane
whose initial divider location is to be determined.- Returns:
- the desired divider location of the supplied
JSplitPane
.
-
getDividerProportion
double getDividerProportion(DockingPort dockingPort, javax.swing.JSplitPane splitPane)
Returns the desired divider proportion of the specifiedJSplitPane
after rendering. This method assumes that theJSplitPane
parameter is, or will be embedded within the specifiedDockingPort
. This method does not assume that theJSplitPane
has been validated and that it's current dimensions are non-zero.- Parameters:
dockingPort
- theDockingPort
that contains, or will contain the specifiedJSplitPane
.splitPane
- theJSplitPane
whose initial divider location is to be determined.- Returns:
- the desired divider proportion of the supplied
JSplitPane
.
-
-