Class BasicMenuBuilder
java.lang.Object
com.levigo.jadice.web.client.ui.menu.BasicMenuBuilder
- All Implemented Interfaces:
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.
-
Field Summary
Fields inherited from interface com.levigo.jadice.web.client.ui.menu.MenuBuilder
GROUP_DEFAULT
-
Constructor Summary
ConstructorDescriptionBasicMenuBuilder
(Collection<Object> context) Creates a newBasicMenuBuilder
with the given context. -
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 groupMenuBuilder.GROUP_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.
-
Constructor Details
-
BasicMenuBuilder
Creates a newBasicMenuBuilder
with the given context.- Parameters:
context
- the context
-
-
Method Details
-
installAction
Description copied from interface:MenuBuilder
Install the given action into the default menu groupMenuBuilder.GROUP_DEFAULT
.- Specified by:
installAction
in interfaceMenuBuilder
- Parameters:
action
- theAction
to install.
-
installAction
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 interfaceMenuBuilder
- Parameters:
group
- the group into which to install itaction
- theAction
to install- See Also:
-
installSubMenu
Description copied from interface:MenuBuilder
Install a sub-menu and return aMenuBuilder
for it. If the sub-menu already exists, this method will throw anIllegalArgumentException
.- Specified by:
installSubMenu
in interfaceMenuBuilder
- 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
-
findSubMenu
Description copied from interface:MenuBuilder
Find aMenuBuilder
for an existing sub-menu. If the sub-menu does not exist, this will returnnull
.- Specified by:
findSubMenu
in interfaceMenuBuilder
- Parameters:
id
- the sub-menu's id- Returns:
- the
MenuBuilder
ornull
, if there is no sub-menu with the given id.
-
getGroups
Description copied from interface:MenuBuilder
Return the (read-only) list of group names already defined.- Specified by:
getGroups
in interfaceMenuBuilder
- Returns:
- a list of Strings.
-
getSubMenuIDs
Description copied from interface:MenuBuilder
Return the (read-only) list of sub-menu ids already defined.- Specified by:
getSubMenuIDs
in interfaceMenuBuilder
- Returns:
- a list of Strings.
-
createContentToolbarItems
Description copied from interface:MenuBuilder
Fills the toolbar with the installed actions and submenus. Adds separators between different groups.- Specified by:
createContentToolbarItems
in interfaceMenuBuilder
- Parameters:
toolbar
- the toolbar which should be filled
-
createContextMenu
Description copied from interface:MenuBuilder
Creates aContextMenu
containing the installed actions and submenus. Adds a separator between different groups.- Specified by:
createContextMenu
in interfaceMenuBuilder
- Returns:
- the created context menu
-