Search in sources :

Example 51 with Entry

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

the class UserInputListenerFactory method filterPlugins.

private void filterPlugins(Entry entry, Set<String> plugins) {
    final Iterator<Entry> iterator = entry.children().iterator();
    while (iterator.hasNext()) {
        final Entry child = iterator.next();
        final Object plugin = child.getAttribute("plugin");
        if (plugin != null && !plugins.contains(plugin))
            iterator.remove();
        else
            filterPlugins(child, plugins);
    }
}
Also used : Entry(org.freeplane.core.ui.menubuilders.generic.Entry)

Example 52 with Entry

use of org.freeplane.core.ui.menubuilders.generic.Entry 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 53 with Entry

use of org.freeplane.core.ui.menubuilders.generic.Entry 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 54 with Entry

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

Example 55 with Entry

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

the class JComponentRemoverTest method ignoresEntriesWithoutComponents.

@Test
public void ignoresEntriesWithoutComponents() throws Exception {
    final JComponentRemover componentRemover = new JComponentRemover();
    final Entry entry = new Entry();
    componentRemover.visit(entry);
}
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