List of usage examples for javax.swing.tree DefaultMutableTreeNode children
Vector children
To view the source code for javax.swing.tree DefaultMutableTreeNode children.
Click Source Link
From source file:org.openehealth.coms.cc.web_frontend.consentcreator.controller.CreateConsentServiceServlet.java
/** * This method provides upon request the root of the organisation-tree and * the first batch of it's children./*from w w w . j a va 2s . com*/ */ @SuppressWarnings("rawtypes") private void requestTypeTreeRoot() { try { DefaultMutableTreeNode node = ccService.getOIDTreeRoot(); Vector<JSONObject> vjbo = new Vector<JSONObject>(); for (Enumeration e = node.children(); e.hasMoreElements();) { DefaultMutableTreeNode n = (DefaultMutableTreeNode) e.nextElement(); JSONObject jso = new JSONObject(); jso.put("name", ((OIDObject) n.getUserObject()).getName()); jso.put("identifier", ((OIDObject) n.getUserObject()).getIdentifier()); jso.put("hasChildren", !n.isLeaf()); jso.put("isActive", ((OIDObject) n.getUserObject()).isActive()); vjbo.add(jso); } JSONObject root = new JSONObject(); root.put("name", ((OIDObject) node.getUserObject()).getName()); root.put("identifier", ((OIDObject) node.getUserObject()).getIdentifier()); root.put("hasChildren", !node.isLeaf()); root.put("isActive", ((OIDObject) node.getUserObject()).isActive()); root.put("children", new JSONArray(vjbo)); writeJSONObject(root); } catch (Exception e) { Logger.getLogger(this.getClass()).error(e); } }
From source file:org.openehealth.coms.cc.web_frontend.consentcreator.service.ConsentCreatorService.java
/** * Returns all children of the TreeNode with the given ID. * //from w ww . j a v a 2 s . c om * @param oid * @return */ @SuppressWarnings("rawtypes") public Vector<OIDObject> getOIDTreeNodeChildren(String oid) { Vector<OIDObject> children = new Vector<OIDObject>(); DefaultMutableTreeNode soughtNode = consentCreatorUtilites.traverseTreeOID(oid, getOIDTreeRoot()); if (soughtNode != null) { for (Enumeration e = soughtNode.children(); e.hasMoreElements();) { DefaultMutableTreeNode lon = (DefaultMutableTreeNode) e.nextElement(); OIDObject o = new OIDObject(((OIDObject) lon.getUserObject()).getIdentifier(), ((OIDObject) lon.getUserObject()).getName(), ((OIDObject) lon.getUserObject()).isActive()); o.setHasChildren(!lon.isLeaf()); children.add(o); } } return children; }
From source file:org.openehealth.coms.cc.web_frontend.consentcreator.service.ConsentCreatorUtilities.java
/** * Constructs a Vector from the given Node and it's sub-Nodes * //from www .j a v a 2 s. c o m * @param node * @return */ public Vector<JSONObject> traverseTreeForExpand(DefaultMutableTreeNode node) { try { Vector<JSONObject> vjbo = new Vector<JSONObject>(); for (Enumeration e = node.children(); e.hasMoreElements();) { DefaultMutableTreeNode n = (DefaultMutableTreeNode) e.nextElement(); JSONObject jso = new JSONObject(); jso.put("name", ((OIDObject) n.getUserObject()).getName()); jso.put("identifier", ((OIDObject) n.getUserObject()).getIdentifier()); jso.put("hasChildren", !n.isLeaf()); jso.put("isActive", ((OIDObject) n.getUserObject()).isActive()); if (n.getChildCount() != 0) { Vector<JSONObject> retvjo = traverseTreeForExpand(n); jso.put("children", retvjo); } vjbo.add(jso); } return vjbo; } catch (Exception e) { Logger.getLogger(this.getClass()).error(e); } return null; }
From source file:org.openehealth.coms.cc.web_frontend.consentcreator.service.ConsentCreatorUtilities.java
/** * Searches for the given oid in the given node and it's children. * If the node is found, it is returned. * //from www . j a va 2 s . co m * @param oid * @param node * @return */ @SuppressWarnings("rawtypes") public DefaultMutableTreeNode traverseTreeOID(String oid, DefaultMutableTreeNode node) { DefaultMutableTreeNode ret = null; Enumeration e = node.children(); while (e.hasMoreElements() && ret == null) { DefaultMutableTreeNode n = (DefaultMutableTreeNode) e.nextElement(); if (((OIDObject) n.getUserObject()).getIdentifier().equalsIgnoreCase(oid)) { ret = n; } else if (containsOID(oid, ((OIDObject) n.getUserObject()).getIdentifier())) { ret = traverseTreeOID(oid, n); } } return ret; }
From source file:org.openehealth.coms.cc.web_frontend.consentcreator.service.ConsentCreatorUtilities.java
/** * Searches for the given oid in the given node and it's children. * If the node is found, it is returned. * //from w w w . j a v a 2s . c o m * @param oid * @param node * @return */ @SuppressWarnings("rawtypes") public DefaultMutableTreeNode traverseTreeString(String query, DefaultMutableTreeNode searchNode, DefaultMutableTreeNode realNode) { DefaultMutableTreeNode ret = null; Enumeration e = realNode.children(); while (e.hasMoreElements()) { DefaultMutableTreeNode n = (DefaultMutableTreeNode) e.nextElement(); if (((OIDObject) n.getUserObject()).getName().toLowerCase().contains(query)) { ret = n; TreeNode[] path = n.getPath(); addNodeToModel(path, searchNode, 1); } if (n.getChildCount() != 0) { traverseTreeString(query, searchNode, n); } } return ret; }
From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java
private ArrayList<DefaultMutableTreeNode> getLocalLeafs(DefaultMutableTreeNode node, TreePath path) { ArrayList<DefaultMutableTreeNode> list = new ArrayList<DefaultMutableTreeNode>(); TreePath temp;/*from w ww .j a v a 2 s. c o m*/ if (node.isLeaf()) { list.add(node); } else { Enumeration<DefaultMutableTreeNode> en = node.children(); while (en.hasMoreElements()) { DefaultMutableTreeNode elem = en.nextElement(); temp = path.pathByAddingChild(elem); jTreeResults.expandPath(temp); list.addAll(getLocalLeafs(elem, temp)); } } return list; }
From source file:ser321.media.MediaJavaClient.java
private DefaultMutableTreeNode getSubLabelled(DefaultMutableTreeNode root, String label) { DefaultMutableTreeNode ret = null; DefaultMutableTreeNode next = null; boolean found = false; for (Enumeration e = root.children(); e.hasMoreElements();) { next = (DefaultMutableTreeNode) e.nextElement(); debug("sub with label: " + (String) next.getUserObject()); if (((String) next.getUserObject()).equals(label)) { debug("found sub with label: " + label); found = true;// w ww. j a v a 2 s. c om break; } } if (found) ret = next; else ret = null; return ret; }
From source file:streamme.visuals.Main.java
public void playNodes() { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree_files.getLastSelectedPathComponent(); if (node != null && node.isLeaf()) { DataNode dn = (DataNode) node.getUserObject(); if (!dn.isFolder()) { PlaylistManager pm = PlaylistManager.get(); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); pm.clearPlaylist(-1);//from w w w . j a v a 2s .c o m // Get Path: javax.swing.tree.TreeNode[] tree = parent.getPath(); String path = StreamMe.OPTIONS.getOutputPath(); for (int i = 1; i < tree.length; i++) { path += "\\" + ((DataNode) ((DefaultMutableTreeNode) tree[i]).getUserObject()).getName(); } Enumeration ch = parent.children(); DefaultMutableTreeNode child = null; while (ch.hasMoreElements()) { child = (DefaultMutableTreeNode) ch.nextElement(); if (child.isLeaf()) break; } int songIdx = 0, i = 0; while (child != null) { DataNode childnode = (DataNode) child.getUserObject(); if (child == node) { songIdx = i; } pm.addToPlaylist(-1, childnode.toFileLink(path + "\\" + childnode.getName())); child = child.getNextSibling(); i++; } playSong(pm.getDefaultModelIdx(), songIdx); } } }