com.levigo.util.swing.menu
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.

Caveat: levigo reserves the right to amend this interface in future releases. Therefore we strongly discourage independent implementations of it.


Nested Class Summary
static class MenuBuilder.ItemType
           
 
Field Summary
static String GROUP_DEFAULT
          The name of the default menu group.
static String GROUP_EDIT
          The name of the "edit" menu group.
static String GROUP_KEY
          The item type key queried on actions to determine the group name, if no explicit name has been specified upon installation.
static String GROUP_SETTINGS
          The name of the "settings" menu group.
static String ITEM_TYPE_KEY
          The item type key queried on actions to determine the type of menu item to create.
 
Method Summary
 MenuBuilder findSubMenu(String id)
          Find a MenuBuilder for an existing sub-menu.
 List<String> getGroups()
          Return the (read-only) list of group names already defined.
 Set<String> getSubMenuIDs()
          Return the (read-only) list of sub-menu ids already defined.
 void installAction(Action action)
          Install the given action into the default menu group GROUP_DEFAULT.
 void installAction(String group, Action action)
          Install the given action into the given menu group.
 MenuBuilder installSubMenu(String group, String id, Action action)
          Install a sub-menu and return a MenuBuilder for it.
 

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

GROUP_EDIT

static final String GROUP_EDIT
The name of the "edit" menu group.

See Also:
Constant Field Values

GROUP_SETTINGS

static final String GROUP_SETTINGS
The name of the "settings" menu group.

See Also:
Constant Field Values

GROUP_KEY

static final String GROUP_KEY
The item type key queried on actions to determine the group name, if no explicit name has been specified upon installation.

See Also:
Constant Field Values

ITEM_TYPE_KEY

static final String ITEM_TYPE_KEY
The item type key queried on actions to determine the type of menu item to create. This property must be used in conjunction with a value of type MenuBuilder.ItemType.

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. Callers are free to choose group names as they see fit. However, there are some pre-defined group names which can be used as appropriate.

Parameters:
group - the group into which to install it
action - the Action to install
See Also:
GROUP_DEFAULT, GROUP_EDIT, GROUP_SETTINGS

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. Please note that the action's ActionListener.actionPerformed(java.awt.event.ActionEvent) is never actually called.
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.


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.