Package org.flexdock.docking
Interface DockingStrategy
-
- All Known Implementing Classes:
DefaultDockingStrategy
public interface DockingStrategyThis interface defines an API used byDockingManagerandDockingPortto support customizable behaviors during docking operations.DockingManagerwill associate aDockingStrategywith a particularDockingPortorDockableclass type. Calls toDockingManager.dock()andDockingManager.undock()will be deferred to theDockingStrategyassociated with the parameters supplied in the respective method calls.DockingStrategiesare also responsible for creating sub-DockingPorts and split panes for nestedDockingPortsImplementations ofDockingStrategyare responsible for managing component relationships betweenDockablesand 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 particularDockablemay be removed from one parentContainerorDockingPortand added to another.DockingStrategymay determine whether a call todock()implies an attempt to float aDockablein 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 ofDockingStrategyare not discouraged, the recommeded path is to subclassDefaultDockingStrategyfor consistency of behavior.DockingStrategiesare associated with a particular type ofDockableorDockingPortby callingDockingManager.setDockingStrategy(Class c, DockingStrategy strategy).DefaultDockingStrategyis the default implementation used for all classes that do not have a customDockingStrategyregistered.- Author:
- Christopher Butler
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DockingPortcreateDockingPort(DockingPort base)Creates and returns a newDockingPortinstance based upon the suppliedDockingPortparameter.javax.swing.JSplitPanecreateSplitPane(DockingPort base, java.lang.String region)Creates and returns a newJSplitPaneinstance based upon the supplied parameters.javax.swing.JSplitPanecreateSplitPane(DockingPort base, java.lang.String region, float percent)Creates and returns a newJSplitPaneinstance based upon the supplied parameters.booleandock(Dockable dockable, DockingPort dockingPort, java.lang.String dockingRegion)Attempts to dock the specifiedDockableinto the suppliedDockingPortin the specified region.booleandock(Dockable dockable, DockingPort dockingPort, java.lang.String dockingRegion, DragOperation operation)Attempts to dock the specifiedDockableinto the suppliedDockingPortin the specified region based upon the semantics of the specifiedDragOperation.doublegetDividerProportion(DockingPort dockingPort, javax.swing.JSplitPane splitPane)Returns the desired divider proportion of the specifiedJSplitPaneafter rendering.intgetInitialDividerLocation(DockingPort dockingPort, javax.swing.JSplitPane splitPane)Returns the initial divider location to be used by the specifiedJSplitPane.booleanundock(Dockable dockable)Undocks the specifiedDockableinstance from its containingDockingPort.
-
-
-
Method Detail
-
dock
boolean dock(Dockable dockable, DockingPort dockingPort, java.lang.String dockingRegion)
Attempts to dock the specifiedDockableinto the suppliedDockingPortin the specified region. If docking is not possible for the specified parameters, then the method returnsfalseand no action is taken. Since there is noDragOperationparameter present, this method implies programmatic docking as opposed to docking as a result of drag-events.- Parameters:
dockable- theDockablewe wish to dockdockingPort- theDockingPortinto which we wish to dockdockingRegion- the region of the specifiedDockingPortinto 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 specifiedDockableinto the suppliedDockingPortin the specified region based upon the semantics of the specifiedDragOperation. If docking is not possible for the specified parameters, then the method returnsfalseand no action is taken.- Parameters:
dockable- theDockablewe wish to dockdockingPort- theDockingPortinto which we wish to dockdockingRegion- the region of the specifiedDockingPortinto which we wish to dock.operation- theDragOperationdescribing 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 specifiedDockableinstance from its containingDockingPort.- Parameters:
dockable- theDockablewe wish to undock- Returns:
trueif theDockablewas successfully undocked. Otherwise, returnsfalse.
-
createDockingPort
DockingPort createDockingPort(DockingPort base)
Creates and returns a newDockingPortinstance based upon the suppliedDockingPortparameter. For layouts that support nestedDockingPorts, this method is useful for creating childDockingPortssuitable for embedding within the baseDockingPort- Parameters:
base- theDockingPortoff of which the returned instance will be based.- Returns:
- a new
DockingPortinstance based upon the supplied parameter.
-
createSplitPane
javax.swing.JSplitPane createSplitPane(DockingPort base, java.lang.String region)
Creates and returns a newJSplitPaneinstance based upon the supplied parameters. The returnedJSplitPaneshould be suitable for embedding within the baseDockingPortand its orientation should reflect the suppliedregionparameter.- Parameters:
base- theDockingPortoff of which the returnedJSplitPanewill be based.region- the region within the baseDockingPortused to determine the orientation of the returnedJSplitPane.- Returns:
- a new
JSplitPanesuitable for embedding within the baseDockingPortparameter.
-
createSplitPane
javax.swing.JSplitPane createSplitPane(DockingPort base, java.lang.String region, float percent)
Creates and returns a newJSplitPaneinstance based upon the supplied parameters. The returnedJSplitPaneshould be suitable for embedding within the baseDockingPortand its orientation should reflect the suppliedregionparameter.- Parameters:
base- theDockingPortoff of which the returnedJSplitPanewill be based.region- the region within the baseDockingPortused to determine the orientation of the returnedJSplitPane.percent- the percentage used in the split.- Returns:
- a new
JSplitPanesuitable for embedding within the baseDockingPortparameter.
-
getInitialDividerLocation
int getInitialDividerLocation(DockingPort dockingPort, javax.swing.JSplitPane splitPane)
Returns the initial divider location to be used by the specifiedJSplitPane. This method assumes that theJSplitPaneparameter is embedded within the specifiedDockingPortand that is has been validated and its current dimensions are non-zero.- Parameters:
dockingPort- theDockingPortthat contains, or will contain the specifiedJSplitPane.splitPane- theJSplitPanewhose 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 specifiedJSplitPaneafter rendering. This method assumes that theJSplitPaneparameter is, or will be embedded within the specifiedDockingPort. This method does not assume that theJSplitPanehas been validated and that it's current dimensions are non-zero.- Parameters:
dockingPort- theDockingPortthat contains, or will contain the specifiedJSplitPane.splitPane- theJSplitPanewhose initial divider location is to be determined.- Returns:
- the desired divider proportion of the supplied
JSplitPane.
-
-