Search in sources :

Example 26 with Entry

use of org.freeplane.core.ui.menubuilders.generic.Entry 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 27 with Entry

use of org.freeplane.core.ui.menubuilders.generic.Entry in project freeplane by freeplane.

the class ActionSelectListenerTest method activatesSelectOnPopup_forCheckSelectionOnPopup.

@Test
public void activatesSelectOnPopup_forCheckSelectionOnPopup() {
    Entry menuEntry = new Entry();
    Entry actionEntry = new Entry();
    menuEntry.addChild(actionEntry);
    final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
    when(someAction.checkSelectionOnPopup()).thenReturn(true);
    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).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 28 with Entry

use of org.freeplane.core.ui.menubuilders.generic.Entry in project freeplane by freeplane.

the class ComponentBuilderTest method testName.

@Test
public void testName() throws Exception {
    final Entry entry = new Entry();
    final Component testComponent = new JPanel();
    final ComponentBuilder builder = new ComponentBuilder(new ComponentProvider() {

        @Override
        public Component createComponent(Entry entry) {
            return testComponent;
        }
    });
    builder.visit(entry);
    Assert.assertThat(new EntryAccessor().getComponent(entry), CoreMatchers.<Object>equalTo(testComponent));
}
Also used : JPanel(javax.swing.JPanel) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) ComponentProvider(org.freeplane.core.ui.menubuilders.menu.ComponentProvider) Component(java.awt.Component) Test(org.junit.Test)

Example 29 with Entry

use of org.freeplane.core.ui.menubuilders.generic.Entry in project freeplane by freeplane.

the class EntriesForActionTest method returnsEmptyListIfNoActionWasRegistered.

@Test
public void returnsEmptyListIfNoActionWasRegistered() throws Exception {
    final EntriesForAction entriesForAction = new EntriesForAction();
    AFreeplaneAction action = mock(AFreeplaneAction.class);
    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)

Example 30 with Entry

use of org.freeplane.core.ui.menubuilders.generic.Entry in project freeplane by freeplane.

the class EntriesForActionTest method returnsListWithRegisteredAction.

@Test
public void returnsListWithRegisteredAction() throws Exception {
    final EntriesForAction entriesForAction = new EntriesForAction();
    AFreeplaneAction action = mock(AFreeplaneAction.class);
    final Entry actionEntry = new Entry();
    entriesForAction.registerEntry(action, actionEntry);
    Collection<Entry> entries = entriesForAction.entries(action);
    assertThat(entries, equalTo((Collection<Entry>) asList(actionEntry)));
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

Entry (org.freeplane.core.ui.menubuilders.generic.Entry)64 Test (org.junit.Test)49 EntryAccessor (org.freeplane.core.ui.menubuilders.generic.EntryAccessor)36 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)22 JMenu (javax.swing.JMenu)9 Container (java.awt.Container)5 PhaseProcessor (org.freeplane.core.ui.menubuilders.generic.PhaseProcessor)5 SubtreeProcessor (org.freeplane.core.ui.menubuilders.generic.SubtreeProcessor)4 JComponent (javax.swing.JComponent)3 JMenuItem (javax.swing.JMenuItem)3 JPanel (javax.swing.JPanel)3 JToolBar (javax.swing.JToolBar)3 FreeplaneToolBar (org.freeplane.core.ui.components.FreeplaneToolBar)3 JToolbarComponentBuilder (org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder)3 Component (java.awt.Component)2 Collection (java.util.Collection)2 JButton (javax.swing.JButton)2 IUserInputListenerFactory (org.freeplane.core.ui.IUserInputListenerFactory)2 FreeplaneMenuBar (org.freeplane.core.ui.components.FreeplaneMenuBar)2 AcceleratebleActionProvider (org.freeplane.core.ui.menubuilders.action.AcceleratebleActionProvider)2