Search in sources :

Example 6 with IUserInputListenerFactory

use of org.freeplane.core.ui.IUserInputListenerFactory 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 7 with IUserInputListenerFactory

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

Example 8 with IUserInputListenerFactory

use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.

the class ModeController method updateMenus.

public void updateMenus(String menuStructure, final Set<String> plugins) {
    final IUserInputListenerFactory userInputListenerFactory = getUserInputListenerFactory();
    userInputListenerFactory.getAcceleratorManager().loadDefaultAcceleratorPresets();
    userInputListenerFactory.updateMenus(menuStructure, plugins);
    final MenuBuilder menuBuilder = userInputListenerFactory.getMenuBuilder(MenuBuilder.class);
    final Iterator<IMenuContributor> iterator = menuContributors.iterator();
    while (iterator.hasNext()) {
        iterator.next().updateMenus(this, menuBuilder);
    }
}
Also used : IMenuContributor(org.freeplane.core.ui.IMenuContributor) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) MenuBuilder(org.freeplane.core.ui.MenuBuilder)

Example 9 with IUserInputListenerFactory

use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.

the class MLogicalStyleController method initM.

public void initM() {
    final ModeController modeController = Controller.getCurrentModeController();
    modeController.getMapController().addNodeChangeListener(new StyleRemover());
    modeController.registerExtensionCopier(new ExtensionCopier());
    modeController.addAction(new RedefineStyleAction());
    modeController.addAction(new NewUserStyleAction());
    modeController.addAction(new ManageMapConditionalStylesAction());
    modeController.addAction(new ManageNodeConditionalStylesAction());
    modeController.addAction(new CopyStyleExtensionsAction());
    if (modeController.getModeName().equals("MindMap")) {
        modeController.addAction(new MapBackgroundColorAction());
        modeController.addAction(new MapBackgroundImageAction());
        modeController.addAction(new MapBackgroundClearAction());
        modeController.addAction(new SetBooleanMapPropertyAction(MapStyle.FIT_TO_VIEWPORT));
        modeController.addAction(new CopyMapStylesAction());
    }
    if (!modeController.getController().getViewController().isHeadless()) {
        final IUserInputListenerFactory userInputListenerFactory = modeController.getUserInputListenerFactory();
        final MenuBuilder menuBuilder = userInputListenerFactory.getMenuBuilder(MenuBuilder.class);
        // TODO RIBBONS - apply to ribbons as well
        Controller.getCurrentController().getMapViewManager().addMapSelectionListener(new IMapSelectionListener() {

            public void beforeMapChange(final MapModel oldMap, final MapModel newMap) {
                removeStyleMenu(menuBuilder, "main_menu_styles");
                removeStyleMenu(menuBuilder, "node_popup_styles");
            }

            public void afterMapChange(final MapModel oldMap, final MapModel newMap) {
                addStyleMenu(menuBuilder, "main_menu_styles", newMap);
                addStyleMenu(menuBuilder, "node_popup_styles", newMap);
            }
        });
        final MapController mapController = modeController.getMapController();
        mapController.addMapChangeListener(new IMapChangeListener() {

            public void onPreNodeMoved(final NodeModel oldParent, final int oldIndex, final NodeModel newParent, final NodeModel child, final int newIndex) {
            }

            public void onPreNodeDelete(final NodeModel oldParent, final NodeModel selectedNode, final int index) {
            }

            public void onNodeMoved(final NodeModel oldParent, final int oldIndex, final NodeModel newParent, final NodeModel child, final int newIndex) {
            }

            public void onNodeInserted(final NodeModel parent, final NodeModel child, final int newIndex) {
            }

            public void onNodeDeleted(final NodeModel parent, final NodeModel child, final int index) {
            }

            public void mapChanged(final MapChangeEvent event) {
                if (event.getProperty().equals(MapStyle.MAP_STYLES)) {
                    removeStyleMenu(menuBuilder, "main_menu_styles");
                    addStyleMenu(menuBuilder, "main_menu_styles", event.getMap());
                    removeStyleMenu(menuBuilder, "node_popup_styles");
                    addStyleMenu(menuBuilder, "node_popup_styles", event.getMap());
                }
            }
        });
        mapController.addNodeSelectionListener(new INodeSelectionListener() {

            public void onSelect(final NodeModel node) {
                selectActions();
            }

            public void onDeselect(final NodeModel node) {
            }
        });
    }
}
Also used : IMapSelectionListener(org.freeplane.features.map.IMapSelectionListener) IMapChangeListener(org.freeplane.features.map.IMapChangeListener) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) MapBackgroundImageAction(org.freeplane.view.swing.features.filepreview.MapBackgroundImageAction) IExtensionCopier(org.freeplane.features.map.IExtensionCopier) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) MenuBuilder(org.freeplane.core.ui.MenuBuilder) MapController(org.freeplane.features.map.MapController) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) NodeModel(org.freeplane.features.map.NodeModel) MapBackgroundClearAction(org.freeplane.view.swing.features.filepreview.MapBackgroundClearAction) MapChangeEvent(org.freeplane.features.map.MapChangeEvent)

