From: Niki Roo Date: Sat, 25 Apr 2020 18:01:40 +0000 (+0200) Subject: keep selection on filtering/downloading X-Git-Tag: fanfix-swing-1.0.0~35 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=f40e041bd2d02683569c8ca3e2d1c9d3232bdd32;p=fanfix-swing.git keep selection on filtering/downloading --- diff --git a/src/be/nikiroo/fanfix_swing/gui/BooksPanel.java b/src/be/nikiroo/fanfix_swing/gui/BooksPanel.java index b0009c17..0eef128d 100644 --- a/src/be/nikiroo/fanfix_swing/gui/BooksPanel.java +++ b/src/be/nikiroo/fanfix_swing/gui/BooksPanel.java @@ -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 bookInfos) { - synchronized (lastLoad) { - lastLoad[0] = "bookinfos"; - lastLoad[1] = bookInfos; - } + // TODO + private void loadData(List 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) lastLoad[1], (List) lastLoad[2], (List) 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! diff --git a/src/be/nikiroo/fanfix_swing/gui/book/BookInfo.java b/src/be/nikiroo/fanfix_swing/gui/book/BookInfo.java index 713ee203..c0a164ad 100644 --- a/src/be/nikiroo/fanfix_swing/gui/book/BookInfo.java +++ b/src/be/nikiroo/fanfix_swing/gui/book/BookInfo.java @@ -341,4 +341,9 @@ public class BookInfo { return info; } + + @Override + public String toString() { + return "BookInfo: " + type + " " + id; + } } diff --git a/src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java b/src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java index 46c6946b..3110e006 100644 --- a/src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java +++ b/src/be/nikiroo/fanfix_swing/gui/book/BookPopup.java @@ -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());