use of org.freeplane.core.ui.ActionEnabler 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);
}
}
}
use of org.freeplane.core.ui.ActionEnabler in project freeplane by freeplane.
the class JMenuItemBuilder method createActionComponent.
private Component createActionComponent(Entry entry) {
// FIXME actually not possible
final Object alreadyExistingComponent = entryAccessor.getComponent(entry);
if (alreadyExistingComponent != null) {
LogUtils.severe("BUG : component already exists at " + entry.getPath());
return null;
}
final Component component = menuActionComponentProvider.createComponent(entry);
final AFreeplaneAction action = entryAccessor.getAction(entry);
if (action != null) {
final ActionEnabler actionEnabler = new ActionEnabler(component);
action.addPropertyChangeListener(actionEnabler);
entry.setAttribute(actionEnabler.getClass(), actionEnabler);
}
return component;
}
use of org.freeplane.core.ui.ActionEnabler in project freeplane by freeplane.
the class JToolbarComponentBuilder method visit.
@Override
public void visit(Entry entry) {
Component component = componentProvider.createComponent(entry);
if (component != null) {
final EntryAccessor entryAccessor = new EntryAccessor();
entryAccessor.setComponent(entry, component);
final AFreeplaneAction action = entryAccessor.getAction(entry);
if (action != null) {
final ActionEnabler actionEnabler = new ActionEnabler(component);
action.addPropertyChangeListener(actionEnabler);
entry.setAttribute(actionEnabler.getClass(), actionEnabler);
}
final Container container = (Container) new EntryAccessor().getAncestorComponent(entry);
if (container instanceof JToolBar)
container.add(component);
else
SwingUtilities.getAncestorOfClass(JToolBar.class, container).add(component);
}
}
Aggregations