From 754a5bc205f6a50f3fe3fe7c2dfb09d8a8dd09bb Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 5 Mar 2017 19:50:21 +0100 Subject: [PATCH] UI: progress bars fixes, update nikiroo-utils - UI: progress bar now working correctly - nikiroo-utils update to show all steps in the progress bars --- ...es.jar => nikiroo-utils-1.3.5-sources.jar} | Bin 49880 -> 51298 bytes src/be/nikiroo/fanfix/reader/LocalReader.java | 4 +- .../fanfix/reader/LocalReaderFrame.java | 108 ++++++++++-------- .../fanfix/supported/BasicSupport.java | 2 + 4 files changed, 67 insertions(+), 47 deletions(-) rename libs/{nikiroo-utils-1.3.4-sources.jar => nikiroo-utils-1.3.5-sources.jar} (84%) diff --git a/libs/nikiroo-utils-1.3.4-sources.jar b/libs/nikiroo-utils-1.3.5-sources.jar similarity index 84% rename from libs/nikiroo-utils-1.3.4-sources.jar rename to libs/nikiroo-utils-1.3.5-sources.jar index f4b5883d12bbb6a81149ad8861d192e62f89412d..e2af882d63fa5ceadf162f6e4537b392700342be 100644 GIT binary patch delta 4235 zcmZXXbyQT*x5tM8q+5FEl9KL{QfVYb7=(c#MY<%e0)n7OjNkx*3?Pj#l=RRcCFy{~ z&?#LOJmmLV>-pBZf1LB(d*6M|y7%sN_WfX=<1Z%SlN;;d6I=%o6BC12vy#Y_z?Y-W zAii({9Knnyf-iMB-^J^p$xVXmg8sS05zk1O5jc8cK*Qe0!2Yqn{UbBDuis5K`vChC zGkeczaq2(hn8hgRzCsaQq_lbbPn2=KKkNfbb-J`c3IbAer-J9(v&VE7VF9#vi3LYh zsoyoOo$d?`>$ukCNN7BzbQb1+?j<=$yW(Oty&Ev4NN>_1)_|g%b#vx*jPlV1UJm4C zSj}*L1%?a?({OZ+s#Ix`AChvFCxiXRQ}?kyBtKU(%y*;R@?P)>tzcq% zv3SxswNcV!v0{<^W%q@VH>1J2COVE{pu*t$U-VMy-k6 z6r3C0W4FrLl$7y=$q5rUC1T!U4V>O;KNxaBhcmreTjg7cUAV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F%H33~Q>728#GO4+-e}iQJXPdcp=Qy9PT30i) zv^6<~^RVdt979-rB2m*<_BOGKIptCD8rs6Qh6mLb4J&+6ZhU!-J=d3?XJ|<*Eb-#& zMM|Jpx@BL`QOVcK<)++S)Y=FsG{0IzmNK)-RBdwSI^o{UgKYDS1HDdE-8@4*(G_lX z*^nP&XX)hRY$(dA0T6>ecB9ntGWN-80vXO11@TB1v2Y=GHH5lX_QMl)&1-wxE z_uoK-T%gT+OcR*C3jBFHzhwq$&-YYZfJB1*cP9d5(d0=!1gfMnGm(5Po9j?}Towim z9<8M}mT@lAQ?7OxlZVpnFs8#>N_&?Y<@Q2MhdXm6!dv%t53Oes#vYlpZ4MvmAangzW@g`O*e2c(PLtitSb zr_ICU7Cg>!;kKULGf0i?wgN>JjVvqO8NAAkr^91B2obP}3O1ntluh$uoryjW0o=Pd z8xMHPLA?B z!hOoh+Q_%LhFeuZHn39?MHV3J*UMIao{}_`j8YXh)E|1+MsZ_IKpW0eUS9ZpXGKts z5}9BS=o1qV&nn#1P72^S`9A^YdNh9<_nyZ9oWcbN_abQ4xi{ei3TBEXeFSui}{1YtnUpb{7w zL{tABGzABT($FHD3kV&O1xv@!+|D6waCz(rN(17B zvDGwptCkUPp|FWZa@d*ubL=3{*?(sNW&b~z0Vt(tf4`|lk80k~}(9smFU diff --git a/src/be/nikiroo/fanfix/reader/LocalReader.java b/src/be/nikiroo/fanfix/reader/LocalReader.java index b031de84..29a840f3 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReader.java +++ b/src/be/nikiroo/fanfix/reader/LocalReader.java @@ -211,8 +211,8 @@ class LocalReader extends BasicReader { }); } - // refresh = delete from LocalReader cache (TODO: rename?) - void refresh(String luid) { + // delete from local reader library + void clearLocalReaderCache(String luid) { lib.delete(luid); } diff --git a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java index a90360ee..1dc63e78 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java @@ -97,6 +97,22 @@ class LocalReaderFrame extends JFrame { pgBar = new ProgressBar(); add(pgBar, BorderLayout.SOUTH); + pgBar.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + invalidate(); + pgBar.setProgress(null); + validate(); + setEnabled(true); + } + }); + + pgBar.addUpdateListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + revalidate(); + repaint(); + } + }); + setJMenuBar(createMenu()); booksByType = new HashMap(); @@ -185,8 +201,6 @@ class LocalReaderFrame extends JFrame { /** * Refresh the list of {@link LocalReaderBook}s from disk. * - * @param type - * the type of {@link Story} to load, or NULL for all types */ private void refreshBooks() { for (LocalReaderGroup group : booksByType.keySet()) { @@ -427,7 +441,8 @@ class LocalReaderFrame extends JFrame { if (selectedBook != null) { outOfUi(null, new Runnable() { public void run() { - reader.refresh(selectedBook.getMeta().getLuid()); + reader.clearLocalReaderCache(selectedBook.getMeta() + .getLuid()); selectedBook.setCached(false); SwingUtilities.invokeLater(new Runnable() { public void run() { @@ -453,12 +468,13 @@ class LocalReaderFrame extends JFrame { refresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (selectedBook != null) { - imprt(selectedBook.getMeta().getUrl(), new Runnable() { + final MetaData meta = selectedBook.getMeta(); + imprt(meta.getUrl(), new Runnable() { public void run() { - reader.delete(selectedBook.getMeta().getLuid()); - selectedBook = null; + reader.delete(meta.getLuid()); + LocalReaderFrame.this.selectedBook = null; } - }); + }, "Removing old copy"); } } }); @@ -480,11 +496,6 @@ class LocalReaderFrame extends JFrame { public void run() { reader.delete(selectedBook.getMeta().getLuid()); selectedBook = null; - SwingUtilities.invokeLater(new Runnable() { - public void run() { - refreshBooks(); - } - }); } }); } @@ -549,31 +560,32 @@ class LocalReaderFrame extends JFrame { * @param run * the action to run */ - private void outOfUi(final Progress pg, final Runnable run) { - pgBar.setProgress(pg); + private void outOfUi(Progress progress, final Runnable run) { + final Progress pg = new Progress(); + final Progress reload = new Progress("Reload local caches"); + if (progress == null) { + progress = new Progress(); + } + pg.addProgress(progress, 90); + pg.addProgress(reload, 10); + + invalidate(); + pgBar.setProgress(pg); + validate(); setEnabled(false); - pgBar.addActioListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - pgBar.setProgress(null); - setEnabled(true); - } - }); new Thread(new Runnable() { public void run() { run.run(); - if (pg == null) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - setEnabled(true); - } - }); - } else if (!pg.isDone()) { + refreshBooks(); + reload.setProgress(100); + if (!pg.isDone()) { + // will trigger pgBar ActionListener: pg.setProgress(pg.getMax()); } } - }).start(); + }, "outOfUi thread").start(); } /** @@ -612,7 +624,7 @@ class LocalReaderFrame extends JFrame { } if (url != null && !url.toString().isEmpty()) { - imprt(url.toString(), null); + imprt(url.toString(), null, null); } } @@ -626,13 +638,20 @@ class LocalReaderFrame extends JFrame { * @param onSuccess * Action to execute on success */ - private void imprt(final String url, final Runnable onSuccess) { - final Progress pg = new Progress("Importing " + url); + private void imprt(final String url, final Runnable onSuccess, + String onSuccessPgName) { + final Progress pg = new Progress(); + final Progress pgImprt = new Progress(); + final Progress pgOnSuccess = new Progress(onSuccessPgName); + pg.addProgress(pgImprt, 95); + pg.addProgress(pgOnSuccess, 5); + outOfUi(pg, new Runnable() { public void run() { Exception ex = null; try { - Instance.getLibrary().imprt(BasicReader.getUrl(url), pg); + Instance.getLibrary().imprt(BasicReader.getUrl(url), + pgImprt); } catch (IOException e) { ex = e; } @@ -640,25 +659,24 @@ class LocalReaderFrame extends JFrame { final Exception e = ex; final boolean ok = (e == null); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - if (!ok) { - Instance.syserr(e); + + pgOnSuccess.setProgress(0); + if (!ok) { + Instance.syserr(e); + SwingUtilities.invokeLater(new Runnable() { + public void run() { JOptionPane.showMessageDialog( LocalReaderFrame.this, "Cannot import: " + url, e.getMessage(), JOptionPane.ERROR_MESSAGE); - - setEnabled(true); - } else { - refreshBooks(); - if (onSuccess != null) { - onSuccess.run(); - refreshBooks(); - } } + }); + } else { + if (onSuccess != null) { + onSuccess.run(); } - }); + } + pgOnSuccess.setProgress(100); } }); } diff --git a/src/be/nikiroo/fanfix/supported/BasicSupport.java b/src/be/nikiroo/fanfix/supported/BasicSupport.java index f255d5ed..e3b6fab3 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupport.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupport.java @@ -401,6 +401,8 @@ public abstract class BasicSupport { return null; } + pg.setName("Retrieving " + story.getMeta().getTitle()); + setCurrentReferer(url); story.setChapters(new ArrayList()); -- 2.27.0