use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class JMenuItemBuilderTest method createsMenuButtonWithAcceleratedAction.
@Test
public void createsMenuButtonWithAcceleratedAction() {
final EntryAccessor entryAccessor = new EntryAccessor();
entryAccessor.setComponent(menuEntry, menu);
menuEntry.addChild(actionEntry);
final KeyStroke keyStroke = KeyStroke.getKeyStroke('A');
when(accelerators.getAccelerator(action)).thenReturn(keyStroke);
menuActionGroupBuilder.visit(actionEntry);
JMenuItem item = (JMenuItem) new EntryAccessor().getComponent(actionEntry);
Assert.assertThat(item.getAccelerator(), equalTo(keyStroke));
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class JMenuItemBuilderTest method createsMenuSeparator.
@Test
public void createsMenuSeparator() {
new EntryAccessor().setComponent(menuEntry, menu);
Entry separatorEntry = new Entry();
separatorEntry.setBuilders(asList("separator"));
menuEntry.addChild(separatorEntry);
menuActionGroupBuilder.visit(separatorEntry);
JPopupMenu.Separator separator = (JPopupMenu.Separator) new EntryAccessor().getComponent(separatorEntry);
assertThat(separator.getParent(), CoreMatchers.<Container>equalTo(menu.getPopupMenu()));
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class JMenuItemBuilderTest method setup.
@Before
public void setup() {
actionEntry = new Entry();
action = Mockito.mock(AFreeplaneAction.class);
actionEntry.setName("action");
when(action.getKey()).thenReturn("action");
when(action.getRawText()).thenReturn("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;
}
};
menuActionGroupBuilder = new JMenuItemBuilder(popupListener, accelerators, acceleratebleActionProvider, resourceAccessorMock);
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class JMenuItemBuilderTest method createsSubmenuWithAction.
@Test
public void createsSubmenuWithAction() {
Entry parentMenuEntry = new Entry();
final JMenu parentMenu = new JMenu();
new EntryAccessor().setComponent(parentMenuEntry, parentMenu);
parentMenuEntry.addChild(menuEntry);
menuEntry.addChild(actionEntry);
new EntryAccessor().setAction(menuEntry, action);
menuActionGroupBuilder.visit(menuEntry);
final JMenuItem menuItem = getFirstSubMenuItem(menuEntry);
assertThatMenuItemHasCorrectAction(menuItem);
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class JMenubarBuilderTest method createsEmptyToolbarComponent.
@Test
public void createsEmptyToolbarComponent() {
Entry toolbarEntry = new Entry();
final IUserInputListenerFactory userInputListenerFactory = mock(IUserInputListenerFactory.class);
final FreeplaneMenuBar menubar = TestMenuBarFactory.createFreeplaneMenuBar();
when(userInputListenerFactory.getMenuBar()).thenReturn(menubar);
final JMenubarBuilder toolbarBuilder = new JMenubarBuilder(userInputListenerFactory);
toolbarBuilder.visit(toolbarEntry);
assertThat(new EntryAccessor().getComponent(toolbarEntry), CoreMatchers.<Object>is(menubar));
}
Aggregations