bibliothek.gui.dock.action
Class MultiDockActionSource

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

public class MultiDockActionSource
extends AbstractDockActionSource

A DockActionSource that combines various sources in one source. This source behaves like a list of DockActionSources.

Author:
Benjamin Sigg

Field Summary
 
Fields inherited from class bibliothek.gui.dock.action.AbstractDockActionSource
listeners
 
Constructor Summary
MultiDockActionSource(DockActionSource... sources)
          Constructs a new source.
MultiDockActionSource(LocationHint hint, DockActionSource... sources)
          Constructs a new source.
 
Method Summary
 void add(DockAction... actions)
          Adds several actions to this source.
 void add(DockActionSource source)
          Adds a source as child of this source.
 void addDockActionSourceListener(DockActionSourceListener listener)
          Adds a listener to this source.
 void addSeparator()
          Adds a separator at the end of the current list of actions
 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.
protected  int getDockActionCountUntil(int index, boolean allowUpdate)
          Counts how many DockActions are provided by the source-children with index 0 (incl) to index (excl).
 LocationHint getLocationHint()
          Gets a hint where to put this source in relation to other sources.
protected  int getSource(DockAction action)
          Gets the index of the child-source which contains action.
 boolean isSeparateSources()
          Tells whether there is a separator between sources or not
 java.util.Iterator<DockAction> iterator()
           
 void remove(DockActionSource source)
          Removes source from this MultiDockActionSource.
 void removeAll()
          Removes all children of this source.
 void removeDockActionSourceListener(DockActionSourceListener listener)
          Removes an earlier added listener.
 void setHint(LocationHint hint)
          Sets the location-hint of this source.
 void setSeparateSources(boolean separateSources)
          Sets whether there are separators between the children of this source or not.
 
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

MultiDockActionSource

public MultiDockActionSource(DockActionSource... sources)
Constructs a new source. The sources are added as children of this source.

Parameters:
sources - The children of this source

MultiDockActionSource

public MultiDockActionSource(LocationHint hint,
                             DockActionSource... sources)
Constructs a new source. The sources are added as children of this source.

Parameters:
hint - the preferred location of this source
sources - The children of this source
Method Detail

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)

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

setHint

public void setHint(LocationHint hint)
Sets the location-hint of this source.

Parameters:
hint - the hint that tells an ActionOffer where to put this source.

addSeparator

public void addSeparator()
Adds a separator at the end of the current list of actions


isSeparateSources

public boolean isSeparateSources()
Tells whether there is a separator between sources or not

Returns:
true if there is a separator

setSeparateSources

public void setSeparateSources(boolean separateSources)
Sets whether there are separators between the children of this source or not.

Parameters:
separateSources - true if children should be separated

add

public void add(DockActionSource source)
Adds a source as child of this source. All DockActions of source will be presented as actions of this source.
Note: creating circles or adding a source more than once will lead to unspecified behavior.

Parameters:
source - the new child

remove

public void remove(DockActionSource source)
Removes source from this MultiDockActionSource.

Parameters:
source - the child to remove

removeAll

public void removeAll()
Removes all children of this source.


add

public void add(DockAction... actions)
Adds several actions to this source.

Parameters:
actions - the new actions

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

getSource

protected int getSource(DockAction action)
Gets the index of the child-source which contains action.

Parameters:
action - the action for which is searched
Returns:
the index of the source which contains the action or -1

getDockActionCountUntil

protected int getDockActionCountUntil(int index,
                                      boolean allowUpdate)
Counts how many DockActions are provided by the source-children with index 0 (incl) to index (excl).

Parameters:
index - the index of the first source that should not be counted
allowUpdate - whether the updateSeparators() can be called by this method or not
Returns:
the number of actions of the first index child-sources.

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