Package docking.menu
Class MenuManager
- java.lang.Object
-
- docking.menu.MenuManager
-
public class MenuManager extends java.lang.Object
Class to manage a hierarchy of menus.
-
-
Constructor Summary
Constructors Constructor Description MenuManager(java.lang.String name, char mnemonicKey, java.lang.String group, boolean usePopupPath, MenuHandler menuHandler, MenuGroupMap menuGroupMap)
Constructs a new MenuManager
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAction(DockingActionIf action)
Adds an action to this menu.void
dispose()
DockingActionIf
getAction(java.lang.String actionName)
java.lang.String
getGroup()
javax.swing.JMenu
getMenu()
Returns a Menu hierarchy of all the actionsjavax.swing.event.PopupMenuListener
getMenuHandler()
javax.swing.JMenuItem
getMenuItem()
java.lang.String
getMenuItemText()
static char
getMnemonicKey(java.lang.String str)
Parses the mnemonic key from the menu items text.javax.swing.JPopupMenu
getPopupMenu()
Returns a JPopupMenu for the action hierarchyjava.lang.String
getSubGroup()
boolean
isEmpty()
Tests if this menu is empty.void
menuGroupChanged(java.lang.String[] theMenuPath, int i, java.lang.String localGroup)
Notification that a menu item has changed groups.boolean
removeAction(DockingActionIf action)
static java.lang.String
stripMnemonicAmp(java.lang.String text)
Removes the Mnemonic indicator character (&) from the textjava.lang.String
toString()
-
-
-
Constructor Detail
-
MenuManager
public MenuManager(java.lang.String name, char mnemonicKey, java.lang.String group, boolean usePopupPath, MenuHandler menuHandler, MenuGroupMap menuGroupMap)
Constructs a new MenuManager- Parameters:
name
- the name of the menu.mnemonicKey
- the key to use for the menu mnemonicgroup
- the group of the menu.usePopupPath
- if true, registers actions with popup paths as popup items.menuHandler
- Listener to be notified of menu behavior.menuGroupMap
- maps menu groups to menu paths
-
-
Method Detail
-
addAction
public void addAction(DockingActionIf action)
Adds an action to this menu. Can create subMenus depending on the menuPath of the action- Parameters:
action
- the action to be added
-
getAction
public DockingActionIf getAction(java.lang.String actionName)
-
getMnemonicKey
public static char getMnemonicKey(java.lang.String str)
Parses the mnemonic key from the menu items text.- Parameters:
str
- the menu item text- Returns:
- the mnemonic key for encoded in the actions menu text. Returns 0 if there is none.
-
stripMnemonicAmp
public static java.lang.String stripMnemonicAmp(java.lang.String text)
Removes the Mnemonic indicator character (&) from the text- Parameters:
text
- the text to strip- Returns:
- the stripped mnemonic
-
isEmpty
public boolean isEmpty()
Tests if this menu is empty.
-
getMenu
public javax.swing.JMenu getMenu()
Returns a Menu hierarchy of all the actions- Returns:
- the menu
-
getMenuItem
public javax.swing.JMenuItem getMenuItem()
- See Also:
ManagedMenuItem.getMenuItem()
-
getGroup
public java.lang.String getGroup()
- See Also:
ManagedMenuItem.getGroup()
-
getSubGroup
public java.lang.String getSubGroup()
-
dispose
public void dispose()
-
getPopupMenu
public javax.swing.JPopupMenu getPopupMenu()
Returns a JPopupMenu for the action hierarchy- Returns:
- the popup menu
-
removeAction
public boolean removeAction(DockingActionIf action)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
menuGroupChanged
public void menuGroupChanged(java.lang.String[] theMenuPath, int i, java.lang.String localGroup)
Notification that a menu item has changed groups.- Parameters:
theMenuPath
- the menu path of the item whose group changed.i
- the index into the menu path of the part that changed groups.localGroup
- the new group.
-
getMenuHandler
public javax.swing.event.PopupMenuListener getMenuHandler()
-
getMenuItemText
public java.lang.String getMenuItemText()
-
-