Search in sources :

Example 11 with EntryAccessor

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

the class ToolbarComponentProviderTest method testName.

@Test
public void testName() throws Exception {
    final ToolbarComponentProvider toolbarComponentProvider = new ToolbarComponentProvider();
    final Entry entry = new Entry();
    final EntryAccessor entryAccessor = new EntryAccessor();
    final Object testComponent = new JPanel();
    entryAccessor.setComponent(entry, testComponent);
    Assert.assertThat(toolbarComponentProvider.createComponent(entry), equalTo(testComponent));
}
Also used : JPanel(javax.swing.JPanel) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Test(org.junit.Test)

Example 12 with EntryAccessor

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

the class ToolbarComponentProvider method createComponent.

/* (non-Javadoc)
	 * @see org.freeplane.core.ui.menubuilders.menu.ComponentProvider#createComponent(org.freeplane.core.ui.menubuilders.generic.Entry)
	 */
@Override
public Component createComponent(Entry entry) {
    final EntryAccessor entryAccessor = new EntryAccessor();
    final Object existingComponent = entryAccessor.getComponent(entry);
    if (existingComponent != null)
        return (Component) existingComponent;
    final AFreeplaneAction action = entryAccessor.getAction(entry);
    Component component;
    if (action != null) {
        if (action.isSelectable()) {
            component = new JAutoToggleButton(action);
        } else {
            component = new JButton(action);
        }
    } else if (entry.builders().contains("separator")) {
        component = new Separator();
    } else
        component = null;
    return component;
}
Also used : JAutoToggleButton(org.freeplane.core.ui.components.JAutoToggleButton) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) JButton(javax.swing.JButton) Component(java.awt.Component) Separator(javax.swing.JToolBar.Separator)

Example 13 with EntryAccessor

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

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

the class PopupBuilder method visit.

@Override
public void visit(Entry target) {
    nodePopupMenu.addPopupMenuListener(new PopupMenuListenerForEntry(target, popupListener));
    new EntryAccessor().setComponent(target, nodePopupMenu);
}
Also used : EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor)

Example 15 with EntryAccessor

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

the class JComponentRemover method visit.

@Override
public void visit(Entry target) {
    final EntryAccessor entryAccessor = new EntryAccessor();
    final Component component = (Component) entryAccessor.removeComponent(target);
    if (component != null) {
        if (component instanceof AbstractButton)
            ((AbstractButton) component).setAction(null);
        removeMenuComponent(component);
        ActionEnabler actionEnabler = target.removeAttribute(ActionEnabler.class);
        if (actionEnabler != null) {
            final AFreeplaneAction action = entryAccessor.getAction(target);
            action.removePropertyChangeListener(actionEnabler);
        }
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) AbstractButton(javax.swing.AbstractButton) ActionEnabler(org.freeplane.core.ui.ActionEnabler) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) Component(java.awt.Component)

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