some update/refresh fixes
[fanfix.git] / src / be / nikiroo / fanfix_swing / gui / browser / SourceTab.java
index 6abb46433499bac4fd4fc82b4762c1a30e0b3219..ffa5e416abfd9936ee47264cd787e62ac46a0da6 100644 (file)
@@ -38,6 +38,10 @@ public class SourceTab extends BasicTab<Map<String, List<String>>> {
 
        @Override
        protected String keyToDisplay(String key) {
+               if (key.trim().isEmpty()) {
+                       return "[*]"; // Root node
+               }
+
                // Get and remove type
                String type = key.substring(0, 1);
                key = key.substring(1);
@@ -62,10 +66,12 @@ public class SourceTab extends BasicTab<Map<String, List<String>>> {
                int count = 0;
                for (String source : sourcesGrouped.keySet()) {
                        if (checkFilter(filter, source) || checkFilter(filter, sourcesGrouped.get(source))) {
-                               boolean hasChildren = sourcesGrouped.get(source).size() > 1;
+                               List<String> children = sourcesGrouped.get(source);
+                               boolean hasChildren = (children.size() > 1)
+                                               || (children.size() == 1 && !children.get(0).trim().isEmpty());
                                DefaultMutableTreeNode sourceNode = new DefaultMutableTreeNode(">" + source + (hasChildren ? "/" : ""));
                                root.add(sourceNode);
-                               for (String subSource : sourcesGrouped.get(source)) {
+                               for (String subSource : children) {
                                        if (checkFilter(filter, source) || checkFilter(filter, subSource)) {
                                                count = count + 1;
                                                if (subSource.isEmpty() && sourcesGrouped.get(source).size() > 1) {