Package docking.menu

Class MenuManager


  • public class MenuManager
    extends java.lang.Object
    Class to manage a hierarchy of menus.
    • 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 mnemonic
        group - 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
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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()