Class 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 an ActionManager 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 Detail

      • AbstractPopupMenuBuilder

        protected AbstractPopupMenuBuilder​(ActionManager manager,
                                           ActionBuilder builder)
        Creates a new instance of AbstractPopupMenuBuilder.
        Parameters:
        manager - the ActionManager
        builder - the ActionBuilder
    • Method Detail

      • getActionManager

        public ActionManager getActionManager()
        Returns the ActionManager this builder delegates to.
        Returns:
        the ActionManager
      • getActionBuilder

        public ActionBuilder getActionBuilder()
        Returns the ActionBuilder data object to be passed to the action manager.
        Returns:
        the ActionBuilder
      • 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 interface PopupMenuBuilder
        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). Its create() method returns the menu created. The passed in ActionData 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 interface PopupMenuBuilder
        Parameters:
        menuDesc - an ActionData 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 the ActionManager in order to add new elements to it.
        Returns:
        the menu to be constructed