Usage Example:
MenumyMenu = Menu.create() .setTitle("My Menu") .setIcon(Icons.ALL.menu()) .appendChild(new MenuItem< >("Menu Item 1"));
V
The type of the item value that the menu holds.
See also :
V
the type of value associated with this menu item
public void Menu()
public static Menu<V> create()
V
The type of the menu item value.
A new menu instance.
public Menu<V> appendChild(AbstractMenuItem<V> menuItem)
menuItem
The menu item to be added.
The current Menu instance.
public Menu<V> insertChild(int index, AbstractMenuItem<V> menuItem)
index
The index to insert the menu item at.
menuItem
The menu item to be added.
The current Menu instance.
public Menu<V> appendChild(MenuItemsGroup<V> menuGroup, MenuItemsGroupHandler<V, I> groupHandler)
I
The type of the abstract menu item.
menuGroup
The menu items group to be added.
groupHandler
The handler for the menu items group.
The current Menu instance.
public Menu<V> insertGroup(int index, MenuItemsGroup<V> menuGroup, MenuItemsGroupHandler<V, I> groupHandler)
index
The index to insert the menu items group at.
I
The type of the abstract menu item.
menuGroup
The menu items group to be added.
groupHandler
The handler for the menu items group.
The current Menu instance.
public Menu<V> removeItem(AbstractMenuItem<V> menuItem)
menuItem
The menu item to be removed.
The current Menu instance.
public Menu<V> removeItemAt(int index)
index
the index of the menu item to be removed.
The current Menu instance.
public Menu<V> removeAll()
The current Menu instance.
public Menu<V> appendChild(Separator separator)
separator
The separator to be added.
The current Menu instance.
public Menu<V> insertChild(int index, Separator separator)
index
The index to insert the separator at.
separator
The separator to be added.
The current Menu instance.
public HTMLDivElement element()
Retrieves the main HTMLDivElement element representing this menu.
Returns:
the main HTMLDivElement element.
public void clearSelection(boolean silent)
silent
if true, does not trigger the deselection listeners; otherwise, does.
public boolean onSearch(String token)
If no results match, a "no results" message is displayed.
token
the string to use for filtering the menu items.
true if one or more items match the search token, false otherwise.
public List<AbstractMenuItem<V>> getMenuItems()
the list of direct menu items.
public List<AbstractMenuItem<V>> getFlatMenuItems()
This method will return both direct menu items and those that are part of a MenuItemsGroup .
Returns:
a flattened list of all menu items.
public Menu<V> openSubMenu(Menu<V> dropMenu)
dropMenu
The submenu to open.
The current Menu instance.
public Menu<V> getParent()
The parent menu or null if there isn't any.
public AbstractMenuItem<V> getParentItem()
The parent menu item or null if there isn't any.
public boolean isSearchable()
true if the menu is searchable, false otherwise.
public Menu<V> setSearchable(boolean searchable)
searchable
true to enable search, false to disable.
The current Menu instance.
public void MenuItem(String text)
text
the text for the menu item
public void MenuItem(String text, String description)
text
the text for the menu item
description
the description for the menu item
public static MenuItem<V> create(String text)
text
the text for the menu item
the created menu item
public static MenuItem<V> create(String text, String description)
text
the text for the menu item
description
the description for the menu item
the created menu item
public MenuItem<V> withClickableElement(ChildHandler<MenuItem<V>, AnchorElement> handler)
handler
The child handler to apply.
This menu item instance.
public SmallElement getDescriptionElement()
the description element
public SpanElement getTextElement()
the text element
public String getText()
public boolean onSearch(String token, boolean caseSensitive)
token
the search token
caseSensitive
indicates if the search should be case-sensitive
true if the menu item contains the token, false otherwise