Example 10 with IUserInputListenerFactory

use of org.freeplane.core.ui.IUserInputListenerFactory in project freeplane by freeplane.

the class FrameController method selectMode.

public void selectMode(final ModeController oldModeController, final ModeController newModeController) {
    if (oldModeController == newModeController) {
        return;
    }
    if (oldModeController != null) {
        final IUserInputListenerFactory userInputListenerFactory = oldModeController.getUserInputListenerFactory();
        for (int j = 0; j < 4; j++) {
            final Iterable<JComponent> modeToolBars = userInputListenerFactory.getToolBars(j);
            if (modeToolBars != null) {
                for (final Component toolBar : modeToolBars) {
                    toolbarPanel[j].remove(toolBar);
                }
                toolbarPanel[j].revalidate();
            }
        }
    }
    final IUserInputListenerFactory newUserInputListenerFactory = newModeController.getUserInputListenerFactory();
    for (int j = 0; j < 4; j++) {
        final Iterable<JComponent> newToolBars = newUserInputListenerFactory.getToolBars(j);
        if (newToolBars != null) {
            int i = 0;
            for (final JComponent toolBar : newToolBars) {
                UIComponentVisibilityDispatcher dispatcher = UIComponentVisibilityDispatcher.dispatcher(toolBar);
                if (dispatcher != null) {
                    dispatcher.resetVisible();
                    toolbarPanel[j].add(toolBar, i++);
                }
            }
            toolbarPanel[j].revalidate();
            toolbarPanel[j].repaint();
        }
    }
    if (newUserInputListenerFactory.useRibbonMenu()) {
        newUserInputListenerFactory.getMenuBuilder(RibbonBuilder.class).buildRibbon();
    } else {
        setFreeplaneMenuBar(newUserInputListenerFactory.getMenuBar());
        setUIComponentsVisible(newModeController.getController().getMapViewManager(), isMenubarVisible());
    }
}
Also used : IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) JComponent(javax.swing.JComponent) Component(java.awt.Component) JComponent(javax.swing.JComponent) RibbonBuilder(org.freeplane.core.ui.ribbon.RibbonBuilder)

Aggregations

IUserInputListenerFactory (org.freeplane.core.ui.IUserInputListenerFactory)10 JToolBar (javax.swing.JToolBar)3 MenuBuilder (org.freeplane.core.ui.MenuBuilder)2 FreeplaneMenuBar (org.freeplane.core.ui.components.FreeplaneMenuBar)2 EntriesForAction (org.freeplane.core.ui.menubuilders.action.EntriesForAction)2 Entry (org.freeplane.core.ui.menubuilders.generic.Entry)2 EntryAccessor (org.freeplane.core.ui.menubuilders.generic.EntryAccessor)2 FreeplaneActions (org.freeplane.features.mode.FreeplaneActions)2 Before (org.junit.Before)2 Test (org.junit.Test)2 Component (java.awt.Component)1 Container (java.awt.Container)1 BufferedReader (java.io.BufferedReader)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 JComponent (javax.swing.JComponent)1 JPopupMenu (javax.swing.JPopupMenu)1 IMenuContributor (org.freeplane.core.ui.IMenuContributor)1 IAcceleratorMap (org.freeplane.core.ui.menubuilders.action.IAcceleratorMap)1 BuildPhaseListener (org.freeplane.core.ui.menubuilders.generic.BuildPhaseListener)1