use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class WorkspacePopupMenuBuilder method addActions.
public static void addActions(final WorkspacePopupMenu popupMenu, final String[] keys) {
assert popupMenu != null;
assert keys != null;
Stack<JMenu> subMenuStack = new Stack<JMenu>();
for (String key : keys) {
if (key == null) {
continue;
} else if (key.equals(SEPARATOR)) {
if (subMenuStack.size() == 0) {
popupMenu.addSeparator();
} else {
subMenuStack.peek().addSeparator();
}
} else if (key.startsWith("beginSubMenu")) {
String popupName = key.substring("beginSubMenu".length());
JMenu subMenu = new JMenu(popupName);
(subMenuStack.size() == 0 ? popupMenu : subMenuStack.peek()).add(subMenu);
subMenuStack.push(subMenu);
} else if (key.equals("endSubMenu")) {
subMenuStack.pop();
} else {
AFreeplaneAction action = Controller.getCurrentController().getAction(key);
if (action == null) {
continue;
}
addAction(popupMenu, subMenuStack.size() == 0 ? popupMenu : subMenuStack.peek(), action);
}
}
}
Aggregations