From 2e942f960d2b12b22f8097c8375186a174902d46 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 26 Apr 2020 01:23:11 +0200 Subject: [PATCH] DataNode, DataTree fixes --- src/be/nikiroo/utils/ui/DataNode.java | 10 ++++++++-- src/be/nikiroo/utils/ui/DataTree.java | 20 -------------------- 2 files changed, 8 insertions(+), 22 deletions(-) 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; - } } -- 2.27.0