public void nodeAdded(String fqn) { MyNode n, p; n = root.add(fqn); if (n != null) { p = (MyNode) n.getParent(); tree_model.reload(p); jtree.scrollPathToVisible(new TreePath(n.getPath())); } }
@Override public void selectUsages(@NotNull Usage[] usages) { List<TreePath> paths = new LinkedList<TreePath>(); for (Usage usage : usages) { final UsageNode node = myUsageNodes.get(usage); if (node != NULL_NODE && node != null) { paths.add(new TreePath(node.getPath())); } } myTree.setSelectionPaths(paths.toArray(new TreePath[paths.size()])); if (!paths.isEmpty()) myTree.scrollPathToVisible(paths.get(0)); }
/** * Processes an idChanged event. Search is different from all other navigators in that you while * search tree is synchronized the highlighting doesn't occur unless selected from the search * navigator. */ public void idChanged(HelpModelEvent e) { ID id = e.getID(); URL url = e.getURL(); HelpModel helpModel = searchnav.getModel(); debug("idChanged(" + e + ")"); if (e.getSource() != helpModel) { debug("Internal inconsistency!"); debug(" " + e.getSource() + " != " + helpModel); throw new Error("Internal error"); } TreePath s = tree.getSelectionPath(); if (s != null) { Object o = s.getLastPathComponent(); // should require only a TreeNode if (o instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode tn = (DefaultMutableTreeNode) o; SearchTOCItem item = (SearchTOCItem) tn.getUserObject(); if (item != null) { ID nId = item.getID(); if (nId != null && nId.equals(id)) { return; } } } } DefaultMutableTreeNode node = findIDorURL(topNode, id, url); if (node == null) { // node doesn't exist. Need to clear the selection. debug("node didn't exist"); tree.clearSelection(); return; } TreePath path = new TreePath(node.getPath()); tree.expandPath(path); tree.setSelectionPath(path); tree.scrollPathToVisible(path); }