Search in sources :

Example 6 with Entry

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

the class JMenuItemBuilderTest method createsMainMenuWithoutAction.

@Test
public void createsMainMenuWithoutAction() {
    Entry parentMenuEntry = new Entry();
    final FreeplaneMenuBar parentMenu = TestMenuBarFactory.createFreeplaneMenuBar();
    new EntryAccessor().setComponent(parentMenuEntry, parentMenu);
    parentMenuEntry.addChild(menuEntry);
    menuEntry.addChild(actionEntry);
    menuActionGroupBuilder.visit(menuEntry);
    JMenu item = (JMenu) new EntryAccessor().getComponent(menuEntry);
    assertThat(item.getParent(), CoreMatchers.<Container>equalTo(parentMenu));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) FreeplaneMenuBar(org.freeplane.core.ui.components.FreeplaneMenuBar) JMenu(javax.swing.JMenu) Test(org.junit.Test)

Example 7 with Entry

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

the class JMenuItemBuilderTest method whenPopupMenuBecomesInvisible_popupListenerIsCalled.

@Test
public void whenPopupMenuBecomesInvisible_popupListenerIsCalled() throws Exception {
    Entry parentMenuEntry = new Entry();
    final JMenu parentMenu = new JMenu();
    new EntryAccessor().setComponent(parentMenuEntry, parentMenu);
    parentMenuEntry.addChild(menuEntry);
    menuEntry.addChild(actionEntry);
    menuActionGroupBuilder.visit(menuEntry);
    JMenu item = (JMenu) new EntryAccessor().getComponent(menuEntry);
    item.getPopupMenu().setVisible(true);
    item.getPopupMenu().setVisible(false);
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
        }
    });
    verify(popupListener).childEntriesHidden(menuEntry);
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JMenu(javax.swing.JMenu) Test(org.junit.Test)

Example 8 with Entry

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

the class JMenuRadioGroupBuilderTest method setup.

@Before
public void setup() {
    actionEntry = new Entry();
    action = Mockito.mock(AFreeplaneAction.class);
    actionEntry.setName("action");
    new EntryAccessor().setAction(actionEntry, action);
    menuEntry = new Entry();
    menuEntry.setName("menu");
    groupEntry = new Entry();
    menu = new JMenu();
    popupListener = mock(EntryPopupListener.class);
    resourceAccessorMock = mock(ResourceAccessor.class);
    when(resourceAccessorMock.getRawText(anyString())).thenReturn("");
    when(resourceAccessorMock.getRawText("menu")).thenReturn("menu");
    accelerators = mock(IAcceleratorMap.class);
    acceleratebleActionProvider = new AcceleratebleActionProvider() {

        @Override
        protected boolean isApplet() {
            return false;
        }
    };
    radioGroupBuilder = new JMenuRadioGroupBuilder(popupListener, accelerators, acceleratebleActionProvider, resourceAccessorMock);
}
Also used : ResourceAccessor(org.freeplane.core.ui.menubuilders.generic.ResourceAccessor) IAcceleratorMap(org.freeplane.core.ui.menubuilders.action.IAcceleratorMap) AcceleratebleActionProvider(org.freeplane.core.ui.menubuilders.action.AcceleratebleActionProvider) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JMenu(javax.swing.JMenu) EntryPopupListener(org.freeplane.core.ui.menubuilders.generic.EntryPopupListener) Before(org.junit.Before)

Example 9 with Entry

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

the class JToolbarComponentBuilderTest method createsToolbarButtonWithAction.

@Test
public void createsToolbarButtonWithAction() {
    Entry actionEntry = new Entry();
    final AFreeplaneAction action = Mockito.mock(AFreeplaneAction.class);
    new EntryAccessor().setAction(actionEntry, action);
    Entry toolbarEntry = new Entry();
    final FreeplaneToolBar toolbar = new FreeplaneToolBar("toolbar", SwingConstants.HORIZONTAL);
    new EntryAccessor().setComponent(toolbarEntry, toolbar);
    toolbarEntry.addChild(actionEntry);
    final JToolbarComponentBuilder toolbarActionGroupBuilder = new JToolbarComponentBuilder();
    toolbarActionGroupBuilder.visit(actionEntry);
    JButton button = (JButton) new EntryAccessor().getComponent(actionEntry);
    assertThat(button.getAction(), CoreMatchers.<Action>equalTo(action));
    assertThat(button.getParent(), CoreMatchers.equalTo((Container) toolbar));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Container(java.awt.Container) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar) JButton(javax.swing.JButton) JToolbarComponentBuilder(org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder) Test(org.junit.Test)

Example 10 with Entry

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

the class MenuAcceleratorChangeListenerTest method setsKeystroke.

@Test
public void setsKeystroke() throws Exception {
    final EntriesForAction entriesForAction = new EntriesForAction();
    final MenuAcceleratorChangeListener menuAcceleratorChangeListener = new MenuAcceleratorChangeListener(entriesForAction);
    final AFreeplaneAction action = mock(AFreeplaneAction.class);
    Entry actionEntry = new Entry();
    final JMenuItem menu = new JMenuItem();
    new EntryAccessor().setComponent(actionEntry, menu);
    entriesForAction.registerEntry(action, actionEntry);
    final KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0);
    menuAcceleratorChangeListener.acceleratorChanged(action, null, keyStroke);
    Assert.assertThat(menu.getAccelerator(), equalTo(keyStroke));
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) EntriesForAction(org.freeplane.core.ui.menubuilders.action.EntriesForAction) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) KeyStroke(javax.swing.KeyStroke) JMenuItem(javax.swing.JMenuItem) 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