Search in sources :

Example 1 with FreeplaneMenuBar

use of org.freeplane.core.ui.components.FreeplaneMenuBar in project freeplane by freeplane.

the class UserInputListenerFactory method updateMenus.

public void updateMenus(String menuStructureResource, Set<String> plugins) {
    mapsPopupMenu = new JPopupMenu();
    getMenuBuilder(MenuBuilder.class).addPopupMenu(mapsPopupMenu, FreeplaneMenuBar.MAP_POPUP_MENU);
    getMenuBuilder(MenuBuilder.class).addPopupMenu(getNodePopupMenu(), UserInputListenerFactory.NODE_POPUP);
    final URL popupStructure = ResourceController.getResourceController().getResource(menuStructureResource.replace("menu.xml", "popup.xml"));
    loadStructure(plugins, popupStructure);
    if (useRibbonMenu()) {
        final URL ribbonStructure = ResourceController.getResourceController().getResource(menuStructureResource.replace("menu.xml", "ribbon.xml"));
        if (ribbonStructure != null) {
            getMenuBuilder(RibbonBuilder.class).updateRibbon(ribbonStructure);
        }
    } else {
        final FreeplaneMenuBar menuBar = getMenuBar();
        getMenuBuilder(MenuBuilder.class).addMenuBar(menuBar, FreeplaneMenuBar.MENU_BAR_PREFIX);
        getMenuBuilder(MenuBuilder.class).addToolbar((JToolBar) getToolBar("/main_toolbar"), "/main_toolbar");
        final URL menuStructure = ResourceController.getResourceController().getResource(menuStructureResource);
        loadStructure(plugins, menuStructure);
        final URL toolbarStructure = ResourceController.getResourceController().getResource(menuStructureResource.replace("menu.xml", "toolbar.xml"));
        loadStructure(plugins, toolbarStructure);
        final IMapViewManager viewController = Controller.getCurrentController().getMapViewManager();
        viewController.updateMenus(getMenuBuilder(MenuBuilder.class));
    }
    mapsPopupMenu.setName(TextUtils.getText("mindmaps"));
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) FreeplaneMenuBar(org.freeplane.core.ui.components.FreeplaneMenuBar) MenuBuilder(org.freeplane.core.ui.MenuBuilder) RibbonBuilder(org.freeplane.core.ui.ribbon.RibbonBuilder) JPopupMenu(javax.swing.JPopupMenu) URL(java.net.URL)

Example 2 with FreeplaneMenuBar

use of org.freeplane.core.ui.components.FreeplaneMenuBar in project freeplane by freeplane.

the class JMenuItemBuilderTest method createsMainMenuWithoutAction.

@Test
public void createsMainMenuWithoutAction() {
    Entry parentMenuEntry = new Entry();
    final FreeplaneMenuBar parentMenu = TestMenuBarFactory.createFreeplaneMenuBar();
    new EntryAccessor().setComponent(parentMenuEntry, parentMenu);
    parentMenuEntry.addChild(menuEntry);
    menuEntry.addChild(actionEntry);
    menuActionGroupBuilder.visit(menuEntry);
    JMenu item = (JMenu) new EntryAccessor().getComponent(menuEntry);
    assertThat(item.getParent(), CoreMatchers.<Container>equalTo(parentMenu));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) FreeplaneMenuBar(org.freeplane.core.ui.components.FreeplaneMenuBar) JMenu(javax.swing.JMenu) Test(org.junit.Test)

Example 3 with FreeplaneMenuBar

use of org.freeplane.core.ui.components.FreeplaneMenuBar in project freeplane by freeplane.

the class JMenubarBuilder method visit.

@Override
public void visit(Entry target) {
    final FreeplaneMenuBar menuBar = userInputListenerFactory.getMenuBar();
    addMnemonicsBeforeShowing(menuBar);
    new EntryAccessor().setComponent(target, menuBar);
}
Also used : EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) FreeplaneMenuBar(org.freeplane.core.ui.components.FreeplaneMenuBar)

