DataNode, DataTree fixes
authorNiki Roo <niki@nikiroo.be>
Sat, 25 Apr 2020 23:23:11 +0000 (01:23 +0200)
committerNiki Roo <niki@nikiroo.be>
Sat, 25 Apr 2020 23:23:11 +0000 (01:23 +0200)
src/be/nikiroo/utils/ui/DataNode.java
src/be/nikiroo/utils/ui/DataTree.java

index 2d3ac267842325333484b68886998471981d8135..b4dbe7bb04130bf69e4e67ca12ea330b812544ef 100644 (file)
@@ -78,8 +78,14 @@ public class DataNode<T> {
                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<T> child : children) {
                        s += child.count();
                }
index e941a71d2ac00a238c0c6fd6a67932b7f08ca080..108476eadfc2a4384bc1724a2a0c64ddcbe7fe3f 100644 (file)
@@ -65,24 +65,4 @@ public abstract class DataTree<E> {
 
                return new DataNode<E>(children, source.getUserData());
        }
-
-       // TODO: not in this class:
-
-       public void loadInto(DefaultMutableTreeNode root, String filter) {
-               DataNode<E> filtered = getRoot(filter);
-               for (DataNode<E> child : filtered.getChildren()) {
-                       root.add(nodeToNode(child));
-               }
-       }
-
-       private MutableTreeNode nodeToNode(DataNode<E> node) {
-               // TODO: node.toString
-               DefaultMutableTreeNode otherNode = new DefaultMutableTreeNode(
-                               node.toString());
-               for (DataNode<E> child : node.getChildren()) {
-                       otherNode.add(nodeToNode(child));
-               }
-
-               return otherNode;
-       }
 }