List of usage examples for javax.swing.tree DefaultMutableTreeNode getAllowsChildren
public boolean getAllowsChildren()
From source file:net.landora.animeinfo.notifications.NotificationViewer.java
private void addChildren(DefaultMutableTreeNode node, List<Object> items) { if (node.getAllowsChildren()) { for (int i = 0; i < node.getChildCount(); i++) { DefaultMutableTreeNode n = (DefaultMutableTreeNode) node.getChildAt(i); addChildren(n, items);//from ww w . j a v a 2s . co m } } else { items.add(node.getUserObject()); } }
From source file:fxts.stations.ui.help.ContentTree.java
/** * Returns node containing the specified url. * * @param aParent parent node//from w w w . ja v a2 s .c o m * @param aUrl specified url * * @return node containing specified url */ public DefaultMutableTreeNode findNodeByUrl(DefaultMutableTreeNode aParent, String aUrl) { DefaultMutableTreeNode node; DefaultMutableTreeNode result; NodeInfo info; if (!aParent.getAllowsChildren()) { return null; } for (Enumeration enumeration = aParent.children(); enumeration.hasMoreElements();) { node = (DefaultMutableTreeNode) enumeration.nextElement(); info = (NodeInfo) node.getUserObject(); if (aUrl.equals(info.getUrl())) { return node; } else { result = findNodeByUrl(node, aUrl); if (result != null) { return result; } } } return null; }
From source file:fxts.stations.ui.help.ContentTree.java
/** * Returns path to node containing the specified url. * * @param aParentPath parent node/* ww w . j a v a2s .com*/ * @param aUrl specified url * * @return path to node containing specified url */ public TreePath findPathByUrl(TreePath aParentPath, String aUrl) { DefaultMutableTreeNode parentNode; DefaultMutableTreeNode node; TreePath resultPath; NodeInfo info; parentNode = (DefaultMutableTreeNode) aParentPath.getLastPathComponent(); if (!parentNode.getAllowsChildren()) { return null; } for (Enumeration enumeration = parentNode.children(); enumeration.hasMoreElements();) { node = (DefaultMutableTreeNode) enumeration.nextElement(); info = (NodeInfo) node.getUserObject(); if (aUrl.equals(info.getUrl())) { return aParentPath.pathByAddingChild(node); } else { resultPath = findPathByUrl(aParentPath.pathByAddingChild(node), aUrl); if (resultPath != null) { return resultPath; } } } return null; }