Search in sources :

Example 1 with EntryAccessor

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

the class MenuUtils method getMenuItemIcon.

/**
 * returns the icon for a menuItemKey or null if it has none.
 */
public static Icon getMenuItemIcon(String menuItemKey) {
    Entry menuItem = genericMenuStructure().findEntry(menuItemKey);
    if (menuItem == null)
        return null;
    final EntryAccessor entryAccessor = new EntryAccessor(new FreeplaneResourceAccessor());
    final AFreeplaneAction action = entryAccessor.getAction(menuItem);
    return (Icon) action.getValue(Action.SMALL_ICON);
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) FreeplaneResourceAccessor(org.freeplane.core.ui.menubuilders.FreeplaneResourceAccessor) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Icon(javax.swing.Icon) MindIcon(org.freeplane.features.icon.MindIcon)

Example 2 with EntryAccessor

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

the class JMenuItemBuilderTest method createsGroupWithAction.

@Test
public void createsGroupWithAction() {
    Entry parentMenuEntry = new Entry();
    final JMenu parentMenu = new JMenu();
    new EntryAccessor().setComponent(parentMenuEntry, parentMenu);
    parentMenuEntry.addChild(groupEntry);
    groupEntry.addChild(actionEntry);
    new EntryAccessor().setAction(groupEntry, action);
    menuActionGroupBuilder.visit(groupEntry);
    final JMenuItem menuItem = getFirstSubMenuItem(groupEntry);
    assertThatMenuItemHasCorrectAction(menuItem);
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) Test(org.junit.Test)

Example 3 with EntryAccessor

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

the class JMenuItemBuilderTest method getFirstSubMenuItem.

private JMenuItem getFirstSubMenuItem(Entry entry) {
    JMenu menu = (JMenu) new EntryAccessor().getComponent(entry);
    final JMenuItem menuItem = (JMenuItem) menu.getPopupMenu().getComponent(0);
    return menuItem;
}
Also used : EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 4 with EntryAccessor

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

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

the class JMenuItemBuilderTest method whenPopupMenuBecomesVisible_itsOwnPopupListenerIsCalled.

@Test
public void whenPopupMenuBecomesVisible_itsOwnPopupListenerIsCalled() {
    menuEntry.addChild(actionEntry);
    menuActionGroupBuilder.visit(menuEntry);
    JMenu item = (JMenu) new EntryAccessor().getComponent(menuEntry);
    item.getPopupMenu().setVisible(true);
    verify(popupListener).childEntriesWillBecomeVisible(menuEntry);
}
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