Search in sources :

Example 46 with EntryAccessor

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

the class JMenuItemBuilderTest method whenPopupMenuBecomesVisible_itsChildActionPopupListenerIsCalled.

@Test
public void whenPopupMenuBecomesVisible_itsChildActionPopupListenerIsCalled() {
    menuEntry.addChild(actionEntry);
    menuActionGroupBuilder.visit(menuEntry);
    JMenu item = (JMenu) new EntryAccessor().getComponent(menuEntry);
    item.getPopupMenu().setVisible(true);
    verify(popupListener).childEntriesWillBecomeVisible(actionEntry);
}
Also used : EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JMenu(javax.swing.JMenu) Test(org.junit.Test)

Example 47 with EntryAccessor

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

the class JMenuItemBuilderTest method createsMenuButtonWithAction.

@Test
public void createsMenuButtonWithAction() {
    new EntryAccessor().setComponent(menuEntry, menu);
    menuEntry.addChild(actionEntry);
    menuActionGroupBuilder.visit(actionEntry);
    JMenuItem item = (JMenuItem) new EntryAccessor().getComponent(actionEntry);
    assertThatMenuItemHasCorrectAction(item);
    assertThat(item.getParent(), CoreMatchers.<Container>equalTo(menu.getPopupMenu()));
}
Also used : EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JMenuItem(javax.swing.JMenuItem) Test(org.junit.Test)

Example 48 with EntryAccessor

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

the class JMenuItemBuilderTest method createsMenuItemWithSelectableAction.

@Test
public void createsMenuItemWithSelectableAction() {
    menuEntry.addChild(actionEntry);
    when(action.isSelectable()).thenReturn(true);
    new EntryAccessor().setComponent(menuEntry, menu);
    menuActionGroupBuilder.visit(actionEntry);
    JAutoCheckBoxMenuItem item = (JAutoCheckBoxMenuItem) new EntryAccessor().getComponent(actionEntry);
    final AccelerateableAction itemAction = (AccelerateableAction) item.getAction();
    assertThat(itemAction.getOriginalAction(), CoreMatchers.<Action>equalTo(action));
    assertThat(item.getParent(), CoreMatchers.<Container>equalTo(menu.getPopupMenu()));
}
Also used : EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JAutoCheckBoxMenuItem(org.freeplane.core.ui.components.JAutoCheckBoxMenuItem) AccelerateableAction(org.freeplane.core.ui.AccelerateableAction) Test(org.junit.Test)

Example 49 with EntryAccessor

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

the class JMenuItemBuilderTest method createsSubmenuWithoutAction.

@Test
public void createsSubmenuWithoutAction() {
    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);
    assertThat(item.getParent(), CoreMatchers.<Container>equalTo(parentMenu.getPopupMenu()));
}
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 50 with EntryAccessor

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

the class JMenuItemBuilderTest method whenPopupMenuBecomesVisible_itsChildGroupPopupListenerIsCalled.

@Test
public void whenPopupMenuBecomesVisible_itsChildGroupPopupListenerIsCalled() {
    menuEntry.addChild(groupEntry);
    menuActionGroupBuilder.visit(menuEntry);
    JMenu menu = (JMenu) new EntryAccessor().getComponent(menuEntry);
    menu.getPopupMenu().setVisible(true);
    verify(popupListener).childEntriesWillBecomeVisible(groupEntry);
}
Also used : 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