Search in sources :

Example 36 with EntryAccessor

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

the class MenuBuilderIntegrationTest method createsToolbarButtonWithAction.

@Test
public void createsToolbarButtonWithAction() {
    String content = "<FreeplaneUIEntries>" + "<Entry name='home' builder='toolbar'>" + "<Entry name='action'/>" + "</Entry>" + "</FreeplaneUIEntries>";
    final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
    when(freeplaneActions.getAction("action")).thenReturn(someAction);
    Entry builtMenuStructure = buildJMenu(content);
    assertThat(((JButton) new EntryAccessor().getComponent(builtMenuStructure.getChild(0).getChild(0))).getAction(), CoreMatchers.<Action>equalTo(someAction));
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Test(org.junit.Test)

Example 37 with EntryAccessor

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

the class MenuBuilderIntegrationTest method givengroupWithAction_addsActionButtonToToolbar.

@Test
public void givengroupWithAction_addsActionButtonToToolbar() {
    String content = "<FreeplaneUIEntries>" + "<Entry name='home' builder='toolbar'>" + "<Entry name='action'/>" + "</Entry>" + "</FreeplaneUIEntries>";
    final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
    when(freeplaneActions.getAction("action")).thenReturn(someAction);
    Entry builtMenuStructure = buildJMenu(content);
    final JToolBar toolbar = (JToolBar) new EntryAccessor().getComponent(builtMenuStructure.getChild(0));
    final JButton button = (JButton) new EntryAccessor().getComponent(builtMenuStructure.getChild(0).getChild(0));
    assertThat(button.getParent(), CoreMatchers.equalTo((Container) toolbar));
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Container(java.awt.Container) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar) Test(org.junit.Test)

Example 38 with EntryAccessor

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

the class AcceleratorBuilderTest method registersEntryWithAction.

@Test
public void registersEntryWithAction() {
    Entry actionEntry = new Entry();
    final AFreeplaneAction action = mock(AFreeplaneAction.class);
    new EntryAccessor().setAction(actionEntry, action);
    IAcceleratorMap map = mock(IAcceleratorMap.class);
    IEntriesForAction entries = mock(IEntriesForAction.class);
    final AcceleratorBuilder acceleratorBuilder = new AcceleratorBuilder(map, entries);
    acceleratorBuilder.visit(actionEntry);
    Mockito.verify(entries).registerEntry(action, actionEntry);
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Test(org.junit.Test)

Example 39 with EntryAccessor

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

the class AcceleratorBuilderTest method givenEntryWithoutAccelerator_setsUserDefinedAccelerator.

@Test
public void givenEntryWithoutAccelerator_setsUserDefinedAccelerator() {
    Entry actionEntry = new Entry();
    final AFreeplaneAction action = mock(AFreeplaneAction.class);
    new EntryAccessor().setAction(actionEntry, action);
    IAcceleratorMap map = mock(IAcceleratorMap.class);
    final AcceleratorBuilder acceleratorBuilder = new AcceleratorBuilder(map, mock(IEntriesForAction.class));
    acceleratorBuilder.visit(actionEntry);
    Mockito.verify(map).setUserDefinedAccelerator(action);
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Test(org.junit.Test)

Example 40 with EntryAccessor

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

the class AcceleratorDestroyerTest method unregistersEntryWithAction.

@Test
public void unregistersEntryWithAction() {
    Entry actionEntry = new Entry();
    final AFreeplaneAction action = mock(AFreeplaneAction.class);
    new EntryAccessor().setAction(actionEntry, action);
    IEntriesForAction entries = mock(IEntriesForAction.class);
    final AcceleratorDestroyer acceleratorDestroyer = new AcceleratorDestroyer(entries);
    acceleratorDestroyer.visit(actionEntry);
    Mockito.verify(entries).unregisterEntry(action, actionEntry);
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) 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