bibliothek.gui.dock.facile.action
Class KeyedActionSource

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

@FrameworkOnly
public class KeyedActionSource
extends AbstractDockActionSource

An action source using CDockable.getAction(String) to determine which action to use. If getAction returns null, then a default action can be used. This action source also allows to disable any action.

Author:
Benjamin Sigg

Field Summary
 
Fields inherited from class bibliothek.gui.dock.action.AbstractDockActionSource
listeners
 
Constructor Summary
KeyedActionSource(CDockable dockable, String key)
          Creates a new action source
 
Method Summary
 void addDockActionSourceListener(DockActionSourceListener listener)
          Adds a listener to this source.
 void destroy()
          Detaches the listeners this DockActionSource added to other objects.
 DockAction getDefaultAction()
          Gets the default action of 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.
 String getKey()
          Gets the key which is used for calling CDockable.getAction(String)
 LocationHint getLocationHint()
          Gets a hint where to put this source in relation to other sources.
 Iterator<DockAction> iterator()
           
 void removeDockActionSourceListener(DockActionSourceListener listener)
          Removes an earlier added listener.
 void setDefaultAction(DockAction defaultAction)
          Sets the default action of this source.
 void setVisible(boolean visible)
          Changes whether any actions are shown or not.
 
Methods inherited from class bibliothek.gui.dock.action.AbstractDockActionSource
fireAdded, fireRemoved, hasListeners, indexOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyedActionSource

public KeyedActionSource(CDockable dockable,
                         String key)
Creates a new action source

Parameters:
dockable - the element for which this source is used
key - the key for calling CDockable.getAction(String)
Method Detail

getKey

public String getKey()
Gets the key which is used for calling CDockable.getAction(String)

Returns:
the key, not null

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)

destroy

public void destroy()
Detaches the listeners this DockActionSource added to other objects.


setVisible

public void setVisible(boolean visible)
Changes whether any actions are shown or not.

Parameters:
visible - the new state

setDefaultAction

public void setDefaultAction(DockAction defaultAction)
Sets the default action of this source. The default action is used if CDockable.getAction(String) returns null.

Parameters:
defaultAction - the default action, may be null

getDefaultAction

public DockAction getDefaultAction()
Gets the default action of this source.

Returns:
the default action, can be null

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

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

iterator

public Iterator<DockAction> iterator()