Search in sources :

Example 1 with FreeplaneActions

use of org.freeplane.features.mode.FreeplaneActions 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)

Example 2 with FreeplaneActions

use of org.freeplane.features.mode.FreeplaneActions in project freeplane by freeplane.

the class MenuBuilderIntegrationTest method setup.

@Before
public void setup() {
    freeplaneActions = mock(FreeplaneActions.class);
    recursiveMenuStructureBuilder = new RecursiveMenuStructureProcessor();
    recursiveMenuStructureBuilder.setDefaultBuilderPair(EntryVisitor.EMTPY, EntryVisitor.EMTPY);
    final IUserInputListenerFactory userInputListenerFactory = mock(IUserInputListenerFactory.class);
    toolbar = new JToolBar();
    when(userInputListenerFactory.getToolBar("/main_toolbar")).thenReturn(toolbar);
    recursiveMenuStructureBuilder.addBuilder("toolbar", new JToolbarBuilder(userInputListenerFactory));
    recursiveMenuStructureBuilder.setSubtreeDefaultBuilderPair("toolbar", "toolbar.action");
    recursiveMenuStructureBuilder.addBuilderPair("toolbar.action", new BuilderDestroyerPair(new JToolbarComponentBuilder(), null));
}
Also used : RecursiveMenuStructureProcessor(org.freeplane.core.ui.menubuilders.generic.RecursiveMenuStructureProcessor) FreeplaneActions(org.freeplane.features.mode.FreeplaneActions) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) BuilderDestroyerPair(org.freeplane.core.ui.menubuilders.generic.BuilderDestroyerPair) JToolbarBuilder(org.freeplane.core.ui.menubuilders.menu.JToolbarBuilder) JToolbarComponentBuilder(org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder) JToolBar(javax.swing.JToolBar) Before(org.junit.Before)

Example 3 with FreeplaneActions

use of org.freeplane.features.mode.FreeplaneActions 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 4 with FreeplaneActions

use of org.freeplane.features.mode.FreeplaneActions in project freeplane by freeplane.

the class MenuBuildProcessFactoryTest method setup.

@Before
public void setup() {
    freeplaneActions = mock(FreeplaneActions.class);
    final ResourceAccessor resourceAccessorMock = mock(ResourceAccessor.class);
    when(resourceAccessorMock.getRawText(Matchers.anyString())).thenReturn("text");
    final IUserInputListenerFactory userInputListenerFactory = mock(IUserInputListenerFactory.class);
    final FreeplaneMenuBar menubar = TestMenuBarFactory.createFreeplaneMenuBar();
    when(userInputListenerFactory.getMenuBar()).thenReturn(menubar);
    phaseProcessor = new MenuBuildProcessFactory(userInputListenerFactory, freeplaneActions, resourceAccessorMock, mock(IAcceleratorMap.class), new EntriesForAction(), Collections.<BuildPhaseListener>emptyList()).getBuildProcessor();
}
Also used : ResourceAccessor(org.freeplane.core.ui.menubuilders.generic.ResourceAccessor) IAcceleratorMap(org.freeplane.core.ui.menubuilders.action.IAcceleratorMap) FreeplaneActions(org.freeplane.features.mode.FreeplaneActions) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) EntriesForAction(org.freeplane.core.ui.menubuilders.action.EntriesForAction) FreeplaneMenuBar(org.freeplane.core.ui.components.FreeplaneMenuBar) Before(org.junit.Before)

Aggregations

FreeplaneActions (org.freeplane.features.mode.FreeplaneActions)4 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)2 IUserInputListenerFactory (org.freeplane.core.ui.IUserInputListenerFactory)2 Entry (org.freeplane.core.ui.menubuilders.generic.Entry)2 EntryAccessor (org.freeplane.core.ui.menubuilders.generic.EntryAccessor)2 Before (org.junit.Before)2 Test (org.junit.Test)2 JToolBar (javax.swing.JToolBar)1 SetBooleanPropertyAction (org.freeplane.core.resources.SetBooleanPropertyAction)1 FreeplaneMenuBar (org.freeplane.core.ui.components.FreeplaneMenuBar)1 EntriesForAction (org.freeplane.core.ui.menubuilders.action.EntriesForAction)1 IAcceleratorMap (org.freeplane.core.ui.menubuilders.action.IAcceleratorMap)1 BuilderDestroyerPair (org.freeplane.core.ui.menubuilders.generic.BuilderDestroyerPair)1 RecursiveMenuStructureProcessor (org.freeplane.core.ui.menubuilders.generic.RecursiveMenuStructureProcessor)1 ResourceAccessor (org.freeplane.core.ui.menubuilders.generic.ResourceAccessor)1 JToolbarBuilder (org.freeplane.core.ui.menubuilders.menu.JToolbarBuilder)1 JToolbarComponentBuilder (org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder)1