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);
}
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);
}
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;
}
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));
}
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);
}
Aggregations