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