protected void expand(CategoryNode node) { _tree.expandPath(getTreePath(node)); }
@Override public void treeExpanded(final TreeExpansionEvent event) { final TreePath treePath = event.getPath(); final Object expandedTreePathObject = treePath.getLastPathComponent(); if (!(expandedTreePathObject instanceof TreeNode)) { return; } final TreeNode expandedTreeNode = (TreeNode) expandedTreePathObject; if (expandedTreeNode.getChildCount() == 1) { final TreeNode descendantTreeNode = expandedTreeNode.getChildAt(0); if (descendantTreeNode.isLeaf()) { return; } final TreePath nextTreePath = treePath.pathByAddingChild(descendantTreeNode); tree.expandPath(nextTreePath); } }
protected void expand(CategoryNode node) { _tree.expandPath(getTreePath(node)); }
protected void expandRootNode() { if (_rootAlreadyExpanded) { return; } _rootAlreadyExpanded = true; TreePath path = new TreePath(_model.getRootCategoryNode().getPath()); expandPath(path); }
@Override public void mousePressed(MouseEvent e) { int selRow = ManagerDatabase.this.tree.getRowForLocation(e.getX(), e.getY()); TreePath selPath = ManagerDatabase.this.tree.getPathForLocation(e.getX(), e.getY()); if (selRow != -1 && e.getClickCount() == 2) { if (ManagerDatabase.this.tree.isExpanded(selPath)) { ManagerDatabase.this.tree.collapsePath(selPath); } else { ManagerDatabase.this.tree.expandPath(selPath); } } }
@Override public void run() { TreePath path = new TreePath(node.getPath()); if (!jTree.isExpanded(path)) { jTree.expandPath(path); jTree.updateUI(); } } });
/** * Call this method whenever you update the tree and needs it reloaded */ public synchronized void update() { synchronized (this.tree) { this.tree.removeTreeExpansionListener(this); this.tree.removeTreeSelectionListener(this); ((DefaultTreeModel) this.tree.getModel()).reload(); for (TreePath treePath : expandedTreePaths) { this.tree.expandPath(treePath); } this.tree.getSelectionModel().setSelectionPaths(selectedTreePaths); this.tree.addTreeExpansionListener(this); this.tree.addTreeSelectionListener(this); } }
protected void processCategories(Document doc) { CategoryExplorerTree tree = _monitor.getCategoryExplorerTree(); CategoryExplorerModel model = tree.getExplorerModel(); NodeList nodeList = doc.getElementsByTagName(CATEGORY); // determine where the starting node is NamedNodeMap map = nodeList.item(0).getAttributes(); int j = (getValue(map, NAME).equalsIgnoreCase(FIRST_CATEGORY_NAME)) ? 1 : 0; // iterate backwards throught the nodeList so that expansion of the // list can occur for (int i = nodeList.getLength() - 1; i >= j; i--) { Node n = nodeList.item(i); map = n.getAttributes(); CategoryNode chnode = model.addCategory(new CategoryPath(getValue(map, PATH))); chnode.setSelected((getValue(map, SELECTED).equalsIgnoreCase("true")) ? true : false); if (getValue(map, EXPANDED).equalsIgnoreCase("true")) ; tree.expandPath(model.getTreePathToRoot(chnode)); } }
@Override public void execute() { if (MediatorGui.treeDatabase() == null) { LOGGER.error("Unexpected unregistered MediatorGui.treeDatabase() in "+ this.getClass()); } // Tree model, update the tree (refresh, add node, etc) DefaultTreeModel treeModel = (DefaultTreeModel) MediatorGui.treeDatabase().getModel(); // First node in tree DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot(); // Loop into the list of databases for (Database database: this.databases) { // Create a node model with the database element AbstractNodeModel newTreeNodeModel = new NodeModelDatabase(database); // Create the node DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(newTreeNodeModel); // Save the node MediatorGui.frame().getTreeNodeModels().put(database, newNode); // Add the node to the tree root.add(newNode); } // Refresh the tree treeModel.reload(root); // Open the root node MediatorGui.treeDatabase().expandPath(new TreePath(root.getPath())); MediatorGui.treeDatabase().setRootVisible(false); }
MediatorGui.treeDatabase().expandPath(new TreePath(tableNode.getPath()));
MediatorGui.treeDatabase().expandPath(new TreePath(databaseNode.getPath()));
/** * Expand the given tree to the given level, starting from the given node * and path. * * @param tree The tree to be expanded * @param node The node to start from * @param path The path to start from * @param level The number of levels to expand to */ private static void expandNode(final JTree tree, final TreeNode node, final TreePath path, final int level) { if (level <= 0) { return; } tree.expandPath(path); for (int i = 0; i < node.getChildCount(); ++i) { final TreeNode childNode = node.getChildAt(i); expandNode(tree, childNode, path.pathByAddingChild(childNode), level - 1); } }
@Override public void run() { try { System.out.println("auto expanding " + p); tree.expandPath(p); } catch (Exception e) { e.printStackTrace(); } } });
private void expandPath(TreePath treePath) { if (!tree.isExpanded(treePath)) { tree.expandPath(treePath); } }
/** Expand the given path and makes it visible. * @param path the path */ protected void showPath(TreePath path) { tree.expandPath(path); showPathWithoutExpansion(path); }
@Override public void run() { LOG.log(Level.FINEST, "Just print the variable so it is not GCed: {0}", prepare); final TreePath p = getTreePath(n); LOG.log(Level.FINE, "expandNode: {0} {1}", new Object[] { n, p }); tree.expandPath(p); LOG.fine("expandPath done"); } });
/** * Call to expand the entire tree. */ public void expandTree() { for (int i = 0; i <= tree.getRowCount(); i++) { tree.expandPath(tree.getPathForRow(i)); } }
private void expandTree(JTree tree, TreePath parent) { TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration<?> children = node.children(); children.hasMoreElements();) { TreeNode subNode = (TreeNode) children.nextElement(); TreePath path = parent.pathByAddingChild(subNode); expandTree(tree, path); } } tree.expandPath(parent); }
private void expandTree(JTree tree, TreePath parent) { TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration<?> enumNodes = node.children(); enumNodes.hasMoreElements();) { TreeNode subNode = (TreeNode) enumNodes.nextElement(); TreePath path = parent.pathByAddingChild(subNode); expandTree(tree, path); } } tree.expandPath(parent); }
public void runDiscovery(){ Gateway[] g = Gateway.newGateways(bc); for (int i = 0 ; i < g.length ; i++) { this.createTreeNode(g[i]); } (new Thread(this.pt)).start(); tree.expandPath(new TreePath(((DefaultMutableTreeNode)(dtm.getRoot())).getPath())); // expand root node }