Package docking.menu
Class MenuManager
- java.lang.Object
-
- docking.menu.MenuManager
-
public class MenuManager extends java.lang.ObjectClass 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 voidaddAction(DockingActionIf action)Adds an action to this menu.voiddispose()DockingActionIfgetAction(java.lang.String actionName)java.lang.StringgetGroup()javax.swing.JMenugetMenu()Returns a Menu hierarchy of all the actionsjavax.swing.event.PopupMenuListenergetMenuHandler()javax.swing.JMenuItemgetMenuItem()java.lang.StringgetMenuItemText()static chargetMnemonicKey(java.lang.String str)Parses the mnemonic key from the menu items text.javax.swing.JPopupMenugetPopupMenu()Returns a JPopupMenu for the action hierarchyjava.lang.StringgetSubGroup()booleanisEmpty()Tests if this menu is empty.voidmenuGroupChanged(java.lang.String[] theMenuPath, int i, java.lang.String localGroup)Notification that a menu item has changed groups.booleanremoveAction(DockingActionIf action)static java.lang.StringstripMnemonicAmp(java.lang.String text)Removes the Mnemonic indicator character (&) from the textjava.lang.StringtoString()
-
-
-
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:
toStringin 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()
-
-