From: Niki Roo Date: Mon, 13 Apr 2020 18:21:15 +0000 (+0200) Subject: stories order by name X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=62c7e07ef88c8f809b46f4e4525aa0d3f8a9cb14;p=fanfix-jexer.git stories order by name --- diff --git a/src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java b/src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java index eccdde5..80827c0 100644 --- a/src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java +++ b/src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java @@ -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 diff --git a/src/be/nikiroo/fanfix_swing/gui/browser/AuthorTab.java b/src/be/nikiroo/fanfix_swing/gui/browser/AuthorTab.java index d0e7ca9..b986e4d 100644 --- a/src/be/nikiroo/fanfix_swing/gui/browser/AuthorTab.java +++ b/src/be/nikiroo/fanfix_swing/gui/browser/AuthorTab.java @@ -27,6 +27,8 @@ public class AuthorTab extends BasicTab> { for (String author : authors) { data.add(author); } + + sort(data); } catch (Exception e) { // TODO e.printStackTrace(); diff --git a/src/be/nikiroo/fanfix_swing/gui/browser/BasicTab.java b/src/be/nikiroo/fanfix_swing/gui/browser/BasicTab.java index 9b2bf78..c7f1e42 100644 --- a/src/be/nikiroo/fanfix_swing/gui/browser/BasicTab.java +++ b/src/be/nikiroo/fanfix_swing/gui/browser/BasicTab.java @@ -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 extends ListenerPanel { protected abstract int loadData(DefaultMutableTreeNode root, T data, String filter); + protected void sort(List values) { + Collections.sort(values, new Comparator() { + @Override + public int compare(String o1, String o2) { + return ("" + o1).compareToIgnoreCase("" + o2); + } + }); + } + private TreeCellRenderer generateCellRenderer() { DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() { @Override diff --git a/src/be/nikiroo/fanfix_swing/gui/browser/SourceTab.java b/src/be/nikiroo/fanfix_swing/gui/browser/SourceTab.java index a0006b4..a86420e 100644 --- a/src/be/nikiroo/fanfix_swing/gui/browser/SourceTab.java +++ b/src/be/nikiroo/fanfix_swing/gui/browser/SourceTab.java @@ -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>> { protected int loadData(DefaultMutableTreeNode root, Map> sourcesGrouped, String filter) { int count = 0; - for (String source : sourcesGrouped.keySet()) { + List sources = new ArrayList(sourcesGrouped.keySet()); + sort(sources); + for (String source : sources) { if (checkFilter(filter, source) || checkFilter(filter, sourcesGrouped.get(source))) { List children = sourcesGrouped.get(source); @@ -77,6 +83,7 @@ public class SourceTab extends BasicTab>> { DefaultMutableTreeNode sourceNode = new DefaultMutableTreeNode( ">" + source + (hasChildren ? "/" : "")); root.add(sourceNode); + sort(children); for (String subSource : children) { if (checkFilter(filter, source) || checkFilter(filter, subSource)) { diff --git a/src/be/nikiroo/fanfix_swing/gui/browser/TagsTab.java b/src/be/nikiroo/fanfix_swing/gui/browser/TagsTab.java index 2d40eab..4224fb3 100644 --- a/src/be/nikiroo/fanfix_swing/gui/browser/TagsTab.java +++ b/src/be/nikiroo/fanfix_swing/gui/browser/TagsTab.java @@ -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> { } } } + + sort(data); } catch (Exception e) { // TODO e.printStackTrace();