Search in sources :

Example 21 with Entry

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

the class XmlEntryStructureBuilderTest method givenXmlWithChildEntryWithTrue_createsBooleanObject.

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

Example 22 with Entry

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

the class XmlEntryStructureBuilderTest method givenXmlWithourContent_createsEmptyStructure.

@Test
public void givenXmlWithourContent_createsEmptyStructure() {
    String xmlWithoutContent = "<FreeplaneUIEntries/>";
    Entry builtMenuStructure = XmlEntryStructureBuilder.buildMenuStructure(xmlWithoutContent);
    Entry menuStructureWithChildEntry = new Entry();
    assertThat(builtMenuStructure, equalTo(menuStructureWithChildEntry));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Test(org.junit.Test)

Example 23 with Entry

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

the class XmlEntryStructureBuilderTest method givenXmlWithChildEntryWithTwoBuilders_createsStructureWithChildEntry.

@Test
public void givenXmlWithChildEntryWithTwoBuilders_createsStructureWithChildEntry() {
    String xmlWithoutContent = "<FreeplaneUIEntries><Entry builder='builder1, builder2'/></FreeplaneUIEntries>";
    Entry builtMenuStructure = XmlEntryStructureBuilder.buildMenuStructure(xmlWithoutContent);
    Entry menuStructureWithChildEntry = new Entry();
    final Entry childEntry = new Entry();
    childEntry.setBuilders(asList("builder1", "builder2"));
    menuStructureWithChildEntry.addChild(childEntry);
    assertThat(builtMenuStructure, equalTo(menuStructureWithChildEntry));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Test(org.junit.Test)

Example 24 with Entry

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

the class AcceleratorBuilderTest method setsDefaultAcceleratorForAction.

@Test
public void setsDefaultAcceleratorForAction() {
    Entry actionEntry = new Entry();
    String actionKey = "actionKey";
    actionEntry.setName(actionKey);
    String keyStroke = KeyStroke.getKeyStroke('A', InputEvent.CTRL_MASK).toString();
    actionEntry.setAttribute("accelerator", keyStroke);
    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).setDefaultAccelerator(action, keyStroke);
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 25 with Entry

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

the class AcceleratorBuilderTest method givenEntryWithoutAccelerator_doesNotSetOwnDefaultAccelerator.

@Test
public void givenEntryWithoutAccelerator_doesNotSetOwnDefaultAccelerator() {
    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, never()).setDefaultAccelerator(Mockito.<AFreeplaneAction>any(), anyString());
}
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