use of org.freeplane.core.ui.menubuilders.generic.EntryVisitor 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;
}
});
}
Aggregations