Search in sources :

Example 41 with Entry

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

the class XmlEntryStructureBuilderTest method givenXmlWithChildEntryWithFalse_createsBooleanObject.

@Test
public void givenXmlWithChildEntryWithFalse_createsBooleanObject() {
    String xmlWithoutContent = "<FreeplaneUIEntries><Entry builderSpecificAttribute='FAlse'/></FreeplaneUIEntries>";
    Entry builtMenuStructure = XmlEntryStructureBuilder.buildMenuStructure(xmlWithoutContent);
    Entry menuStructureWithChildEntry = new Entry();
    final Entry childEntry = new Entry();
    childEntry.setAttribute("builderSpecificAttribute", false);
    menuStructureWithChildEntry.addChild(childEntry);
    assertThat(builtMenuStructure, equalTo(menuStructureWithChildEntry));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Test(org.junit.Test)

Example 42 with Entry

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

the class XmlEntryStructureBuilderTest method givenXmlWithSameChildLevels_createsStructure.

@Test
public void givenXmlWithSameChildLevels_createsStructure() {
    String xmlWithoutContent = "<FreeplaneUIEntries><Entry name='level1'/>" + "<Entry name='level2'/>" + "</FreeplaneUIEntries>";
    Entry builtMenuStructure = XmlEntryStructureBuilder.buildMenuStructure(xmlWithoutContent);
    Entry menuStructureWithChildEntry = new Entry();
    final Entry childEntry = new Entry();
    childEntry.setName("level1");
    menuStructureWithChildEntry.addChild(childEntry);
    final Entry child2Entry = new Entry();
    child2Entry.setName("level2");
    menuStructureWithChildEntry.addChild(child2Entry);
    assertThat(builtMenuStructure, equalTo(menuStructureWithChildEntry));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Test(org.junit.Test)

Example 43 with Entry

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

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

the class AcceleratorBuilderTest method ignoresEntryWithoutAction.

@Test
public void ignoresEntryWithoutAction() {
    Entry actionEntry = new Entry();
    String actionKey = "actionKey";
    actionEntry.setName(actionKey);
    String keyStroke = "CONTROL A";
    actionEntry.setAttribute("accelerator", keyStroke);
    IAcceleratorMap map = mock(IAcceleratorMap.class);
    final AcceleratorBuilder acceleratorBuilder = new AcceleratorBuilder(map, mock(IEntriesForAction.class));
    acceleratorBuilder.visit(actionEntry);
    Mockito.verify(map, never()).setDefaultAccelerator(Mockito.<AFreeplaneAction>any(), Mockito.<String>any());
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 45 with Entry

use of org.freeplane.core.ui.menubuilders.generic.Entry 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)

Aggregations

Entry (org.freeplane.core.ui.menubuilders.generic.Entry)64 Test (org.junit.Test)49 EntryAccessor (org.freeplane.core.ui.menubuilders.generic.EntryAccessor)36 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)22 JMenu (javax.swing.JMenu)9 Container (java.awt.Container)5 PhaseProcessor (org.freeplane.core.ui.menubuilders.generic.PhaseProcessor)5 SubtreeProcessor (org.freeplane.core.ui.menubuilders.generic.SubtreeProcessor)4 JComponent (javax.swing.JComponent)3 JMenuItem (javax.swing.JMenuItem)3 JPanel (javax.swing.JPanel)3 JToolBar (javax.swing.JToolBar)3 FreeplaneToolBar (org.freeplane.core.ui.components.FreeplaneToolBar)3 JToolbarComponentBuilder (org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder)3 Component (java.awt.Component)2 Collection (java.util.Collection)2 JButton (javax.swing.JButton)2 IUserInputListenerFactory (org.freeplane.core.ui.IUserInputListenerFactory)2 FreeplaneMenuBar (org.freeplane.core.ui.components.FreeplaneMenuBar)2 AcceleratebleActionProvider (org.freeplane.core.ui.menubuilders.action.AcceleratebleActionProvider)2