Package org.freeplane.core.util

# Class MenuUtils

java.lang.Object
org.freeplane.core.util.MenuUtils

public class MenuUtils extends Object
Utilities for dealing with the Freeplane menu: In scripts available as "global variable" menuUtils.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `MenuUtils.MenuEntry`
  The userObject type for createMenuEntryTree().
  `static class`
  `MenuUtils.MenuEntryTreeBuilder`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MenuUtils()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static DefaultMutableTreeNode`
  `createAcceleratebleMenuEntryTree(String menuRootKey)`
  Used as the basis for dynamic generation of hotkey list.
  `static DefaultMutableTreeNode`
  `createMenuEntryTree(String menuRootKey)`
  returns a tree of all `JMenuItem` nodes the menu contains (omitting Strings and Separators).
  `static void`
  `executeMenuItems(List<String> menuItemKeys)`
  to be used from scripts to execute menu items.
  `static org.freeplane.core.ui.IndexedTree.Node`
  `findAssignedMenuItemNodeRecursively(DefaultMutableTreeNode menubarNode, KeyStroke keystroke)`
  there are little reasons to use this in scripts.
  `static String`
  `formatKeyStroke(KeyStroke keyStroke)`
  pretty print a keystroke.
  `static Icon`
  `getMenuItemIcon(String menuItemKey)`
  returns the icon for a menuItemKey or null if it has none.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MenuUtils

    public MenuUtils()

- ## Method Details

  - ### createMenuEntryTree

    public static DefaultMutableTreeNode createMenuEntryTree(String menuRootKey)
    returns a tree of all `JMenuItem` nodes the menu contains (omitting Strings and Separators). The tree is build from `DefaultMutableTreeNode` nodes having `MenuEntry` objects as their userObjects. Note that the root node may have null as userObject if the menu item at `menuRootKey` doesn't contain a `JMenuItem`!
    Parameters:
      `menuRootKey` - the key of the node that should form the root of the output.
    Throws:
      `IllegalArgumentException` - if the menuRootKey does not point to an entry in the menu tree

  - ### createAcceleratebleMenuEntryTree

    public static DefaultMutableTreeNode createAcceleratebleMenuEntryTree(String menuRootKey)
    Used as the basis for dynamic generation of hotkey list. Same as `createMenuEntryTree(String)` but all MenuEntries without associated accelerator and (then) empty submenus are removed from the result.
    Throws:
      `IllegalArgumentException` - if the menuRootKey does not point to an entry in the menu tree

  - ### formatKeyStroke

    public static String formatKeyStroke(KeyStroke keyStroke)
    pretty print a keystroke.

  - ### findAssignedMenuItemNodeRecursively

    public static org.freeplane.core.ui.IndexedTree.Node findAssignedMenuItemNodeRecursively(DefaultMutableTreeNode menubarNode, KeyStroke keystroke)
    there are little reasons to use this in scripts.

  - ### executeMenuItems

    public static void executeMenuItems(List<String> menuItemKeys)
    to be used from scripts to execute menu items. Find out the menuItemKey of a menu item with the devtools add-on. It contains a tool for that.

  - ### getMenuItemIcon

    public static Icon getMenuItemIcon(String menuItemKey)
    returns the icon for a menuItemKey or null if it has none.