Class BasicMenuBuilder

java.lang.Object
com.levigo.jadice.web.client.ui.menu.BasicMenuBuilder
All Implemented Interfaces:
MenuBuilder

public class BasicMenuBuilder extends Object implements MenuBuilder
Default implementation of the MenuBuilder. It can be used to configure toolbar content and ContextMenus at the same time.

Usage: Create a new instance of the class using the constructor. Install all actions and sub menus which should be contained in resulting menu via installAction(Action), installAction(String, Action) and installSubMenu(String, String, Action). If all actions and sub menus are installed call createContextMenu() to create a ContextMenu out of the installed content or call createContentToolbarItems(Bar) to fill a toolbar with the installed content.

  • Constructor Details

    • BasicMenuBuilder

      public BasicMenuBuilder(Collection<Object> context)
      Creates a new BasicMenuBuilder with the given context.
      Parameters:
      context - the context
  • Method Details

    • installAction

      public void installAction(Action action)
      Description copied from interface: MenuBuilder
      Install the given action into the default menu group MenuBuilder.GROUP_DEFAULT.
      Specified by:
      installAction in interface MenuBuilder
      Parameters:
      action - the Action to install.
    • installAction

      public void installAction(String group, Action action)
      Description copied from interface: MenuBuilder
      Install the given action into the given menu group. If the group does not exist, it will be created on the fly.
      Specified by:
      installAction in interface MenuBuilder
      Parameters:
      group - the group into which to install it
      action - the Action to install
      See Also:
    • installSubMenu

      public MenuBuilder installSubMenu(String group, String id, Action action)
      Description copied from interface: MenuBuilder
      Install a sub-menu and return a MenuBuilder for it. If the sub-menu already exists, this method will throw an IllegalArgumentException.
      Specified by:
      installSubMenu in interface MenuBuilder
      Parameters:
      group - the group into which to install it
      id - the sub-menu's id
      action - the action describing the sub-menu.
      Returns:
      a MenuBuilder for the sub-menu
    • findSubMenu

      public MenuBuilder findSubMenu(String id)
      Description copied from interface: MenuBuilder
      Find a MenuBuilder for an existing sub-menu. If the sub-menu does not exist, this will return null.
      Specified by:
      findSubMenu in interface MenuBuilder
      Parameters:
      id - the sub-menu's id
      Returns:
      the MenuBuilder or null, if there is no sub-menu with the given id.
    • getGroups

      public List<String> getGroups()
      Description copied from interface: MenuBuilder
      Return the (read-only) list of group names already defined.
      Specified by:
      getGroups in interface MenuBuilder
      Returns:
      a list of Strings.
    • getSubMenuIDs

      public Set<String> getSubMenuIDs()
      Description copied from interface: MenuBuilder
      Return the (read-only) list of sub-menu ids already defined.
      Specified by:
      getSubMenuIDs in interface MenuBuilder
      Returns:
      a list of Strings.
    • createContentToolbarItems

      public void createContentToolbarItems(Bar toolbar)
      Description copied from interface: MenuBuilder
      Fills the toolbar with the installed actions and submenus. Adds separators between different groups.
      Specified by:
      createContentToolbarItems in interface MenuBuilder
      Parameters:
      toolbar - the toolbar which should be filled
    • createContextMenu

      public ContextMenu createContextMenu()
      Description copied from interface: MenuBuilder
      Creates a ContextMenu containing the installed actions and submenus. Adds a separator between different groups.
      Specified by:
      createContextMenu in interface MenuBuilder
      Returns:
      the created context menu
    • fillContextMenu

      public void fillContextMenu(ContextMenu contextMenu)
      Description copied from interface: MenuBuilder
      Fills the ContextMenu with the installed actions and submenus. Adds a separator between different groups.
      Specified by:
      fillContextMenu in interface MenuBuilder
      Parameters:
      contextMenu - the context menu which should be filled