use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class ConditionalActionBuilder method visit.
@Override
public void visit(Entry target) {
final String property = (String) target.getAttribute("property");
if (ResourceController.getResourceController().getBooleanProperty(property, false)) {
try {
final String keyName = (String) target.getAttribute("actionKey");
final AFreeplaneAction existingAction = freeplaneActions.getAction(keyName);
final AFreeplaneAction action;
if (existingAction != null)
action = existingAction;
else {
final String className = (String) target.getAttribute("actionClass");
final Class<?> classDefinition = getClass().getClassLoader().loadClass(className);
action = (AFreeplaneAction) classDefinition.newInstance();
freeplaneActions.addAction(action);
}
new EntryAccessor().setAction(target, action);
return;
} catch (Exception e) {
LogUtils.severe(e);
}
}
}
use of org.freeplane.core.ui.AFreeplaneAction 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.AFreeplaneAction 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);
}
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class EntryAccessor method getText.
public String getText(final Entry entry) {
if (entry.getAttribute(TEXT) != null)
return (String) entry.getAttribute(TEXT);
else {
final String textKey = (String) entry.getAttribute(TEXT_KEY);
if (textKey != null)
return (String) resourceAccessor.getRawText(textKey);
else {
final AFreeplaneAction action = getAction(entry);
if (action != null)
return action.getRawText();
String name = entry.getName();
if (name.isEmpty())
return "";
else {
final String rawText = resourceAccessor.getRawText(name);
if (rawText != null)
return rawText;
else
return "";
}
}
}
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class EntryAccessor method getTextKey.
public String getTextKey(final Entry entry) {
if (entry.getAttribute(TEXT) != null)
return null;
final String textKey = (String) entry.getAttribute(TEXT_KEY);
if (textKey != null)
return textKey;
final AFreeplaneAction action = getAction(entry);
if (action != null) {
final String actionTextKey = action.getTextKey();
if (TextUtils.getRawText(actionTextKey, null) != null)
return actionTextKey;
else
return null;
}
String name = entry.getName();
if (name.isEmpty())
return null;
else
return name;
}
Aggregations