use of org.freeplane.core.ui.IndexedTree.Node in project freeplane by freeplane.
the class MenuUtils method menuNode2menuEntryNode.
// in: node for JMenu, out: node for MenuEntry
private static DefaultMutableTreeNode menuNode2menuEntryNode(final DefaultMutableTreeNode menuNode, final HashMap<String, KeyStroke> menuKeyToKeyStrokeMap) {
final IndexedTree.Node node = (Node) menuNode;
final Object userObject = menuNode.getUserObject();
if (userObject instanceof JMenuItem) {
final JMenuItem jMenuItem = (JMenuItem) userObject;
final IFreeplaneAction action = (IFreeplaneAction) jMenuItem.getAction();
final String key = String.valueOf(node.getKey());
final String iconKey = action == null ? null : action.getIconKey();
return new DefaultMutableTreeNode(new MenuEntry(key, jMenuItem.getText(), iconKey, menuKeyToKeyStrokeMap.get(key), jMenuItem.getToolTipText()));
}
// - just omit them
return null;
}
use of org.freeplane.core.ui.IndexedTree.Node in project freeplane by freeplane.
the class MenuUtils method findAssignedMenuItemNodeRecursively.
/**
* there are little reasons to use this in scripts.
*/
public static Node findAssignedMenuItemNodeRecursively(final DefaultMutableTreeNode menubarNode, final KeyStroke keystroke) {
final Enumeration<?> children = menubarNode.children();
while (children.hasMoreElements()) {
final Node child = (Node) children.nextElement();
final Object childUserObject = child.getUserObject();
if (childUserObject instanceof JMenuItem) {
final JMenuItem childMenuItem = (JMenuItem) childUserObject;
if (keystroke.equals(childMenuItem.getAccelerator())) {
return child;
}
}
// recurse
final Node assignedMenuItemNode = findAssignedMenuItemNodeRecursively(child, keystroke);
if (assignedMenuItemNode != null)
return assignedMenuItemNode;
}
return null;
}
Aggregations