Example 4 with FreeplaneMenuBar

use of org.freeplane.core.ui.components.FreeplaneMenuBar in project freeplane by freeplane.

the class JMenubarBuilderTest method createsEmptyToolbarComponent.

@Test
public void createsEmptyToolbarComponent() {
    Entry toolbarEntry = new Entry();
    final IUserInputListenerFactory userInputListenerFactory = mock(IUserInputListenerFactory.class);
    final FreeplaneMenuBar menubar = TestMenuBarFactory.createFreeplaneMenuBar();
    when(userInputListenerFactory.getMenuBar()).thenReturn(menubar);
    final JMenubarBuilder toolbarBuilder = new JMenubarBuilder(userInputListenerFactory);
    toolbarBuilder.visit(toolbarEntry);
    assertThat(new EntryAccessor().getComponent(toolbarEntry), CoreMatchers.<Object>is(menubar));
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) FreeplaneMenuBar(org.freeplane.core.ui.components.FreeplaneMenuBar) Test(org.junit.Test)

Example 5 with FreeplaneMenuBar

use of org.freeplane.core.ui.components.FreeplaneMenuBar in project freeplane by freeplane.

the class MenuBuildProcessFactoryTest method setup.

@Before
public void setup() {
    freeplaneActions = mock(FreeplaneActions.class);
    final ResourceAccessor resourceAccessorMock = mock(ResourceAccessor.class);
    when(resourceAccessorMock.getRawText(Matchers.anyString())).thenReturn("text");
    final IUserInputListenerFactory userInputListenerFactory = mock(IUserInputListenerFactory.class);
    final FreeplaneMenuBar menubar = TestMenuBarFactory.createFreeplaneMenuBar();
    when(userInputListenerFactory.getMenuBar()).thenReturn(menubar);
    phaseProcessor = new MenuBuildProcessFactory(userInputListenerFactory, freeplaneActions, resourceAccessorMock, mock(IAcceleratorMap.class), new EntriesForAction(), Collections.<BuildPhaseListener>emptyList()).getBuildProcessor();
}
Also used : ResourceAccessor(org.freeplane.core.ui.menubuilders.generic.ResourceAccessor) IAcceleratorMap(org.freeplane.core.ui.menubuilders.action.IAcceleratorMap) FreeplaneActions(org.freeplane.features.mode.FreeplaneActions) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) EntriesForAction(org.freeplane.core.ui.menubuilders.action.EntriesForAction) FreeplaneMenuBar(org.freeplane.core.ui.components.FreeplaneMenuBar) Before(org.junit.Before)

Aggregations

FreeplaneMenuBar (org.freeplane.core.ui.components.FreeplaneMenuBar)6 EntryAccessor (org.freeplane.core.ui.menubuilders.generic.EntryAccessor)3 IUserInputListenerFactory (org.freeplane.core.ui.IUserInputListenerFactory)2 Entry (org.freeplane.core.ui.menubuilders.generic.Entry)2 Test (org.junit.Test)2 URL (java.net.URL)1 JMenu (javax.swing.JMenu)1 JPopupMenu (javax.swing.JPopupMenu)1 MenuBuilder (org.freeplane.core.ui.MenuBuilder)1 EntriesForAction (org.freeplane.core.ui.menubuilders.action.EntriesForAction)1 IAcceleratorMap (org.freeplane.core.ui.menubuilders.action.IAcceleratorMap)1 ResourceAccessor (org.freeplane.core.ui.menubuilders.generic.ResourceAccessor)1 RibbonBuilder (org.freeplane.core.ui.ribbon.RibbonBuilder)1 FreeplaneActions (org.freeplane.features.mode.FreeplaneActions)1 IMapViewManager (org.freeplane.features.ui.IMapViewManager)1 Before (org.junit.Before)1