bibliothek.gui.dock.station.toolbar
Class DefaultToolbarStrategy

java.lang.Object
  extended by bibliothek.gui.dock.station.toolbar.DefaultToolbarStrategy
All Implemented Interfaces:
ToolbarStrategy

public class DefaultToolbarStrategy
extends Object
implements ToolbarStrategy

The default implementation of ToolbarStrategy.

Reminder: the toolbar API defines one dockable ComponentDockable and three dockstation layers: ToolbarDockStation, ToolbarGroupDockStation and ToolbarContainerDockStation.

A ComponentDockable can be put in the three layers. A ToolbarDockStation acts exactly the same. A ToolbarGroupDockStation can be put only in a ToolbarGroupDockStation (with some constraints, but this constraints are handled by the station itself) or in ToolbarContainerDockStation.

About the layers (and not about the question to know if a station accept a particular dockable), in the layer hierarchy, a station can only contains the immediate lower dockable:

Author:
Benjamin Sigg, Herve Guillaume

Field Summary
 
Fields inherited from interface bibliothek.gui.dock.station.toolbar.ToolbarStrategy
STRATEGY
 
Constructor Summary
DefaultToolbarStrategy()
           
 
Method Summary
 bibliothek.gui.Dockable ensureToolbarLayer(bibliothek.gui.DockStation station, bibliothek.gui.Dockable dockable)
          As toolbars have constraints on which Dockable can be a child of which DockStation often additional layers between a specific DockStation and a Dockable are required.
protected  Orientation getOrientation(bibliothek.gui.Dockable dockable)
          Tells what orientation should be applied to the parent of dockable.
 boolean isToolbarGroupPart(bibliothek.gui.Dockable dockable)
          Tells whether dockable represents a group of toolbar components, e.g.
 boolean isToolbarGroupPartParent(bibliothek.gui.DockStation parent, bibliothek.gui.Dockable child, boolean strong)
          Tells whether the station parent is a valid choice for the dockable child, assuming that child represents a component of a toolbar, e.g.
 boolean isToolbarPart(bibliothek.gui.Dockable dockable)
          Tells whether dockable represents a toolbar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultToolbarStrategy

public DefaultToolbarStrategy()
Method Detail

ensureToolbarLayer

public bibliothek.gui.Dockable ensureToolbarLayer(bibliothek.gui.DockStation station,
                                                  bibliothek.gui.Dockable dockable)
Description copied from interface: ToolbarStrategy
As toolbars have constraints on which Dockable can be a child of which DockStation often additional layers between a specific DockStation and a Dockable are required. This method defines what these layers are.
This method must not add child to any DockStation.

Specified by:
ensureToolbarLayer in interface ToolbarStrategy
Parameters:
station - some DockStation which is going to become a direct or indirect parent of child
dockable - some Dockable that is going to be a direct or indirect child of parent
Returns:
the element that is actually added to parent as direct child. This can either be child, or a new empty dockable DockStation. A value of null indicates that child can never be any kind of child of parent. The other methods of this ToolbarStrategy should however be implemented such that this case never happens during a drag and drop operation.

getOrientation

protected Orientation getOrientation(bibliothek.gui.Dockable dockable)
Tells what orientation should be applied to the parent of dockable.

Parameters:
dockable - some item that is dropped
Returns:
the preferred orientation of the parent

isToolbarGroupPartParent

public boolean isToolbarGroupPartParent(bibliothek.gui.DockStation parent,
                                        bibliothek.gui.Dockable child,
                                        boolean strong)
Description copied from interface: ToolbarStrategy
Tells whether the station parent is a valid choice for the dockable child, assuming that child represents a component of a toolbar, e.g. a button.

Specified by:
isToolbarGroupPartParent in interface ToolbarStrategy
Parameters:
parent - a potential parent for child. It might be that an additional layer between parent and child will be created.
child - the potential new child of parent
strong - if true, then it must be possible to add child directly to parent, if false the relation must be valid after calling ToolbarStrategy.ensureToolbarLayer(DockStation, Dockable).
Returns:
true if a combination between child and parent is possible

isToolbarGroupPart

public boolean isToolbarGroupPart(bibliothek.gui.Dockable dockable)
Description copied from interface: ToolbarStrategy
Tells whether dockable represents a group of toolbar components, e.g. a group of buttons. Also a single toolbar component can be understood to be a group of components.

Specified by:
isToolbarGroupPart in interface ToolbarStrategy
Parameters:
dockable - some dockable that is drag and dropped
Returns:
true if dockable represents a group of toolbar components

isToolbarPart

public boolean isToolbarPart(bibliothek.gui.Dockable dockable)
Description copied from interface: ToolbarStrategy
Tells whether dockable represents a toolbar. A toolbar can either be a single item like a button, a group of such items, or a real toolbar.

Specified by:
isToolbarPart in interface ToolbarStrategy
Parameters:
dockable - the element to test
Returns:
true if dockable represents a toolbar or a part of a toolbar