Package ca.phon.ui.menu
Class MenuBuilder
java.lang.Object
ca.phon.ui.menu.MenuBuilder
Helper class for building menus. Menus items are 'addressed' using paths. Paths are alphanumeric sequences separated by '/'. Each section of the path is path of the menu hierarchy, with the final item naming the terminating menu/menu item.
Example paths:
File
The file menu.View/Record Data/My Item
The item with name 'My Item' in the View/Record Data' menu.
When adding a MenuElement
, location of the element may be specified in the path
by adding the '@' token followed by
^
- place new element at beginning of this menu$
- place new element at end of the menu (default behaviour)- item name - place after given item name (or end if not found)
File@^
in the path given to the addMenu(String, String)
and
addItem(String, Action)
methods.
Menu builders may be attached to existing menus, in which case existing menu items may be addressed using the scheme above. Menu items are typically added 'before' or 'after' existing items.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addItem
(String path, MenuElement ele) void
addItem
(MenuElement elem, int insertIdx, MenuElement menuItem) void
addMenu
(MenuElement elem, int insertIdx, String text) void
addSeparator
(String path, String sepName) void
appendSubItems
(String path, MenuElement menu) Append all subitems from the givenMenuElement
at the provied path.void
appendSubItems
(MenuElement parent, String path, MenuElement menu) getRoot()
void
Clear root menu element
-
Constructor Details
-
MenuBuilder
public MenuBuilder() -
MenuBuilder
-
-
Method Details
-
getRoot
-
removeAll
public void removeAll()Clear root menu element -
addMenu
-
addMenu
-
getMenu
-
addMenu
-
addSeparator
-
addItem
-
addItem
-
addItem
-
addItem
-
addItem
-
appendSubItems
Append all subitems from the givenMenuElement
at the provied path.- Parameters:
path
-menu
-
-
appendSubItems
-