use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor 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.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class MTextController method createActions.
private void createActions() {
final ModeController modeController = Controller.getCurrentModeController();
modeController.addAction(new EditAction());
modeController.addAction(new UsePlainTextAction());
modeController.addAction(new EditLongAction());
modeController.addAction(new SetImageByFileChooserAction());
modeController.addAction(new EditDetailsAction(false));
modeController.addAction(new EditDetailsAction(true));
modeController.addAction(new DeleteDetailsAction());
modeController.addUiBuilder(Phase.ACTIONS, "splitToWordsActions", new EntryVisitor() {
@Override
public void visit(Entry target) {
final String[] nodeNumbersInLine = ResourceController.getResourceController().getProperty("SplitToWordsAction.nodeNumbersInLine").split("[^\\d]+");
for (String nodeNumberInLineAsString : nodeNumbersInLine) {
try {
final int nodeNumberInLine = Integer.parseInt(nodeNumberInLineAsString);
if (nodeNumberInLine > 0) {
final SplitToWordsAction action = new SplitToWordsAction(nodeNumberInLine);
new EntryAccessor().addChildAction(target, action);
modeController.addAction(action);
}
} catch (NumberFormatException e) {
}
}
}
@Override
public boolean shouldSkipChildren(Entry entry) {
return true;
}
});
modeController.addUiBuilder(Phase.ACTIONS, "joinNodesActions", new EntryVisitor() {
@Override
public void visit(Entry target) {
final String textSeparators = ResourceController.getResourceController().getProperty("JoinNodesAction.textSeparators");
final Pattern JOIN_NODES_ACTION_SEPARATORS = Pattern.compile("\\{\\{.*?\\}\\}");
final Matcher matcher = JOIN_NODES_ACTION_SEPARATORS.matcher(textSeparators);
if (matcher.find()) {
do {
String textSeparator = textSeparators.substring(matcher.start() + 2, matcher.end() - 2);
addAction(modeController, target, textSeparator);
} while (matcher.find());
} else {
addAction(modeController, target, textSeparators);
}
}
private void addAction(final ModeController modeController, Entry target, String textSeparator) {
final JoinNodesAction action = new JoinNodesAction(textSeparator);
new EntryAccessor().addChildAction(target, action);
modeController.addAction(action);
if (target.getChildCount() == 1)
target.getChild(0).setAttribute(EntryAccessor.ACCELERATOR, target.getAttribute(EntryAccessor.ACCELERATOR));
}
@Override
public boolean shouldSkipChildren(Entry entry) {
return true;
}
});
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class AcceleratorBuilder method visit.
public void visit(Entry entry) {
final AFreeplaneAction action = new EntryAccessor().getAction(entry);
if (action != null) {
final EntryAccessor entryAccessor = new EntryAccessor();
String accelerator = entryAccessor.getAccelerator(entry);
if (accelerator != null) {
map.setDefaultAccelerator(action, accelerator);
} else
map.setUserDefinedAccelerator(action);
entries.registerEntry(action, entry);
}
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class ActionFinder method visit.
@Override
public void visit(final Entry target) {
final String actionName = target.getName();
if (!actionName.isEmpty() && new EntryAccessor().getAction(target) == null) {
AFreeplaneAction action = freeplaneActions.getAction(actionName);
if (action == null) {
for (final Class<? extends AFreeplaneAction> actionClass : Arrays.asList(SetBooleanPropertyAction.class, SetBooleanMapPropertyAction.class, SetBooleanMapViewPropertyAction.class, SetStringPropertyAction.class)) {
final String setBooleanPropertyActionPrefix = actionClass.getSimpleName() + ".";
if (actionName.startsWith(setBooleanPropertyActionPrefix)) {
String propertyName = actionName.substring(setBooleanPropertyActionPrefix.length());
action = createAction(actionClass, propertyName);
if (action != null) {
freeplaneActions.addAction(action);
}
break;
}
}
}
new EntryAccessor().setAction(target, action);
}
}
use of org.freeplane.core.ui.menubuilders.generic.EntryAccessor in project freeplane by freeplane.
the class UpdateCheckAction method addUpdateButton.
private void addUpdateButton(final FreeplaneVersion lastVersion) {
if (entry != null) {
Controller controller = Controller.getCurrentController();
final Component component = (Component) new EntryAccessor().getComponent(entry);
if (component != null) {
final Dimension preferredSize = component.getPreferredSize();
if (lastVersion == null || lastVersion.compareTo(FreeplaneVersion.getVersion()) <= 0) {
ResourceController.getResourceController().setProperty(LAST_UPDATE_VERSION, "");
component.setPreferredSize(new Dimension(0, preferredSize.height));
component.setVisible(false);
} else {
ResourceController.getResourceController().setProperty(LAST_UPDATE_VERSION, lastVersion.toString());
final String updateAvailable = TextUtils.format("new_version_available", lastVersion.toString());
controller.getViewController().out(updateAvailable);
putValue(SHORT_DESCRIPTION, updateAvailable);
putValue(LONG_DESCRIPTION, updateAvailable);
component.setPreferredSize(new Dimension(preferredSize.height, preferredSize.height));
component.setVisible(true);
}
}
}
}
Aggregations