Search in sources :

Example 6 with AFreeplaneAction

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

the class AController method addAction.

public void addAction(final AFreeplaneAction value) {
    final String key = value.getKey();
    final AFreeplaneAction old = getActions().put(key, value);
    // System.out.println("key\t\t" + value.getClass().getSimpleName() + "\t\ts/\\\"" + pattern + "\\\"/\\\"" + value.getClass().getSimpleName() + "\\\"/;");
    if (old != null && !old.equals(value)) {
        getActions().put(key, old);
        throw new RuntimeException("action " + key + " already registered");
    }
    if (AFreeplaneAction.checkSelectionOnPropertyChange(value)) {
        final ActionSelectorOnPropertyChange listener = new ActionSelectorOnPropertyChange(value);
        ResourceController.getResourceController().addPropertyChangeListener(listener);
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction)

Example 7 with AFreeplaneAction

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

the class MLinkController method setAnchorID.

public void setAnchorID(final String anchorID) {
    this.anchorID = anchorID;
    final String tooltip;
    AFreeplaneAction setLinkAnchorAction = modeController.getAction("SetLinkAnchorAction");
    final boolean anchored = isAnchored();
    if (anchored)
        tooltip = TextUtils.format(setLinkAnchorAction.getTooltipKey() + "_anchored", anchorID);
    else
        tooltip = TextUtils.getRawText(setLinkAnchorAction.getTooltipKey());
    setLinkAnchorAction.putValue(Action.SHORT_DESCRIPTION, tooltip);
    setLinkAnchorAction.putValue(Action.LONG_DESCRIPTION, tooltip);
    setLinkAnchorAction.setSelected(anchored);
    modeController.getAction("ClearLinkAnchorAction").setEnabled(anchored);
    modeController.getAction("MakeLinkToAnchorAction").setEnabled(anchored);
    modeController.getAction("MakeLinkFromAnchorAction").setEnabled(anchored);
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction)

Example 8 with AFreeplaneAction

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

the class LastOpenedList method createOpenLastMapActionList.

public List<AFreeplaneAction> createOpenLastMapActionList() {
    Controller controller = Controller.getCurrentController();
    final ModeController modeController = controller.getModeController();
    int i = 0;
    int maxEntries = getMaxMenuEntries();
    List<AFreeplaneAction> openMapActions = new ArrayList<AFreeplaneAction>(maxEntries);
    for (final String key : lastOpenedList) {
        if (i == 0 && (!modeController.getModeName().equals(MModeController.MODENAME) || controller.getMap() == null || controller.getMap().getURL() == null)) {
            i++;
            maxEntries++;
        }
        if (i == maxEntries) {
            break;
        }
        final AFreeplaneAction openMapAction = new OpenLastOpenedAction(i++, this, key);
        createOpenMapItemName(openMapAction, key);
        openMapActions.add(openMapAction);
    }
    return openMapActions;
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) ArrayList(java.util.ArrayList) 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)

Example 9 with AFreeplaneAction

use of org.freeplane.core.ui.AFreeplaneAction 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)

Example 10 with AFreeplaneAction

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

the class UserInputListenerFactory method updateModeMenu.

private void updateModeMenu() {
    if (!useRibbonMenu()) {
        getMenuBuilder(MenuBuilder.class).removeChildElements(FreeplaneMenuBar.MODES_MENU);
        Controller controller = Controller.getCurrentController();
        for (final String key : new LinkedList<String>(controller.getModes())) {
            final AFreeplaneAction modesMenuActionListener = new ModesMenuActionListener(key, controller);
            final ModeController modeController = controller.getModeController();
            final boolean isSelected;
            if (modeController != null) {
                isSelected = modeController.getModeName().equals(key);
            } else {
                isSelected = false;
            }
            getMenuBuilder(MenuBuilder.class).addRadioItem(FreeplaneMenuBar.MODES_MENU, modesMenuActionListener, isSelected);
            ResourceController.getResourceController().getProperty(("keystroke_mode_" + key));
        }
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) ModeController(org.freeplane.features.mode.ModeController) ResourceController(org.freeplane.core.resources.ResourceController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) MenuBuilder(org.freeplane.core.ui.MenuBuilder) LinkedList(java.util.LinkedList)

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