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));
}
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;
}
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);
}
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);
}
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);
}
}
}
Aggregations