// {{{ traverseNodes() method public static boolean traverseNodes( DefaultMutableTreeNode node, HyperSearchTreeNodeCallback callbackInterface) { if (!callbackInterface.processNode(node)) return false; for (Enumeration e = node.children(); e.hasMoreElements(); ) { DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) e.nextElement(); if (!traverseNodes(childNode, callbackInterface)) return false; } return true; } // }}}
@Override public void actionPerformed(ActionEvent evt) { TreePath path = resultTree.getSelectionPath(); DefaultMutableTreeNode operNode = (DefaultMutableTreeNode) path.getLastPathComponent(); for (Enumeration e = operNode.children(); e.hasMoreElements(); ) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement(); resultTree.collapsePath(new TreePath(node.getPath())); } resultTree.scrollPathToVisible(new TreePath(operNode.getPath())); }
private OncFilter makeLevelListFilter(Hashtable keywords) { // Create a filter OncFilter filter = new OncFilter(false); OncTreeNode rootNode = filter.getRootNode(); OncTreeNode orNode = new OncTreeNode(TcapLogicalOperator.OR, Persistible.DO_NOT_SAVE); OncTreeNode keywordNode; for (Enumeration e = keywords.keys(); e.hasMoreElements(); ) { Object obj = e.nextElement(); if (obj instanceof Keyword) orNode.add(new OncTreeNode(obj, (Persistible.DO_NOT_SAVE))); } rootNode.add(orNode); return filter; }
public Vector getAssociatedLevelLists() { Vector levelLists = new Vector(); Vector endPts = CollectionHelper.makeVector("Keyword"); Hashtable keywordParents = oncotcap.Oncotcap.getDataSource() .getParentTree( "Keyword", endPts, CollectionHelper.makeVector(this), TreeDisplayModePanel.ROOT); // Take each of the parents and get the associated level lists if (keywordParents.size() <= 0) return levelLists; Hashtable levelListsHashtable = oncotcap.Oncotcap.getDataSource() .getInstanceTree( "EnumLevelList", new Vector(), makeLevelListFilter(keywordParents), TreeDisplayModePanel.ROOT); for (Enumeration e = keywordParents.keys(); e.hasMoreElements(); ) { System.out.println("Keyword.getAssociatedLevelLists: " + e.nextElement()); } // Collect all the level lists from the hashtable Vector selectedItems = CollectionHelper.makeVector(keyword); for (Enumeration e = levelListsHashtable.keys(); e.hasMoreElements(); ) { Object obj = e.nextElement(); if (obj instanceof EnumLevelList) { levelLists.addElement(obj); } } return levelLists; }