use of org.freeplane.core.util.MenuUtils.MenuEntry in project freeplane by freeplane.
the class HotKeyInfoAction method appendChildrenAsHtml.
@SuppressWarnings("unchecked")
private void appendChildrenAsHtml(final StringBuilder builder, final Enumeration<DefaultMutableTreeNode> children, final String title, final int level) {
final ArrayList<MenuEntry> menuEntries = new ArrayList<MenuEntry>();
final ArrayList<DefaultMutableTreeNode> submenus = new ArrayList<DefaultMutableTreeNode>();
// sort and divide
while (children.hasMoreElements()) {
final DefaultMutableTreeNode node = children.nextElement();
if (node.isLeaf()) {
menuEntries.add((MenuEntry) node.getUserObject());
} else {
submenus.add(node);
}
}
// actions
if (!menuEntries.isEmpty()) {
builder.append("<table cellspacing=\"0\" cellpadding=\"0\">");
for (final MenuEntry entry : menuEntries) {
final String keystroke = //
entry.getKeyStroke() == null ? //
"" : MenuUtils.formatKeyStroke(entry.getKeyStroke());
builder.append(el("tr", el("td", entry.getLabel() + " ") + el("td", keystroke) + el("td", entry.getToolTipText())));
}
builder.append("</table>");
}
// submenus
for (final DefaultMutableTreeNode node : submenus) {
final String subtitle = (level > 2 ? title + "→" : "") + String.valueOf(node.getUserObject());
appendAsHtml(builder, node.children(), subtitle, level + 1);
}
}
use of org.freeplane.core.util.MenuUtils.MenuEntry in project freeplane by freeplane.
the class HotKeyInfoAction method appendChildrenAsHtml.
@SuppressWarnings("unchecked")
private void appendChildrenAsHtml(final StringBuilder builder, final Enumeration<TreeNode> children, final String title, final int level) {
final ArrayList<MenuEntry> menuEntries = new ArrayList<MenuEntry>();
final ArrayList<DefaultMutableTreeNode> submenus = new ArrayList<DefaultMutableTreeNode>();
// sort and divide
while (children.hasMoreElements()) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement();
if (node.isLeaf()) {
menuEntries.add((MenuEntry) node.getUserObject());
} else {
submenus.add(node);
}
}
// actions
if (!menuEntries.isEmpty()) {
builder.append("<table cellspacing=\"0\" cellpadding=\"0\">");
for (final MenuEntry entry : menuEntries) {
final String keystroke = //
entry.getKeyStroke() == null ? //
"" : MenuUtils.formatKeyStroke(entry.getKeyStroke());
builder.append(el("tr", el("td", entry.getLabel() + " ") + el("td", keystroke) + el("td", entry.getToolTipText())));
}
builder.append("</table>");
}
// submenus
for (final DefaultMutableTreeNode node : submenus) {
final String subtitle = (level > 2 ? title + "→" : "") + String.valueOf(node.getUserObject());
appendAsHtml(builder, node.children(), subtitle, level + 1);
}
}
use of org.freeplane.core.util.MenuUtils.MenuEntry in project freeplane by freeplane.
the class SelectMenuItemDialog method createTree.
private JTree createTree() {
final MModeController modeController = (MModeController) Controller.getCurrentModeController();
final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder(MenuBuilder.class);
final DefaultMutableTreeNode treeRoot = MenuUtils.createMenuEntryTree(SELECTION_ROOT_KEY, menuBuilder);
if (treeRoot.getUserObject() == null)
treeRoot.setUserObject(new MenuEntry(null, TextUtils.getText("select_menu_item_root_node")));
JTree jTree = new JTree(treeRoot);
jTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
// replace the standard icons
jTree.setCellRenderer(new MenuIconRenderer());
jTree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(final TreeSelectionEvent e) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
btnOK.setEnabled(node != null && node.isLeaf());
}
});
jTree.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() >= 2) {
if (btnOK.isEnabled())
btnOK.doClick();
}
}
});
return jTree;
}
use of org.freeplane.core.util.MenuUtils.MenuEntry in project freeplane by freeplane.
the class AddMenuItemLinkAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final NodeModel selectedNode = Controller.getCurrentModeController().getMapController().getSelectedNode();
final SelectMenuItemDialog dialog = new SelectMenuItemDialog(selectedNode);
final MenuEntry menuItem = dialog.getMenuItem();
if (menuItem != null) {
((MLinkController) LinkController.getController()).setLink(selectedNode, LinkController.createMenuItemLink(menuItem.getKey()), LinkController.LINK_ABSOLUTE);
}
}
Aggregations