Interface MenuBuilder

  • All Known Implementing Classes:
    BasicMenuBuilder

    public interface MenuBuilder
    The MenuBuilder is responsible for the construction of some kind of menu UI in response to contributions it receives.
    • Field Detail

      • GROUP_DEFAULT

        static final String GROUP_DEFAULT
        The name of the default menu group. By convention it is the last group in the menu.
        See Also:
        Constant Field Values
    • Method Detail

      • installAction

        void installAction​(Action action)
        Install the given action into the default menu group GROUP_DEFAULT.
        Parameters:
        action - the Action to install.
      • installAction

        void installAction​(String group,
                           Action action)
        Install the given action into the given menu group. If the group does not exist, it will be created on the fly.
        Parameters:
        group - the group into which to install it
        action - the Action to install
        See Also:
        GROUP_DEFAULT
      • getGroups

        List<String> getGroups()
        Return the (read-only) list of group names already defined.
        Returns:
        a list of Strings.
      • findSubMenu

        MenuBuilder findSubMenu​(String id)
        Find a MenuBuilder for an existing sub-menu. If the sub-menu does not exist, this will return null.
        Parameters:
        id - the sub-menu's id
        Returns:
        the MenuBuilder or null, if there is no sub-menu with the given id.
      • installSubMenu

        MenuBuilder installSubMenu​(String group,
                                   String id,
                                   Action action)
        Install a sub-menu and return a MenuBuilder for it. If the sub-menu already exists, this method will throw an IllegalArgumentException.
        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
        Throws:
        IllegalArgumentException - if a sub-menu for the given id already exists or any of the parameters is null.
      • getSubMenuIDs

        Set<String> getSubMenuIDs()
        Return the (read-only) list of sub-menu ids already defined.
        Returns:
        a list of Strings.
      • createContentToolbarItems

        void createContentToolbarItems​(Bar toolbar)
        Fills the toolbar with the installed actions and submenus. Adds separators between different groups.
        Parameters:
        toolbar - the toolbar which should be filled
      • createContextMenu

        ContextMenu createContextMenu()
        Creates a ContextMenu containing the installed actions and submenus. Adds a separator between different groups.
        Returns:
        the created context menu
      • fillContextMenu

        void fillContextMenu​(ContextMenu contextMenu)
        Fills the ContextMenu with the installed actions and submenus. Adds a separator between different groups.
        Parameters:
        contextMenu - the context menu which should be filled