Search in sources :

Example 21 with AFreeplaneAction

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

the class JComponentRemover method visit.

@Override
public void visit(Entry target) {
    final EntryAccessor entryAccessor = new EntryAccessor();
    final Component component = (Component) entryAccessor.removeComponent(target);
    if (component != null) {
        if (component instanceof AbstractButton)
            ((AbstractButton) component).setAction(null);
        removeMenuComponent(component);
        ActionEnabler actionEnabler = target.removeAttribute(ActionEnabler.class);
        if (actionEnabler != null) {
            final AFreeplaneAction action = entryAccessor.getAction(target);
            action.removePropertyChangeListener(actionEnabler);
        }
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) AbstractButton(javax.swing.AbstractButton) ActionEnabler(org.freeplane.core.ui.ActionEnabler) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Component(java.awt.Component)

Example 22 with AFreeplaneAction

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

the class LastOpenedList method updateMenus.

private void updateMenus(ModeController modeController, Entry target) {
    List<AFreeplaneAction> openMapActions = createOpenLastMapActionList();
    for (AFreeplaneAction openMapAction : openMapActions) {
        modeController.addActionIfNotAlreadySet(openMapAction);
        new EntryAccessor().addChildAction(target, openMapAction);
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor)

Example 23 with AFreeplaneAction

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

the class AcceleratorBuilderTest method setsDefaultAcceleratorForAction.

@Test
public void setsDefaultAcceleratorForAction() {
    Entry actionEntry = new Entry();
    String actionKey = "actionKey";
    actionEntry.setName(actionKey);
    String keyStroke = KeyStroke.getKeyStroke('A', InputEvent.CTRL_MASK).toString();
    actionEntry.setAttribute("accelerator", keyStroke);
    final AFreeplaneAction action = mock(AFreeplaneAction.class);
    new EntryAccessor().setAction(actionEntry, action);
    IAcceleratorMap map = mock(IAcceleratorMap.class);
    final AcceleratorBuilder acceleratorBuilder = new AcceleratorBuilder(map, mock(IEntriesForAction.class));
    acceleratorBuilder.visit(actionEntry);
    Mockito.verify(map).setDefaultAccelerator(action, keyStroke);
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 24 with AFreeplaneAction

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

the class AcceleratorBuilderTest method givenEntryWithoutAccelerator_doesNotSetOwnDefaultAccelerator.

@Test
public void givenEntryWithoutAccelerator_doesNotSetOwnDefaultAccelerator() {
    Entry actionEntry = new Entry();
    final AFreeplaneAction action = mock(AFreeplaneAction.class);
    new EntryAccessor().setAction(actionEntry, action);
    IAcceleratorMap map = mock(IAcceleratorMap.class);
    final AcceleratorBuilder acceleratorBuilder = new AcceleratorBuilder(map, mock(IEntriesForAction.class));
    acceleratorBuilder.visit(actionEntry);
    Mockito.verify(map, never()).setDefaultAccelerator(Mockito.<AFreeplaneAction>any(), anyString());
}
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)

Example 25 with AFreeplaneAction

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

the class ActionFinderTest method attachesExistingFreeplaneAction.

@Test
public void attachesExistingFreeplaneAction() {
    FreeplaneActions freeplaneActions = mock(FreeplaneActions.class);
    Entry entry = new Entry();
    entry.setName("action");
    final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
    when(freeplaneActions.getAction("action")).thenReturn(someAction);
    final ActionFinder actionFinder = new ActionFinder(freeplaneActions);
    actionFinder.visit(entry);
    assertThat((AFreeplaneAction) new EntryAccessor().getAction(entry), CoreMatchers.equalTo(someAction));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) FreeplaneActions(org.freeplane.features.mode.FreeplaneActions) 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