Class AbstractPopupMenuBuilder
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.action.AbstractPopupMenuBuilder
-
- All Implemented Interfaces:
PopupMenuBuilder
public abstract class AbstractPopupMenuBuilder extends Object implements PopupMenuBuilder
An abstract base class for implementations of the
PopupMenuBuilder
interface.The idea behind this class is that the basic functionality required for a popup builder is already provided by an
ActionManager
. For instance, methods for adding actions, separators, or sub menus can be directly delegated to the corresponding methods of the action manager. Therefore, an instance is initialized with anActionManager
reference and meta data to be passed to the methods of the action manager. Based on this most of the creation methods can be implemented. Concrete subclasses just have to provide the actual creation methods - i.e. they have to create the correct objects required by the UI toolkit in use.- Since:
- 1.3
- Version:
- $Id$
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPopupMenuBuilder(ActionManager manager, ActionBuilder builder)
Creates a new instance ofAbstractPopupMenuBuilder
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description PopupMenuBuilder
addAction(FormAction action)
Adds an action to the current menu.PopupMenuBuilder
addSeparator()
Adds a separator to the current menu.PopupMenuBuilder
addSubMenu(Object subMenu)
Adds a sub menu to the current menu.ActionBuilder
getActionBuilder()
Returns theActionBuilder
data object to be passed to the action manager.ActionManager
getActionManager()
Returns theActionManager
this builder delegates to.protected abstract Object
getMenuUnderConstruction()
Returns the menu which is currently under construction.PopupMenuBuilder
subMenuBuilder(ActionData menuDesc)
Returns a builder for creating a sub menu.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.jguiraffe.gui.builder.action.PopupMenuBuilder
create
-
-
-
-
Constructor Detail
-
AbstractPopupMenuBuilder
protected AbstractPopupMenuBuilder(ActionManager manager, ActionBuilder builder)
Creates a new instance ofAbstractPopupMenuBuilder
.- Parameters:
manager
- theActionManager
builder
- theActionBuilder
-
-
Method Detail
-
getActionManager
public ActionManager getActionManager()
Returns theActionManager
this builder delegates to.- Returns:
- the
ActionManager
-
getActionBuilder
public ActionBuilder getActionBuilder()
Returns theActionBuilder
data object to be passed to the action manager.- Returns:
- the
ActionBuilder
-
addAction
public PopupMenuBuilder addAction(FormAction action)
Adds an action to the current menu. This will create a menu item that invokes this action when it is selected by the user. The properties of this item (like text, icon, etc.) are obtained from the action object. This implementation delegates to theActionManager.createMenuItem(ActionBuilder, FormAction, boolean, Object)
method.- Specified by:
addAction
in interfacePopupMenuBuilder
- Parameters:
action
- the action to be added (must not be null)- Returns:
- a reference to this builder
-
addSeparator
public PopupMenuBuilder addSeparator()
Adds a separator to the current menu. Separators can be used for grouping related menu items. This implementation delegates to theActionManager.addMenuSeparator(ActionBuilder, Object)
method of the wrapped action builder.- Specified by:
addSeparator
in interfacePopupMenuBuilder
- Returns:
- a reference to this builder
-
addSubMenu
public PopupMenuBuilder addSubMenu(Object subMenu)
Adds a sub menu to the current menu. This allows for complex structures of hierarchical menus. The object passed to this method must be a menu that was created by a sub menu builder. This implementation is actually a dummy. The newly created sub menu is already added by the sub menu builder.- Specified by:
addSubMenu
in interfacePopupMenuBuilder
- Parameters:
subMenu
- the sub menu to add (must not be null)- Returns:
- a reference to this builder
- See Also:
PopupMenuBuilder.subMenuBuilder(ActionData)
-
subMenuBuilder
public PopupMenuBuilder subMenuBuilder(ActionData menuDesc)
Returns a builder for creating a sub menu. The builder returned by this method can be used to define the sub menu (i.e. add actions, separators, and further sub menus as desired). Itscreate()
method returns the menu created. The passed inActionData
object contains the definition of the menu as it will be displayed in the parent menu (i.e. its text, icon, etc.). This implementation creates a special builder implementation for defining a sub menu.- Specified by:
subMenuBuilder
in interfacePopupMenuBuilder
- Parameters:
menuDesc
- anActionData
object with the properties of the sub menu (must not be null)- Returns:
- a builder for defining the new sub menu
-
getMenuUnderConstruction
protected abstract Object getMenuUnderConstruction()
Returns the menu which is currently under construction. This object is passed to theActionManager
in order to add new elements to it.- Returns:
- the menu to be constructed
-
-