Search in sources :

Example 41 with AFreeplaneAction

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

the class AcceleratorBuilderTest method givenEntryWithoutAccelerator_setsUserDefinedAccelerator.

@Test
public void givenEntryWithoutAccelerator_setsUserDefinedAccelerator() {
    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).setUserDefinedAccelerator(action);
}
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 42 with AFreeplaneAction

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

the class AcceleratorDestroyerTest method unregistersEntryWithAction.

@Test
public void unregistersEntryWithAction() {
    Entry actionEntry = new Entry();
    final AFreeplaneAction action = mock(AFreeplaneAction.class);
    new EntryAccessor().setAction(actionEntry, action);
    IEntriesForAction entries = mock(IEntriesForAction.class);
    final AcceleratorDestroyer acceleratorDestroyer = new AcceleratorDestroyer(entries);
    acceleratorDestroyer.visit(actionEntry);
    Mockito.verify(entries).unregisterEntry(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)

Example 43 with AFreeplaneAction

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

the class ActionFinderTest method attachesSetBooleanPropertyAction.

@Test
public void attachesSetBooleanPropertyAction() {
    FreeplaneActions freeplaneActions = mock(FreeplaneActions.class);
    final SetBooleanPropertyAction setBooleanPropertyAction = Mockito.mock(SetBooleanPropertyAction.class);
    Entry entry = new Entry();
    final String propertyActionName = "SetBooleanPropertyAction.property";
    entry.setName(propertyActionName);
    when(freeplaneActions.getAction(propertyActionName)).thenReturn(null);
    final ActionFinder actionFinder = new ActionFinder(freeplaneActions) {

        @Override
        protected AFreeplaneAction createAction(Class<? extends AFreeplaneAction> actionClass, String propertyName) {
            return setBooleanPropertyAction;
        }
    };
    actionFinder.visit(entry);
    Mockito.verify(freeplaneActions).addAction(setBooleanPropertyAction);
    assertThat(new EntryAccessor().getAction(entry), CoreMatchers.<Object>equalTo(setBooleanPropertyAction));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) SetBooleanPropertyAction(org.freeplane.core.resources.SetBooleanPropertyAction) FreeplaneActions(org.freeplane.features.mode.FreeplaneActions) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Test(org.junit.Test)

Example 44 with AFreeplaneAction

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

the class ActionSelectListenerTest method dontActivateSelectOnPopup_forNotCheckSelectionOnPopup.

@Test
public void dontActivateSelectOnPopup_forNotCheckSelectionOnPopup() {
    Entry menuEntry = new Entry();
    Entry actionEntry = new Entry();
    menuEntry.addChild(actionEntry);
    final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
    when(someAction.checkSelectionOnPopup()).thenReturn(false);
    when(someAction.isEnabled()).thenReturn(true);
    new EntryAccessor().setAction(actionEntry, someAction);
    final EntryPopupListenerCollection entryPopupListenerCollection = new EntryPopupListenerCollection();
    final ActionSelectListener actionSelectListener = new ActionSelectListener();
    entryPopupListenerCollection.addEntryPopupListener(actionSelectListener);
    entryPopupListenerCollection.childEntriesWillBecomeVisible(menuEntry);
    verify(someAction, never()).setSelected();
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryPopupListenerCollection(org.freeplane.core.ui.menubuilders.generic.EntryPopupListenerCollection) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Test(org.junit.Test)

Example 45 with AFreeplaneAction

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

the class EntriesForActionTest method returnsEmptyListIfNoActionWasUnregistered.

@Test
public void returnsEmptyListIfNoActionWasUnregistered() throws Exception {
    final EntriesForAction entriesForAction = new EntriesForAction();
    AFreeplaneAction action = mock(AFreeplaneAction.class);
    final Entry actionEntry = new Entry();
    entriesForAction.registerEntry(action, actionEntry);
    entriesForAction.unregisterEntry(action, actionEntry);
    Collection<Entry> entries = entriesForAction.entries(action);
    assertThat(entries.isEmpty(), equalTo(true));
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) 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