Search in sources :

Example 61 with AFreeplaneAction

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

the class MIconController method getMindIcons.

public Collection<MindIcon> getMindIcons() {
    final List<MindIcon> iconInfoList = new ArrayList<MindIcon>();
    final Collection<AFreeplaneAction> iconActions = getIconActions();
    for (final Action action : iconActions) {
        final MindIcon info = ((IconAction) action).getMindIcon();
        iconInfoList.add(info);
    }
    return iconInfoList;
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Action(javax.swing.Action) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) ArrayList(java.util.ArrayList) MindIcon(org.freeplane.features.icon.MindIcon)

Example 62 with AFreeplaneAction

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

the class MIconController method addActionToIconSubmenu.

private void addActionToIconSubmenu(final JMenu menu, final MindIcon icon, final String fileName) {
    final AFreeplaneAction myAction = iconActions.get(icon);
    final int separatorPosition = fileName.indexOf('/');
    if (separatorPosition == -1) {
        new MenuSplitter().addMenuComponent(menu, new JMenuItem(myAction), menu.getItemCount());
        return;
    }
    final String submenuName = fileName.substring(0, separatorPosition);
    final int componentCount = menu.getItemCount();
    if (componentCount != 0) {
        final Component lastComponent = menu.getMenuComponent(componentCount - 1);
        if (lastComponent instanceof JMenu) {
            final JMenu lastSubmenu = (JMenu) lastComponent;
            if (lastSubmenu.getText().equals(submenuName)) {
                addActionToIconSubmenu(lastSubmenu, icon, fileName.substring(separatorPosition + 1));
                return;
            }
        }
    }
    final JMenu submenu = new JMenu(submenuName);
    menu.add(submenu);
    addActionToIconSubmenu(submenu, icon, fileName.substring(separatorPosition + 1));
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) MenuSplitter(org.freeplane.core.ui.MenuSplitter) JMenuItem(javax.swing.JMenuItem) JComponent(javax.swing.JComponent) Component(java.awt.Component) Point(java.awt.Point) JMenu(javax.swing.JMenu)

Example 63 with AFreeplaneAction

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

the class MIconController method createPreferences.

private void createPreferences() {
    final MModeController modeController = (MModeController) Controller.getCurrentModeController();
    final OptionPanelBuilder optionPanelBuilder = modeController.getOptionPanelBuilder();
    final List<AFreeplaneAction> actions = new ArrayList<AFreeplaneAction>();
    actions.addAll(iconActions.values());
    actions.add(modeController.getAction("RemoveIcon_0_Action"));
    actions.add(modeController.getAction("RemoveIconAction"));
    actions.add(modeController.getAction("RemoveAllIconsAction"));
    for (final AFreeplaneAction iconAction : actions) {
        final IIconInformation info = (IIconInformation) iconAction;
        optionPanelBuilder.addCreator("Keystrokes/icons", new IPropertyControlCreator() {

            public IPropertyControl createControl() {
                final KeyProperty keyProperty = new KeyProperty(info.getShortcutKey(), info.getTranslationKeyLabel());
                keyProperty.setImageIcon(info.getIcon());
                keyProperty.disableModifiers();
                return keyProperty;
            }
        }, IndexedTree.AS_CHILD);
    }
}
Also used : IPropertyControlCreator(org.freeplane.core.resources.components.IPropertyControlCreator) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) OptionPanelBuilder(org.freeplane.core.resources.components.OptionPanelBuilder) ArrayList(java.util.ArrayList) IIconInformation(org.freeplane.features.icon.IIconInformation) IPropertyControl(org.freeplane.core.resources.components.IPropertyControl) KeyProperty(org.freeplane.core.resources.components.KeyProperty) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 64 with AFreeplaneAction

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

the class MIconController method updateIconToolbar.

private void updateIconToolbar(ModeController modeController) {
    iconToolBar.removeAll();
    iconToolBar.add(modeController.getAction("RemoveIcon_0_Action")).setAlignmentX(JComponent.CENTER_ALIGNMENT);
    iconToolBar.add(modeController.getAction("RemoveIconAction")).setAlignmentX(JComponent.CENTER_ALIGNMENT);
    iconToolBar.add(modeController.getAction("RemoveAllIconsAction")).setAlignmentX(JComponent.CENTER_ALIGNMENT);
    iconToolBar.addSeparator();
    if (ResourceController.getResourceController().getBooleanProperty("structured_icon_toolbar")) {
        insertSubmenus(iconToolBar);
        return;
    }
    final String[] fpIcons = ResourceController.getResourceController().getProperty("icons.list").split(";");
    for (final String icon : fpIcons) {
        final MindIcon mindIcon = STORE.getMindIcon(icon);
        final AFreeplaneAction iconAction = iconActions.get(mindIcon);
        iconToolBar.add(iconAction).setAlignmentX(JComponent.CENTER_ALIGNMENT);
    }
    final Collection<MindIcon> userIcons = STORE.getUserIcons();
    for (final MindIcon icon : userIcons) {
        final AFreeplaneAction iconAction = iconActions.get(icon);
        iconToolBar.add(iconAction).setAlignmentX(JComponent.CENTER_ALIGNMENT);
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) MindIcon(org.freeplane.features.icon.MindIcon)

Example 65 with AFreeplaneAction

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

the class InputController method keyPressed.

public void keyPressed(KeyEvent e) {
    KeyStroke currentStroke = KeyStroke.getKeyStrokeForEvent(e);
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        TreePath path = ((JTree) e.getSource()).getSelectionPath();
        if (path == null) {
            return;
        }
        AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
        if (node instanceof IWorkspaceNodeActionListener) {
            ((IWorkspaceNodeActionListener) node).handleAction(new WorkspaceActionEvent(node, WorkspaceActionEvent.WSNODE_OPEN_DOCUMENT, 0, 0, e.getComponent()));
            e.consume();
        }
    } else {
        for (HotKeyIdentifier id : actionKeyMap.keySet()) {
            if (currentStroke.equals(id.getKeyStroke())) {
                if (id.accept(e)) {
                    AFreeplaneAction action = WorkspaceController.getAction(actionKeyMap.get(id));
                    if (action != null) {
                        action.actionPerformed(new ActionEvent(e.getSource(), 0, null));
                    } else {
                        LogUtils.info("No action set for: " + id.getKeyStroke());
                    }
                }
                e.consume();
                break;
            }
        }
    }
}
Also used : JTree(javax.swing.JTree) AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) TreePath(javax.swing.tree.TreePath) IWorkspaceNodeActionListener(org.freeplane.plugin.workspace.event.IWorkspaceNodeActionListener) WorkspaceActionEvent(org.freeplane.plugin.workspace.event.WorkspaceActionEvent) WorkspaceActionEvent(org.freeplane.plugin.workspace.event.WorkspaceActionEvent) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke)

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