Search in sources :

Example 6 with EntryAccessor

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

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

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

use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor 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)

Example 10 with EntryAccessor

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

the class MenuBuildProcessFactoryTest method ifProcessOnPopupIsSet_buildsWhenItBecomesVisible.

@Test
public void ifProcessOnPopupIsSet_buildsWhenItBecomesVisible() throws Exception {
    final Entry menuStructure = XmlEntryStructureBuilder.buildMenuStructure("<Entry builder='main_menu'>" + "<Entry name='submenu'>" + "<Entry name='submenu' processOnPopup='true'>" + "<Entry name='action'/>" + "</Entry>" + "</Entry>" + "</Entry>");
    phaseProcessor.build(menuStructure);
    final Entry openedEntry = menuStructure.getChild(0, 0, 0);
    JMenu menu = (JMenu) new EntryAccessor().getComponent(openedEntry);
    menu.getPopupMenu().setVisible(true);
    verify(freeplaneActions).getAction("action");
}
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)

Aggregations

EntryAccessor (org.freeplane.core.ui.menubuilders.generic.EntryAccessor)58 Entry (org.freeplane.core.ui.menubuilders.generic.Entry)40 Test (org.junit.Test)35 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)27 JMenu (javax.swing.JMenu)13 Component (java.awt.Component)6 Container (java.awt.Container)6 JMenuItem (javax.swing.JMenuItem)6 JToolBar (javax.swing.JToolBar)4 JButton (javax.swing.JButton)3 JComponent (javax.swing.JComponent)3 JPanel (javax.swing.JPanel)3 FreeplaneMenuBar (org.freeplane.core.ui.components.FreeplaneMenuBar)3 FreeplaneToolBar (org.freeplane.core.ui.components.FreeplaneToolBar)3 FreeplaneResourceAccessor (org.freeplane.core.ui.menubuilders.FreeplaneResourceAccessor)3 JToolbarComponentBuilder (org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder)3 ActionEvent (java.awt.event.ActionEvent)2 KeyStroke (javax.swing.KeyStroke)2 ResourceController (org.freeplane.core.resources.ResourceController)2 ActionEnabler (org.freeplane.core.ui.ActionEnabler)2