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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
createContentToolbarItems
(Bar toolbar) Fills the toolbar with the installed actions and submenus.Creates aContextMenu
containing the installed actions and submenus.void
fillContextMenu
(ContextMenu contextMenu) Fills theContextMenu
with the installed actions and submenus.findSubMenu
(String id) Find aMenuBuilder
for an existing sub-menu.Return the (read-only) list of group names already defined.Return the (read-only) list of sub-menu ids already defined.void
installAction
(Action action) Install the given action into the default menu groupGROUP_DEFAULT
.void
installAction
(String group, Action action) Install the given action into the given menu group.installSubMenu
(String group, String id, Action action) Install a sub-menu and return aMenuBuilder
for it.
-
Field Details
-
GROUP_DEFAULT
The name of the default menu group. By convention it is the last group in the menu.- See Also:
-
-
Method Details
-
installAction
Install the given action into the default menu groupGROUP_DEFAULT
.- Parameters:
action
- theAction
to install.
-
installAction
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 itaction
- theAction
to install- See Also:
-
getGroups
Return the (read-only) list of group names already defined.- Returns:
- a list of Strings.
-
findSubMenu
Find aMenuBuilder
for an existing sub-menu. If the sub-menu does not exist, this will returnnull
.- Parameters:
id
- the sub-menu's id- Returns:
- the
MenuBuilder
ornull
, if there is no sub-menu with the given id.
-
installSubMenu
Install a sub-menu and return aMenuBuilder
for it. If the sub-menu already exists, this method will throw anIllegalArgumentException
.- Parameters:
group
- the group into which to install itid
- the sub-menu's idaction
- 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 isnull
.
-
getSubMenuIDs
Return the (read-only) list of sub-menu ids already defined.- Returns:
- a list of Strings.
-
createContentToolbarItems
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 aContextMenu
containing the installed actions and submenus. Adds a separator between different groups.- Returns:
- the created context menu
-