bibliothek.gui.dock.action
Class DefaultDockActionSource

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

public class DefaultDockActionSource
extends AbstractDockActionSource

The DefaultDockActionSource is nothing more than a list of DockActions that may be changed at any time.

Author:
Benjamin Sigg

Field Summary
 
Fields inherited from class bibliothek.gui.dock.action.AbstractDockActionSource
listeners
 
Constructor Summary
DefaultDockActionSource(DockAction... actions)
          Defaultconstructor, fills the list with some initial actions.
DefaultDockActionSource(LocationHint hint, DockAction... actions)
          Defaultconstructor, fills the list with some initial actions.
 
Method Summary
 void add(DockAction... action)
          Adds all given actions to the end of this source.
 void add(int index, DockAction... actions)
          Inserts all given actions such that the first action will have the given index, the second action index+1, and so on...
 void addSeparator()
          Adds a separator at the end of this source
 void addSeparator(int position)
          Adds a separator at position
 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.
 int indexOf(DockAction action)
          Gets the index of the given action
 java.util.Iterator<DockAction> iterator()
           
 void remove(DockAction action)
          Removes the given action from this source.
 void remove(int index)
          Removes the action at index from this source.
 void remove(int index, int length)
          Removes all actions between index (incl.)
 void removeAll()
          Removes all actions stored in this source.
 void setHint(LocationHint hint)
          Sets the location-hint of this source.
 
Methods inherited from class bibliothek.gui.dock.action.AbstractDockActionSource
addDockActionSourceListener, fireAdded, fireRemoved, removeDockActionSourceListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDockActionSource

public DefaultDockActionSource(DockAction... actions)
Defaultconstructor, fills the list with some initial actions.

Parameters:
actions - The actions to add

DefaultDockActionSource

public DefaultDockActionSource(LocationHint hint,
                               DockAction... actions)
Defaultconstructor, fills the list with some initial actions.

Parameters:
hint - the preferred location of this source
actions - The actions to add
Method Detail

iterator

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

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.

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

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

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

addSeparator

public void addSeparator(int position)
Adds a separator at position

Parameters:
position - the location where to add the separator

addSeparator

public void addSeparator()
Adds a separator at the end of this source


add

public void add(DockAction... action)
Adds all given actions to the end of this source.

Parameters:
action - The actions to append

add

public void add(int index,
                DockAction... actions)
Inserts all given actions such that the first action will have the given index, the second action index+1, and so on...

Parameters:
index - The index of the first action
actions - The actions to insert

indexOf

public int indexOf(DockAction action)
Description copied from class: AbstractDockActionSource
Gets the index of the given action

Overrides:
indexOf in class AbstractDockActionSource
Parameters:
action - The action to search in this source
Returns:
The index of the action, -1 if the action was not found

remove

public void remove(DockAction action)
Removes the given action from this source.

Parameters:
action - The action to remove

remove

public void remove(int index)
Removes the action at index from this source.

Parameters:
index - The index of the action to remove

removeAll

public void removeAll()
Removes all actions stored in this source.


remove

public void remove(int index,
                   int length)
Removes all actions between index (incl.) and index+length (excl.).

Parameters:
index - The index of the first action to remove
length - The number of actions to remove
Throws:
java.lang.IllegalArgumentException - If some actions should be removed that do not exist