Search in sources :

Example 36 with AFreeplaneAction

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

the class AcceleratorBuilder method visit.

public void visit(Entry entry) {
    final AFreeplaneAction action = new EntryAccessor().getAction(entry);
    if (action != null) {
        final EntryAccessor entryAccessor = new EntryAccessor();
        String accelerator = entryAccessor.getAccelerator(entry);
        if (accelerator != null) {
            map.setDefaultAccelerator(action, accelerator);
        } else
            map.setUserDefinedAccelerator(action);
        entries.registerEntry(action, entry);
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor)

Example 37 with AFreeplaneAction

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

the class ActionFinder method visit.

@Override
public void visit(final Entry target) {
    final String actionName = target.getName();
    if (!actionName.isEmpty() && new EntryAccessor().getAction(target) == null) {
        AFreeplaneAction action = freeplaneActions.getAction(actionName);
        if (action == null) {
            for (final Class<? extends AFreeplaneAction> actionClass : Arrays.asList(SetBooleanPropertyAction.class, SetBooleanMapPropertyAction.class, SetBooleanMapViewPropertyAction.class, SetStringPropertyAction.class)) {
                final String setBooleanPropertyActionPrefix = actionClass.getSimpleName() + ".";
                if (actionName.startsWith(setBooleanPropertyActionPrefix)) {
                    String propertyName = actionName.substring(setBooleanPropertyActionPrefix.length());
                    action = createAction(actionClass, propertyName);
                    if (action != null) {
                        freeplaneActions.addAction(action);
                    }
                    break;
                }
            }
        }
        new EntryAccessor().setAction(target, action);
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor)

Example 38 with AFreeplaneAction

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

the class MenuBuilderIntegrationTest method createsToolbarButtonWithAction.

@Test
public void createsToolbarButtonWithAction() {
    String content = "<FreeplaneUIEntries>" + "<Entry name='home' builder='toolbar'>" + "<Entry name='action'/>" + "</Entry>" + "</FreeplaneUIEntries>";
    final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
    when(freeplaneActions.getAction("action")).thenReturn(someAction);
    Entry builtMenuStructure = buildJMenu(content);
    assertThat(((JButton) new EntryAccessor().getComponent(builtMenuStructure.getChild(0).getChild(0))).getAction(), CoreMatchers.<Action>equalTo(someAction));
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Test(org.junit.Test)

Example 39 with AFreeplaneAction

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

the class MenuBuilderIntegrationTest method givengroupWithAction_addsActionButtonToToolbar.

@Test
public void givengroupWithAction_addsActionButtonToToolbar() {
    String content = "<FreeplaneUIEntries>" + "<Entry name='home' builder='toolbar'>" + "<Entry name='action'/>" + "</Entry>" + "</FreeplaneUIEntries>";
    final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
    when(freeplaneActions.getAction("action")).thenReturn(someAction);
    Entry builtMenuStructure = buildJMenu(content);
    final JToolBar toolbar = (JToolBar) new EntryAccessor().getComponent(builtMenuStructure.getChild(0));
    final JButton button = (JButton) new EntryAccessor().getComponent(builtMenuStructure.getChild(0).getChild(0));
    assertThat(button.getParent(), CoreMatchers.equalTo((Container) toolbar));
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Container(java.awt.Container) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar) Test(org.junit.Test)

Example 40 with AFreeplaneAction

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

the class AcceleratorBuilderTest method registersEntryWithAction.

@Test
public void registersEntryWithAction() {
    Entry actionEntry = new Entry();
    final AFreeplaneAction action = mock(AFreeplaneAction.class);
    new EntryAccessor().setAction(actionEntry, action);
    IAcceleratorMap map = mock(IAcceleratorMap.class);
    IEntriesForAction entries = mock(IEntriesForAction.class);
    final AcceleratorBuilder acceleratorBuilder = new AcceleratorBuilder(map, entries);
    acceleratorBuilder.visit(actionEntry);
    Mockito.verify(entries).registerEntry(action, actionEntry);
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Test(org.junit.Test)

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