stories order by name
authorNiki Roo <niki@nikiroo.be>
Mon, 13 Apr 2020 18:21:15 +0000 (20:21 +0200)
committerNiki Roo <niki@nikiroo.be>
Mon, 13 Apr 2020 18:21:15 +0000 (20:21 +0200)
src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java
src/be/nikiroo/fanfix_swing/gui/browser/AuthorTab.java
src/be/nikiroo/fanfix_swing/gui/browser/BasicTab.java
src/be/nikiroo/fanfix_swing/gui/browser/SourceTab.java
src/be/nikiroo/fanfix_swing/gui/browser/TagsTab.java

index eccdde59e1960b238bee2be565439ee9da727238..80827c07467b51cbc87453d65db8437c8f591546 100644 (file)
@@ -473,6 +473,12 @@ public class BookPopup extends JPopupMenu {
                                                                // enough, we need to clear the whole cache (for
                                                                // BrowserPanel for instance)
                                                                informer.invalidateCache();
+                                                               
+                                                               // But we ALSO fire those, because they appear
+                                                               // before the whole refresh...
+                                                               for (BookInfo book : selected) {
+                                                                       informer.fireElementChanged(book);
+                                                               }
 
                                                                // TODO: also refresh the
                                                                // Sources/Authors(/Tags?) list
index d0e7ca906f6e32b5b838bc12ca7cd6ed8ddb8b95..b986e4ddf7d6f2b2e4418cdd7632a2a32bbe70fd 100644 (file)
@@ -27,6 +27,8 @@ public class AuthorTab extends BasicTab<List<String>> {
                        for (String author : authors) {
                                data.add(author);
                        }
+
+                       sort(data);
                } catch (Exception e) {
                        // TODO
                        e.printStackTrace();
index 9b2bf789ac8ab05a75ae89c3a1b67a65fb91ba14..c7f1e424421e6a09aede3527b29c8f8d54eba388 100644 (file)
@@ -5,6 +5,9 @@ import java.awt.Component;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 
@@ -210,6 +213,15 @@ public abstract class BasicTab<T> extends ListenerPanel {
        protected abstract int loadData(DefaultMutableTreeNode root, T data,
                        String filter);
 
+       protected void sort(List<String> values) {
+               Collections.sort(values, new Comparator<String>() {
+                       @Override
+                       public int compare(String o1, String o2) {
+                               return ("" + o1).compareToIgnoreCase("" + o2);
+                       }
+               });
+       }
+
        private TreeCellRenderer generateCellRenderer() {
                DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() {
                        @Override
index a0006b4de4c088e75e1296ee596662721944de7c..a86420e57a58ab2c807ff2823cc81bebe3630331 100644 (file)
@@ -1,5 +1,9 @@
 package be.nikiroo.fanfix_swing.gui.browser;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -67,7 +71,9 @@ public class SourceTab extends BasicTab<Map<String, List<String>>> {
        protected int loadData(DefaultMutableTreeNode root,
                        Map<String, List<String>> sourcesGrouped, String filter) {
                int count = 0;
-               for (String source : sourcesGrouped.keySet()) {
+               List<String> sources = new ArrayList<String>(sourcesGrouped.keySet());
+               sort(sources);
+               for (String source : sources) {
                        if (checkFilter(filter, source)
                                        || checkFilter(filter, sourcesGrouped.get(source))) {
                                List<String> children = sourcesGrouped.get(source);
@@ -77,6 +83,7 @@ public class SourceTab extends BasicTab<Map<String, List<String>>> {
                                DefaultMutableTreeNode sourceNode = new DefaultMutableTreeNode(
                                                ">" + source + (hasChildren ? "/" : ""));
                                root.add(sourceNode);
+                               sort(children);
                                for (String subSource : children) {
                                        if (checkFilter(filter, source)
                                                        || checkFilter(filter, subSource)) {
index 2d40eab4ed6b0ce7bd0f67fbc5d08f69de600856..4224fb343a51126f45ea1eae66f12879d742075f 100644 (file)
@@ -1,6 +1,7 @@
 package be.nikiroo.fanfix_swing.gui.browser;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import javax.swing.tree.DefaultMutableTreeNode;
@@ -37,6 +38,8 @@ public class TagsTab extends BasicTab<List<String>> {
                                        }
                                }
                        }
+
+                       sort(data);
                } catch (Exception e) {
                        // TODO
                        e.printStackTrace();