bibliothek.gui.dock.action
Class DefaultActionOffer

java.lang.Object
  extended by bibliothek.gui.dock.action.DefaultActionOffer
All Implemented Interfaces:
ActionOffer

public class DefaultActionOffer
extends Object
implements ActionOffer

An ActionOffer that collects some DockActionSources. This ActionOffer tries to sort the sources by their LocationHint, and uses the Origin if the Hint does not carry enough information.

Author:
Benjamin Sigg

Constructor Summary
DefaultActionOffer()
          Creates a new DefaultActionOffer.
DefaultActionOffer(LocationHint.Origin... origins)
          Creates a new DefaultActionOffer.
 
Method Summary
 DockActionSource getSource(Dockable dockable, DockActionSource source, DockActionSource[] guards, DockActionSource parent, DockActionSource[] parents)
          Generates one source of actions for the given Dockable.
 boolean interested(Dockable dockable)
          Tells whether this ActionOffer wants to collect the actions for the dockable, or if this ActionOffer is not interested in the Dockable.
 boolean isSeparators()
          Gets whether there are separators between groups.
 void setHints(LocationHint.Hint[] hints)
          Sets the preferred order of sources according to their hint.
 void setOrigins(LocationHint.Origin[] origins)
          Sets the preferred order of sources according to their origin.
 void setSeparators(boolean separators)
          Whether there shall be separators between groups.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultActionOffer

public DefaultActionOffer()
Creates a new DefaultActionOffer.


DefaultActionOffer

public DefaultActionOffer(LocationHint.Origin... origins)
Creates a new DefaultActionOffer. The order of origin is used if several sources have the same preferred location hint.

Parameters:
origins - The order of the sources with equal location hint
Method Detail

setOrigins

public void setOrigins(LocationHint.Origin[] origins)
Sets the preferred order of sources according to their origin.

Parameters:
origins - the preferred order

setHints

public void setHints(LocationHint.Hint[] hints)
Sets the preferred order of sources according to their hint.

Parameters:
hints - the preferred order

setSeparators

public void setSeparators(boolean separators)
Whether there shall be separators between groups.

Parameters:
separators - true if separators will be inserted

isSeparators

public boolean isSeparators()
Gets whether there are separators between groups.

Returns:
true if separators are inserted

interested

public boolean interested(Dockable dockable)
Description copied from interface: ActionOffer
Tells whether this ActionOffer wants to collect the actions for the dockable, or if this ActionOffer is not interested in the Dockable.

Specified by:
interested in interface ActionOffer
Parameters:
dockable - The Dockable to test
Returns:
true if this ActionOffer should tell which actions will be associated with the dockable, false otherwise.

getSource

public DockActionSource getSource(Dockable dockable,
                                  DockActionSource source,
                                  DockActionSource[] guards,
                                  DockActionSource parent,
                                  DockActionSource[] parents)
Description copied from interface: ActionOffer
Generates one source of actions for the given Dockable. The ActionOffer is free how to use the actions that are created by other parts of the system, but it is a good idea to use all of them. Note that each argument, and each element in an array, can be null.

Specified by:
getSource in interface ActionOffer
Parameters:
dockable - The Dockable for which the the source has to be created. An invocation of interested should return true, otherwise the behavior of this method is not specified.
source - the DockActionSource derived from dockable
guards - a list of DockActionSources derived from ActionGuards
parent - the DockActionSource derived from the parent of dockable
parents - a list of DockActionSources derived from all parents of dockable
Returns:
The source that was created.