From: Niki Roo Date: Mon, 13 Apr 2020 18:21:15 +0000 (+0200) Subject: stories order by name X-Git-Tag: fanfix-swing-0.0.1~31^2 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=62c7e07ef88c8f809b46f4e4525aa0d3f8a9cb14;p=fanfix-swing.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 eccdde59..80827c07 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 d0e7ca90..b986e4dd 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 9b2bf789..c7f1e424 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 a0006b4d..a86420e5 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 2d40eab4..4224fb34 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();