Search in sources :

Example 1 with IFreeplaneAction

use of org.freeplane.core.ui.IFreeplaneAction in project freeplane by freeplane.

the class MenuActionComponentProvider method createComponent.

/* (non-Javadoc)
	 * @see org.freeplane.core.ui.menubuilders.menu.ComponentProvider#createComponent(org.freeplane.core.ui.menubuilders.generic.Entry)
	 */
@Override
public Component createComponent(Entry entry) {
    final AFreeplaneAction action = entryAccessor.getAction(entry);
    if (action != null) {
        final JMenuItem actionComponent;
        IFreeplaneAction wrappedAction = acceleratebleActionProvider.wrap(action);
        if (action.isSelectable()) {
            actionComponent = new JAutoCheckBoxMenuItem(wrappedAction);
        } else {
            actionComponent = new JFreeplaneMenuItem(wrappedAction);
        }
        final KeyStroke accelerator = accelerators.getAccelerator(action);
        actionComponent.setAccelerator(accelerator);
        MenuIconScaling.scaleIcon(actionComponent);
        return actionComponent;
    } else if (entry.builders().contains("separator")) {
        return new JPopupMenu.Separator();
    } else
        return null;
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) IFreeplaneAction(org.freeplane.core.ui.IFreeplaneAction) JAutoCheckBoxMenuItem(org.freeplane.core.ui.components.JAutoCheckBoxMenuItem) KeyStroke(javax.swing.KeyStroke) JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu) JFreeplaneMenuItem(org.freeplane.core.ui.components.JFreeplaneMenuItem)

Example 2 with IFreeplaneAction

use of org.freeplane.core.ui.IFreeplaneAction in project freeplane by freeplane.

the class MenuRadioActionComponentProvider method createComponent.

/* (non-Javadoc)
	 * @see org.freeplane.core.ui.menubuilders.menu.ComponentProvider#createComponent(org.freeplane.core.ui.menubuilders.generic.Entry)
	 */
@Override
public Component createComponent(Entry entry) {
    final AFreeplaneAction action = entryAccessor.getAction(entry);
    if (action != null) {
        final JMenuItem actionComponent;
        IFreeplaneAction wrappedAction = acceleratebleActionProvider.wrap(action);
        if (action.isSelectable()) {
            actionComponent = new JAutoRadioButtonMenuItem(wrappedAction);
        } else {
            actionComponent = new JRadioButtonMenuItem(wrappedAction);
        }
        actionComponent.setSelected(Boolean.parseBoolean(String.valueOf(entry.getAttribute("selected"))) || entry.getName().equals(getSelectedActionName(entry)));
        buttonGroup.add(actionComponent);
        final KeyStroke accelerator = accelerators.getAccelerator(action);
        actionComponent.setAccelerator(accelerator);
        MenuIconScaling.scaleIcon(actionComponent);
        return actionComponent;
    } else if (entry.builders().contains("separator")) {
        return new JPopupMenu.Separator();
    } else
        return null;
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) IFreeplaneAction(org.freeplane.core.ui.IFreeplaneAction) KeyStroke(javax.swing.KeyStroke) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JMenuItem(javax.swing.JMenuItem) JAutoRadioButtonMenuItem(org.freeplane.core.ui.components.JAutoRadioButtonMenuItem) JPopupMenu(javax.swing.JPopupMenu)

Example 3 with IFreeplaneAction

use of org.freeplane.core.ui.IFreeplaneAction 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;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Node(org.freeplane.core.ui.IndexedTree.Node) IFreeplaneAction(org.freeplane.core.ui.IFreeplaneAction) Node(org.freeplane.core.ui.IndexedTree.Node) IndexedTree(org.freeplane.core.ui.IndexedTree) JMenuItem(javax.swing.JMenuItem)

Example 4 with IFreeplaneAction

use of org.freeplane.core.ui.IFreeplaneAction in project freeplane by freeplane.

the class LastOpenedList method updateMenus.

private void updateMenus() {
    Controller controller = Controller.getCurrentController();
    final ModeController modeController = controller.getModeController();
    if (!modeController.getUserInputListenerFactory().useRibbonMenu()) {
        final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder(MenuBuilder.class);
        menuBuilder.removeChildElements(MENU_CATEGORY);
        List<AFreeplaneAction> openMapActions = createOpenLastMapActionList();
        for (AFreeplaneAction openMapAction : openMapActions) {
            final IFreeplaneAction acceleratableAction = menuBuilder.acceleratableAction(openMapAction);
            final JMenuItem item = new JFreeplaneMenuItem(acceleratableAction);
            item.setMnemonic(0);
            menuBuilder.addMenuItem(MENU_CATEGORY, item, MENU_CATEGORY + '/' + openMapAction.getKey(), UIBuilder.AS_CHILD);
        }
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) IFreeplaneAction(org.freeplane.core.ui.IFreeplaneAction) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ResourceController(org.freeplane.core.resources.ResourceController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) JMenuItem(javax.swing.JMenuItem) MenuBuilder(org.freeplane.core.ui.MenuBuilder) JFreeplaneMenuItem(org.freeplane.core.ui.components.JFreeplaneMenuItem)

Aggregations

JMenuItem (javax.swing.JMenuItem)4 IFreeplaneAction (org.freeplane.core.ui.IFreeplaneAction)4 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)3 JPopupMenu (javax.swing.JPopupMenu)2 KeyStroke (javax.swing.KeyStroke)2 JFreeplaneMenuItem (org.freeplane.core.ui.components.JFreeplaneMenuItem)2 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 ResourceController (org.freeplane.core.resources.ResourceController)1 IndexedTree (org.freeplane.core.ui.IndexedTree)1 Node (org.freeplane.core.ui.IndexedTree.Node)1 MenuBuilder (org.freeplane.core.ui.MenuBuilder)1 JAutoCheckBoxMenuItem (org.freeplane.core.ui.components.JAutoCheckBoxMenuItem)1 JAutoRadioButtonMenuItem (org.freeplane.core.ui.components.JAutoRadioButtonMenuItem)1 Controller (org.freeplane.features.mode.Controller)1 ModeController (org.freeplane.features.mode.ModeController)1 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)1