@Override public void mousePressed(MouseEvent event) { boolean isClickCountMatches = (event.getClickCount() == 1 && luytenPrefs.isSingleClickOpenEnabled()) || (event.getClickCount() == 2 && !luytenPrefs.isSingleClickOpenEnabled()); if (!isClickCountMatches) return; if (!SwingUtilities.isLeftMouseButton(event)) return; final TreePath trp = tree.getPathForLocation(event.getX(), event.getY()); if (trp == null) return; Object lastPathComponent = trp.getLastPathComponent(); boolean isLeaf = (lastPathComponent instanceof TreeNode && ((TreeNode) lastPathComponent).isLeaf()); if (!isLeaf) return; new Thread() { public void run() { openEntryByTreePath(trp); } }.start(); } }
@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); } }
/** * TreeModel method to determine if a node is a leaf. Since <code>node</code> is a TreeNode, this can be answered via * the TreeNode method <code>isLeaf</code>. */ public boolean isLeaf(Object node) { return ((TreeNode)node).isLeaf(); }
/** * Returns <code>true</code> if <code>node</code> is a leaf. It is possible for this method to return * <code>false</code> even if <code>node</code> has no children. A directory in a filesystem, for example, may contain * no files; the node representing the directory is not a leaf, but it also has no children. * * @param node a node in the tree, obtained from this data source * @return true if <code>node</code> is a leaf */ public boolean isLeaf( final Object node ) { final TreeNode tnode = (TreeNode) node; return tnode.isLeaf(); }
public boolean isLeaf() { if (bean != null && bean instanceof TreeNode) { return ((TreeNode)bean).isLeaf(); } return true; }
@Override public boolean isLeaf(Object node) { return ((TreeNode) node).isLeaf(); }
public boolean isLeaf(javax.swing.tree.TreeNode node) { return !node.getAllowsChildren() || node.isLeaf(); } };
@Override public boolean isFolder() { return !getRowData().isLeaf(); }
/** * Returns whether the specified node is a leaf node. The way the test is * performed depends on the. * * @param node * the node to check * @return true if the node is a leaf node */ public boolean isLeaf(Object node) { if (asksAllowsChildren && node instanceof TreeNode) return !((TreeNode) node).getAllowsChildren(); return ((TreeNode) node).isLeaf(); }
for (TreeNode treeNode : nodes) { if(treeNode.isLeaf()){ TreeNode parent = treeNode.getParent(); parent.getChildren().remove(treeNode); } }
public Stream<TreeNode> stream(TreeNode parentNode) { if(parentNode.isLeaf()) { return Stream.of(parentNode) ; } else { return parentNode.getChildren().stream() .map(childNode -> stream(childNode)) .reduce(Stream.of(parentNode), (s1, s2) -> Stream.concat(s1, s2)) ; } }
private static void expandAll(JTree tree, TreePath parent) { TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.isLeaf() && tree.isVisible(parent) == false) { tree.makeVisible(parent); } else { for (Enumeration en = node.children(); en.hasMoreElements();) { TreeNode child = (TreeNode) en.nextElement(); expandAll(tree, parent.pathByAddingChild(child)); } } }
public boolean isLeaf() { if (!asksAllowsChildren) { return getData().isLeaf(); } else { return !getData().getAllowsChildren(); } }
public boolean isLeaf() { if (!asksAllowsChildren) { return getData().isLeaf(); } else { return !getData().getAllowsChildren(); } }
public boolean isLeaf() { if (!asksAllowsChildren) { return getData().isLeaf(); } else { return !getData().getAllowsChildren(); } }
private void testThatChildIsDapNode(DefaultMutableTreeNode parentNode) { assertEquals(1, parentNode.getChildCount()); assertEquals(true, parentNode.getChildAt(0).isLeaf()); assertEquals(true, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0))); }
@Test public void testAppendDapNode() throws URISyntaxException { // preparation datasets.add(createDataset(catalog, "first", "OPENDAP")); // execution new CatalogTree(null, new DefaultAppContext(""), null).appendToNode(new JTree(), datasets, parentNode, true); // verification assertEquals(1, parentNode.getChildCount()); assertEquals(true, parentNode.getChildAt(0).isLeaf()); assertEquals(true, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0))); }
@Test public void testAppendFileNode() throws URISyntaxException { //preparation datasets.add(createDataset(catalog, "fileName", "file")); //execution new CatalogTree(null, new DefaultAppContext(""), null).appendToNode(new JTree(), datasets, parentNode, true); //verification assertEquals(1, parentNode.getChildCount()); assertEquals(true, parentNode.getChildAt(0).isLeaf()); assertEquals(false, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0))); }
private void testThatChildIsNodeWithFileAccess(DefaultMutableTreeNode parentNode) { assertEquals(1, parentNode.getChildCount()); assertEquals(true, parentNode.getChildAt(0).isLeaf()); assertEquals(false, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0))); assertEquals(true, CatalogTreeUtils.isFileNode(parentNode.getChildAt(0))); }