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

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

Nested Class Summary
private  class MultiDockActionSource.Listener
          A listener to the sources of this group of sources.
private  class MultiDockActionSource.SeparatorSource
          A source that shows one separator.
 
Field Summary
private  LocationHint hint
           
private  MultiDockActionSource.Listener listener
           
private  boolean separateSources
           
private  java.util.List<MultiDockActionSource.SeparatorSource> separators
           
private  java.util.List<DockActionSource> sources
           
 
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)
          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
 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.
private  void updateSeparators()
          Ensures that all separators which must be visible are realy visible.
 
Methods inherited from class bibliothek.gui.dock.action.AbstractDockActionSource
fireAdded, fireRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sources

private java.util.List<DockActionSource> sources

separators

private java.util.List<MultiDockActionSource.SeparatorSource> separators

listener

private MultiDockActionSource.Listener listener

separateSources

private boolean separateSources

hint

private LocationHint hint
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

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.

addDockActionSourceListener

public void addDockActionSourceListener(DockActionSourceListener listener)
Description copied from interface: DockActionSource
Adds a listener to this source. The StandardDockActionListener 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)

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

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)
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
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

updateSeparators

private void updateSeparators()
Ensures that all separators which must be visible are realy visible.