Search in sources :

Example 61 with Entry

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

the class JToolbarBuilderTest method createsEmptyToolbarComponent.

@Test
public void createsEmptyToolbarComponent() {
    Entry toolbarEntry = new Entry();
    final IUserInputListenerFactory userInputListenerFactory = mock(IUserInputListenerFactory.class);
    JToolBar toolbar = new JToolBar();
    when(userInputListenerFactory.getToolBar("/main_toolbar")).thenReturn(toolbar);
    final JToolbarBuilder toolbarBuilder = new JToolbarBuilder(userInputListenerFactory);
    toolbarBuilder.visit(toolbarEntry);
    assertThat(new EntryAccessor().getComponent(toolbarEntry), CoreMatchers.<Object>is(toolbar));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JToolBar(javax.swing.JToolBar) Test(org.junit.Test)

Example 62 with Entry

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

the class JToolbarComponentBuilderTest method createsToolbarButtonWithSelectableAction.

@Test
public void createsToolbarButtonWithSelectableAction() {
    Entry actionEntry = new Entry();
    final AFreeplaneAction action = Mockito.mock(AFreeplaneAction.class);
    when(action.isSelectable()).thenReturn(true);
    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);
    JAutoToggleButton button = (JAutoToggleButton) new EntryAccessor().getComponent(actionEntry);
    assertThat(button.getAction(), CoreMatchers.<Action>equalTo(action));
    assertThat(button.getParent(), CoreMatchers.equalTo((Container) toolbar));
}
Also used : JAutoToggleButton(org.freeplane.core.ui.components.JAutoToggleButton) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Container(java.awt.Container) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar) JToolbarComponentBuilder(org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder) Test(org.junit.Test)

Example 63 with Entry

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

the class JToolbarComponentBuilderTest method createsVerticalToolbarSeparator.

@Test
public void createsVerticalToolbarSeparator() {
    Entry separatorEntry = new Entry();
    separatorEntry.setBuilders(asList("separator"));
    Entry toolbarEntry = new Entry();
    final FreeplaneToolBar toolbar = new FreeplaneToolBar("toolbar", SwingConstants.HORIZONTAL);
    new EntryAccessor().setComponent(toolbarEntry, toolbar);
    toolbarEntry.addChild(separatorEntry);
    final JToolbarComponentBuilder toolbarActionGroupBuilder = new JToolbarComponentBuilder();
    toolbarActionGroupBuilder.visit(separatorEntry);
    JToolBar.Separator separator = (JToolBar.Separator) new EntryAccessor().getComponent(separatorEntry);
    assertThat(separator.getParent(), CoreMatchers.equalTo((Container) toolbar));
    assertThat(separator.getOrientation(), CoreMatchers.equalTo(SwingConstants.VERTICAL));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Container(java.awt.Container) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar) JToolbarComponentBuilder(org.freeplane.core.ui.menubuilders.menu.JToolbarComponentBuilder) JToolBar(javax.swing.JToolBar) Test(org.junit.Test)

Example 64 with Entry

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

the class MenuBuildProcessFactoryTest method ifProcessOnPopupIsSet_delayesActionProcessing.

@Test
public void ifProcessOnPopupIsSet_delayesActionProcessing() 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);
    verify(freeplaneActions, never()).getAction("action");
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) 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