bibliothek.gui.dock.action
Class StationChildrenActionSource

java.lang.Object
  extended by bibliothek.gui.dock.action.AbstractDockActionSource
      extended by bibliothek.gui.dock.action.StationChildrenActionSource
All Implemented Interfaces:
DockActionSource, java.lang.Iterable<DockAction>

public class StationChildrenActionSource
extends AbstractDockActionSource

This DockActionSource is a wrapper around a Dockable or a DockStation and adds one DockAction for each child of the station to itself. Subclasses may implement a filter to show more or less actions.

Author:
Benjamin Sigg

Nested Class Summary
protected  class StationChildrenActionSource.FocusAction
          An action that can transfer the focus
 
Field Summary
 
Fields inherited from class bibliothek.gui.dock.action.AbstractDockActionSource
listeners
 
Constructor Summary
StationChildrenActionSource(Dockable dockable, LocationHint hint)
          Creates a new action source.
 
Method Summary
 void addDockActionSourceListener(DockActionSourceListener listener)
          Adds a listener to this source.
protected  DockAction createActionFor(Dockable dockable)
          Creates the DockAction which is shown for dockable.
 Dockable getDockable()
          Gets the dockable or station which is managed by this source.
 DockAction getDockAction(int index)
          Gets the index'th DockAction of this source.
 int getDockActionCount()
          Gets the number of DockActions which are provided by this source.
 LocationHint getLocationHint()
          Gets a hint where to put this source in relation to other sources.
 java.util.Iterator<DockAction> iterator()
           
 void removeDockActionSourceListener(DockActionSourceListener listener)
          Removes an earlier added listener.
protected  boolean shouldShow(Dockable dockable)
          Tells which children to show and which not.
protected  void sort(java.util.List<Dockable> dockables)
          Puts an order in the dockables, telling which items to show when.
 
Methods inherited from class bibliothek.gui.dock.action.AbstractDockActionSource
fireAdded, fireRemoved, indexOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StationChildrenActionSource

public StationChildrenActionSource(Dockable dockable,
                                   LocationHint hint)
Creates a new action source.

Parameters:
dockable - the dockable or station whose children to show, not null
hint - the preferred location of this DockActionSource, may be null
Method Detail

getDockable

public Dockable getDockable()
Gets the dockable or station which is managed by this source.

Returns:
the dockable, not null

getLocationHint

public LocationHint getLocationHint()
Description copied from interface: DockActionSource
Gets a hint where to put this source in relation to other sources. Note that an ActionOffer can choose to ignore these hints, or interpret them in an unexpected way.

Returns:
the preferred location of this source

getDockAction

public DockAction getDockAction(int index)
Description copied from interface: DockActionSource
Gets the index'th DockAction of this source.

Parameters:
index - The index of the action
Returns:
The DockAction

getDockActionCount

public int getDockActionCount()
Description copied from interface: DockActionSource
Gets the number of DockActions which are provided by this source.

Returns:
The number of DockActions

iterator

public java.util.Iterator<DockAction> iterator()

addDockActionSourceListener

public void addDockActionSourceListener(DockActionSourceListener listener)
Description copied from interface: DockActionSource
Adds a listener to this source. The DockActionSourceListener should be informed whenever some DockActions are added or removed from this source.

Specified by:
addDockActionSourceListener in interface DockActionSource
Overrides:
addDockActionSourceListener in class AbstractDockActionSource
Parameters:
listener - The listener

removeDockActionSourceListener

public void removeDockActionSourceListener(DockActionSourceListener listener)
Description copied from interface: DockActionSource
Removes an earlier added listener.

Specified by:
removeDockActionSourceListener in interface DockActionSource
Overrides:
removeDockActionSourceListener in class AbstractDockActionSource
Parameters:
listener - The listener to remove
See Also:
DockActionSource.addDockActionSourceListener(DockActionSourceListener)

createActionFor

protected DockAction createActionFor(Dockable dockable)
Creates the DockAction which is shown for dockable. The default behavior is to create a ButtonDockAction which can be pressed and will transfer the focus to dockable.

Parameters:
dockable - the item for which an action is required
Returns:
the new action, not null

sort

protected void sort(java.util.List<Dockable> dockables)
Puts an order in the dockables, telling which items to show when. The default behavior is to keep the current order (which is the order given by the tree of DockStations and Dockables). Subclasses may also modify the list by adding or removing items, altough a filter is better implemented by overriding shouldShow(Dockable)

Parameters:
dockables - the array to order

shouldShow

protected boolean shouldShow(Dockable dockable)
Tells which children to show and which not. This method is called with all children (direct and indirect) of the station. The default behavior is to return true for any direct child or true if the monitored dockable is no station at all.

Parameters:
dockable - the child to check
Returns:
true if there should be a button, false otherwise