From: Niki Roo Date: Sat, 25 Apr 2020 23:23:11 +0000 (+0200) Subject: DataNode, DataTree fixes X-Git-Tag: fanfix-swing-1.0.0~27 X-Git-Url: http://git.nikiroo.be/?a=commitdiff_plain;h=2e942f960d2b12b22f8097c8375186a174902d46;p=fanfix-swing.git DataNode, DataTree fixes --- diff --git a/src/be/nikiroo/utils/ui/DataNode.java b/src/be/nikiroo/utils/ui/DataNode.java index 2d3ac267..b4dbe7bb 100644 --- a/src/be/nikiroo/utils/ui/DataNode.java +++ b/src/be/nikiroo/utils/ui/DataNode.java @@ -78,8 +78,14 @@ public class DataNode { return userData; } - protected int count() { - int s = 0; + /** + * The total number of nodes present in this {@link DataNode} (including + * itself and descendants). + * + * @return the number + */ + public int count() { + int s = 1; for (DataNode child : children) { s += child.count(); } diff --git a/src/be/nikiroo/utils/ui/DataTree.java b/src/be/nikiroo/utils/ui/DataTree.java index e941a71d..108476ea 100644 --- a/src/be/nikiroo/utils/ui/DataTree.java +++ b/src/be/nikiroo/utils/ui/DataTree.java @@ -65,24 +65,4 @@ public abstract class DataTree { return new DataNode(children, source.getUserData()); } - - // TODO: not in this class: - - public void loadInto(DefaultMutableTreeNode root, String filter) { - DataNode filtered = getRoot(filter); - for (DataNode child : filtered.getChildren()) { - root.add(nodeToNode(child)); - } - } - - private MutableTreeNode nodeToNode(DataNode node) { - // TODO: node.toString - DefaultMutableTreeNode otherNode = new DefaultMutableTreeNode( - node.toString()); - for (DataNode child : node.getChildren()) { - otherNode.add(nodeToNode(child)); - } - - return otherNode; - } }