Search in sources :

Example 66 with AFreeplaneAction

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

the class WorkspacePopupMenuBuilder method addActions.

public static void addActions(final WorkspacePopupMenu popupMenu, final String[] keys) {
    assert popupMenu != null;
    assert keys != null;
    Stack<JMenu> subMenuStack = new Stack<JMenu>();
    for (String key : keys) {
        if (key == null) {
            continue;
        } else if (key.equals(SEPARATOR)) {
            if (subMenuStack.size() == 0) {
                popupMenu.addSeparator();
            } else {
                subMenuStack.peek().addSeparator();
            }
        } else if (key.startsWith("beginSubMenu")) {
            String popupName = key.substring("beginSubMenu".length());
            JMenu subMenu = new JMenu(popupName);
            (subMenuStack.size() == 0 ? popupMenu : subMenuStack.peek()).add(subMenu);
            subMenuStack.push(subMenu);
        } else if (key.equals("endSubMenu")) {
            subMenuStack.pop();
        } else {
            AFreeplaneAction action = Controller.getCurrentController().getAction(key);
            if (action == null) {
                continue;
            }
            addAction(popupMenu, subMenuStack.size() == 0 ? popupMenu : subMenuStack.peek(), action);
        }
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) JMenu(javax.swing.JMenu) Stack(java.util.Stack)

Aggregations

AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)66 EntryAccessor (org.freeplane.core.ui.menubuilders.generic.EntryAccessor)23 Entry (org.freeplane.core.ui.menubuilders.generic.Entry)20 Test (org.junit.Test)20 Component (java.awt.Component)9 ArrayList (java.util.ArrayList)9 KeyStroke (javax.swing.KeyStroke)8 JCommandButton (org.pushingpixels.flamingo.api.common.JCommandButton)8 Container (java.awt.Container)6 ARibbonContributor (org.freeplane.core.ui.ribbon.ARibbonContributor)6 RibbonBuildContext (org.freeplane.core.ui.ribbon.RibbonBuildContext)6 Controller (org.freeplane.features.mode.Controller)6 ModeController (org.freeplane.features.mode.ModeController)6 ActionEvent (java.awt.event.ActionEvent)5 JMenuItem (javax.swing.JMenuItem)5 ResourceController (org.freeplane.core.resources.ResourceController)5 JComponent (javax.swing.JComponent)4 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)4 RichTooltip (org.pushingpixels.flamingo.api.common.RichTooltip)4 PopupPanelCallback (org.pushingpixels.flamingo.api.common.popup.PopupPanelCallback)4