keep selection on filtering/downloading
authorNiki Roo <niki@nikiroo.be>
Sat, 25 Apr 2020 18:01:40 +0000 (20:01 +0200)
committerNiki Roo <niki@nikiroo.be>
Sat, 25 Apr 2020 18:01:40 +0000 (20:01 +0200)
src/be/nikiroo/fanfix_swing/gui/BooksPanel.java
src/be/nikiroo/fanfix_swing/gui/book/BookInfo.java
src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java

index b0009c17ae64f987789d48c3013e778c14790738..0eef128dd93355299743a77ffc4de963b0e0ff76 100644 (file)
@@ -31,8 +31,10 @@ import be.nikiroo.utils.compat.JList6;
 import be.nikiroo.utils.compat.ListCellRenderer6;
 import be.nikiroo.utils.ui.DelayWorker;
 import be.nikiroo.utils.ui.ListModel;
+import be.nikiroo.utils.ui.ListSnapshot;
 import be.nikiroo.utils.ui.ListModel.Predicate;
 import be.nikiroo.utils.ui.ListenerPanel;
+import be.nikiroo.utils.ui.TreeSnapshot;
 import be.nikiroo.utils.ui.UIUtils;
 
 public class BooksPanel extends ListenerPanel {
@@ -113,7 +115,8 @@ public class BooksPanel extends ListenerPanel {
                }.execute();
        }
 
-       public void loadData(final BookInfo.Type type, final String value) {
+       // TODO
+       private void loadData(final BookInfo.Type type, final String value) {
                synchronized (lastLoad) {
                        lastLoad[0] = "type";
                        lastLoad[1] = type;
@@ -123,11 +126,12 @@ public class BooksPanel extends ListenerPanel {
                // TODO todo todo
        }
 
-       public void loadData(List<BookInfo> bookInfos) {
-               synchronized (lastLoad) {
-                       lastLoad[0] = "bookinfos";
-                       lastLoad[1] = bookInfos;
-               }
+       // TODO
+       private void loadData(List<BookInfo> bookInfos) {
+               // synchronized (lastLoad) {
+               // lastLoad[0] = "bookInfos";
+               // lastLoad[1] = bookInfos;
+               // }
 
                data.clearItems();
                data.addAllItems(bookInfos);
@@ -146,6 +150,8 @@ public class BooksPanel extends ListenerPanel {
                        return; // nothing was loaded yet
                }
 
+               ListSnapshot snapshot = new ListSnapshot(list);
+
                if (lastLoad[0].toString().equals("sources, authors, tags")) {
                        loadData((List<String>) lastLoad[1], (List<String>) lastLoad[2],
                                        (List<String>) lastLoad[3]);
@@ -157,6 +163,8 @@ public class BooksPanel extends ListenerPanel {
                        Instance.getInstance().getTraceHandler()
                                        .error("Unknown last load type: " + lastLoad[0]);
                }
+
+               snapshot.apply();
        }
 
        // is UI!
index 713ee203564f8ab90af62335e178faebb43fde1b..c0a164add08c44edd614fcc3db06679bee9aa2f7 100644 (file)
@@ -341,4 +341,9 @@ public class BookInfo {
 
                return info;
        }
+       
+       @Override
+       public String toString() {
+               return "BookInfo: " + type + " " + id;
+       }
 }
index 46c6946b672772055d9e46fa6fc36aed32fcca17..3110e00601d8d89366b6e3553261f49234399a68 100644 (file)
@@ -83,6 +83,9 @@ public class BookPopup extends JPopupMenu {
                addSeparator();
                add(createMenuItemExport());
                if (status.isWritable()) {
+                       // TODO: create a dedicated method to refresh those lists
+                       // TODO: call it when adding/removing things
+                       // TODO: call it deferred so not to slow startup
                        add(createMenuItemMoveTo());
                        add(createMenuItemSetCoverForSource());
                        add(createMenuItemSetCoverForAuthor());