// 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
for (String author : authors) {
data.add(author);
}
+
+ sort(data);
} catch (Exception e) {
// TODO
e.printStackTrace();
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;
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
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;
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);
DefaultMutableTreeNode sourceNode = new DefaultMutableTreeNode(
">" + source + (hasChildren ? "/" : ""));
root.add(sourceNode);
+ sort(children);
for (String subSource : children) {
if (checkFilter(filter, source)
|| checkFilter(filter, subSource)) {
package be.nikiroo.fanfix_swing.gui.browser;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import javax.swing.tree.DefaultMutableTreeNode;
}
}
}
+
+ sort(data);
} catch (Exception e) {
// TODO
e.printStackTrace();