Search in sources :

Example 41 with EntryAccessor

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

the class ActionFinderTest method attachesSetBooleanPropertyAction.

@Test
public void attachesSetBooleanPropertyAction() {
    FreeplaneActions freeplaneActions = mock(FreeplaneActions.class);
    final SetBooleanPropertyAction setBooleanPropertyAction = Mockito.mock(SetBooleanPropertyAction.class);
    Entry entry = new Entry();
    final String propertyActionName = "SetBooleanPropertyAction.property";
    entry.setName(propertyActionName);
    when(freeplaneActions.getAction(propertyActionName)).thenReturn(null);
    final ActionFinder actionFinder = new ActionFinder(freeplaneActions) {

        @Override
        protected AFreeplaneAction createAction(Class<? extends AFreeplaneAction> actionClass, String propertyName) {
            return setBooleanPropertyAction;
        }
    };
    actionFinder.visit(entry);
    Mockito.verify(freeplaneActions).addAction(setBooleanPropertyAction);
    assertThat(new EntryAccessor().getAction(entry), CoreMatchers.<Object>equalTo(setBooleanPropertyAction));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) SetBooleanPropertyAction(org.freeplane.core.resources.SetBooleanPropertyAction) FreeplaneActions(org.freeplane.features.mode.FreeplaneActions) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Test(org.junit.Test)

Example 42 with EntryAccessor

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

the class ActionSelectListenerTest method dontActivateSelectOnPopup_forNotCheckSelectionOnPopup.

@Test
public void dontActivateSelectOnPopup_forNotCheckSelectionOnPopup() {
    Entry menuEntry = new Entry();
    Entry actionEntry = new Entry();
    menuEntry.addChild(actionEntry);
    final AFreeplaneAction someAction = Mockito.mock(AFreeplaneAction.class);
    when(someAction.checkSelectionOnPopup()).thenReturn(false);
    when(someAction.isEnabled()).thenReturn(true);
    new EntryAccessor().setAction(actionEntry, someAction);
    final EntryPopupListenerCollection entryPopupListenerCollection = new EntryPopupListenerCollection();
    final ActionSelectListener actionSelectListener = new ActionSelectListener();
    entryPopupListenerCollection.addEntryPopupListener(actionSelectListener);
    entryPopupListenerCollection.childEntriesWillBecomeVisible(menuEntry);
    verify(someAction, never()).setSelected();
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryPopupListenerCollection(org.freeplane.core.ui.menubuilders.generic.EntryPopupListenerCollection) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Test(org.junit.Test)

Example 43 with EntryAccessor

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

the class UserInputListenerFactory method createModeActions.

private void createModeActions(final Entry modesMenuEntry) {
    rebuildMenuOnMapChange(modesMenuEntry);
    Controller controller = Controller.getCurrentController();
    EntryAccessor entryAccessor = new EntryAccessor();
    for (final String key : new LinkedList<String>(controller.getModes())) {
        final AFreeplaneAction modesMenuAction = new ModesMenuAction(key, controller);
        modeController.addActionIfNotAlreadySet(modesMenuAction);
        Entry actionEntry = new Entry();
        entryAccessor.setAction(actionEntry, modesMenuAction);
        actionEntry.setName(modesMenuAction.getKey());
        final ModeController modeController = controller.getModeController();
        if (modeController != null && modeController.getModeName().equals(key)) {
            actionEntry.setAttribute("selected", true);
        }
        modesMenuEntry.addChild(actionEntry);
        ResourceController.getResourceController().getProperty(("keystroke_mode_" + key));
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) ModeController(org.freeplane.features.mode.ModeController) Controller(org.freeplane.features.mode.Controller) ResourceController(org.freeplane.core.resources.ResourceController) ViewController(org.freeplane.features.ui.ViewController) ModeController(org.freeplane.features.mode.ModeController) LinkedList(java.util.LinkedList)

Example 44 with EntryAccessor

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

the class JComponentRemoverTest method removesComponentsFromParents.

@Test
public void removesComponentsFromParents() throws Exception {
    final JComponentRemover componentRemover = new JComponentRemover();
    final Entry entry = new Entry();
    JComponent parent = new JPanel();
    JComponent entryComponent = new JPanel();
    parent.add(entryComponent);
    new EntryAccessor().setComponent(entry, entryComponent);
    componentRemover.visit(entry);
    Assert.assertThat(entryComponent.getParent(), nullValue(Container.class));
}
Also used : JPanel(javax.swing.JPanel) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) Container(java.awt.Container) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JComponent(javax.swing.JComponent) Test(org.junit.Test)

Example 45 with EntryAccessor

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

the class JComponentRemoverTest method removesExtraSubmenusFromParents.

@Test
public void removesExtraSubmenusFromParents() throws Exception {
    final JComponentRemover componentRemover = new JComponentRemover();
    final Entry entry = new Entry();
    JMenu parent = new JMenu();
    JComponent entryComponent = new JMenu();
    final MenuSplitter menuSplitter = new MenuSplitter(1);
    menuSplitter.addMenuComponent(parent, new JMenu());
    menuSplitter.addMenuComponent(parent, entryComponent);
    new EntryAccessor().setComponent(entry, entryComponent);
    componentRemover.visit(entry);
    Assert.assertThat(parent.getPopupMenu().getComponentCount(), equalTo(1));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) MenuSplitter(org.freeplane.core.ui.MenuSplitter) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JComponent(javax.swing.JComponent) JMenu(javax.swing.JMenu) 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