From 3b2b638f7e1395702f843b5b19d7959327f604b2 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 19 Feb 2017 01:46:02 +0100 Subject: [PATCH] Add progress reporting on GUI --- ...es.jar => nikiroo-utils-1.1.1-sources.jar} | Bin 45056 -> 46014 bytes src/be/nikiroo/fanfix/Library.java | 2 +- src/be/nikiroo/fanfix/Main.java | 37 +---- src/be/nikiroo/fanfix/output/BasicOutput.java | 2 +- src/be/nikiroo/fanfix/reader/BasicReader.java | 32 ++++- src/be/nikiroo/fanfix/reader/LocalReader.java | 2 +- .../fanfix/reader/LocalReaderBook.java | 27 ++-- .../fanfix/reader/LocalReaderFrame.java | 127 +++++++++++++----- .../fanfix/supported/BasicSupport.java | 5 +- src/be/nikiroo/fanfix/supported/Cbz.java | 2 +- src/be/nikiroo/fanfix/supported/E621.java | 2 +- 11 files changed, 153 insertions(+), 85 deletions(-) rename libs/{nikiroo-utils-1.1.0-sources.jar => nikiroo-utils-1.1.1-sources.jar} (74%) diff --git a/libs/nikiroo-utils-1.1.0-sources.jar b/libs/nikiroo-utils-1.1.1-sources.jar similarity index 74% rename from libs/nikiroo-utils-1.1.0-sources.jar rename to libs/nikiroo-utils-1.1.1-sources.jar index f716a6cb2d90b1b9993b8c7a36f8852f8b3a2155..2a6164af1ee44985975a4a5432173c01e82ec388 100644 GIT binary patch delta 7011 zcmZ8mbzGE9*It&E?yjX93F+=`knRwWmK2xnUZqp11?eu4mhJ`t>5>i!`EY%|?|q(c z??0}Yv)4IuesiChd(N4_HQ<*WAclrAJOVxd1qB7LhpwH3Aq4*il!D65)@m)($BG9@aQTMSTWq zJm49@!RV)`jF7@o90-KK2z&#tEES%mtdL81P7`o(C!&N!W3lA&lVz8W=A9um4>Jub*GS|#hQt0$E zP2Q>p0lpZ@w+^R-2|Jf~zTc-~^)M)u{nUPsvTxAp6eJ`+s+G91Glfb611ZTALDCRwR0sZ4LLe}6P+N>X!2vIWv-isM*A zv#If>UACNV%IX77R)KyE}~eU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Vj`;IcYZVI=X((W;IlOM}*dS05G8@BRV>m?p5t>)iLXk$}FPlR8mykCZo?XrO zNA%b!)T" + "" @@ -102,7 +102,7 @@ class LocalReaderBook extends JPanel { this.setLayout(new BorderLayout(10, 10)); this.add(icon, BorderLayout.CENTER); - this.add(tt, BorderLayout.SOUTH); + this.add(title, BorderLayout.SOUTH); setupListeners(); setSelected(false); @@ -151,14 +151,16 @@ class LocalReaderBook extends JPanel { } public void mouseClicked(MouseEvent e) { - Date now = new Date(); - if (lastClick != null - && now.getTime() - lastClick.getTime() < doubleClickDelay) { - click(true); - } else { - click(false); + if (isEnabled()) { + Date now = new Date(); + if (lastClick != null + && now.getTime() - lastClick.getTime() < doubleClickDelay) { + click(true); + } else { + click(false); + } + lastClick = now; } - lastClick = now; } }); } @@ -199,7 +201,8 @@ class LocalReaderBook extends JPanel { g.fillPolygon(new Polygon(xs, ys, xs.length)); Color color = new Color(255, 255, 255, 0); - if (selected && !hovered) { + if (!isEnabled()) { + } else if (selected && !hovered) { color = new Color(80, 80, 100, 40); } else if (!selected && hovered) { color = new Color(230, 230, 255, 100); diff --git a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java index 670ab679..966869f5 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java @@ -19,12 +19,14 @@ import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; import be.nikiroo.fanfix.Instance; -import be.nikiroo.fanfix.Main; import be.nikiroo.fanfix.bundles.UiConfig; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.reader.LocalReaderBook.BookActionListener; +import be.nikiroo.utils.Progress; +import be.nikiroo.utils.ui.ProgressBar; import be.nikiroo.utils.ui.WrapLayout; class LocalReaderFrame extends JFrame { @@ -35,6 +37,8 @@ class LocalReaderFrame extends JFrame { private JPanel bookPane; private String type; private Color color; + private ProgressBar pgBar; + private JMenuBar bar; public LocalReaderFrame(LocalReader reader, String type) { super("Fanfix Library"); @@ -48,18 +52,7 @@ class LocalReaderFrame extends JFrame { books = new ArrayList(); bookPane = new JPanel(new WrapLayout(WrapLayout.LEADING, 5, 5)); - color = null; - String bg = Instance.getUiConfig().getString(UiConfig.BACKGROUND_COLOR); - if (bg.startsWith("#") && bg.length() == 7) { - try { - color = new Color(Integer.parseInt(bg.substring(1, 3), 16), - Integer.parseInt(bg.substring(3, 5), 16), - Integer.parseInt(bg.substring(5, 7), 16)); - } catch (NumberFormatException e) { - color = null; // no changes - e.printStackTrace(); - } - } + color = Instance.getUiConfig().getColor(UiConfig.BACKGROUND_COLOR); if (color != null) { setBackground(color); @@ -70,6 +63,9 @@ class LocalReaderFrame extends JFrame { scroll.getVerticalScrollBar().setUnitIncrement(16); add(scroll, BorderLayout.CENTER); + pgBar = new ProgressBar(); + add(pgBar, BorderLayout.SOUTH); + refreshBooks(type); setJMenuBar(createMenu()); @@ -97,13 +93,18 @@ class LocalReaderFrame extends JFrame { } public void action(LocalReaderBook book) { - try { - File target = LocalReaderFrame.this.reader.getTarget( - luid, null); - Desktop.getDesktop().browse(target.toURI()); - } catch (IOException e) { - Instance.syserr(e); - } + final Progress pg = new Progress(); + outOfUi(pg, new Runnable() { + public void run() { + try { + File target = LocalReaderFrame.this.reader + .getTarget(luid, pg); + Desktop.getDesktop().browse(target.toURI()); + } catch (IOException e) { + Instance.syserr(e); + } + } + }); } }); @@ -115,26 +116,48 @@ class LocalReaderFrame extends JFrame { } private JMenuBar createMenu() { - JMenuBar bar = new JMenuBar(); + bar = new JMenuBar(); JMenu file = new JMenu("File"); JMenuItem imprt = new JMenuItem("Import", KeyEvent.VK_I); imprt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - String url = JOptionPane.showInputDialog(LocalReaderFrame.this, - "url of the story to import?\n" + "\n" - + "Note: it will currently make the UI \n" - + "unresponsive until it is downloaded...", + final String url = JOptionPane.showInputDialog( + LocalReaderFrame.this, "url of the story to import?", "Importing from URL", JOptionPane.QUESTION_MESSAGE); if (url != null && !url.isEmpty()) { - if (Main.imprt(url, null) != 0) { - JOptionPane.showMessageDialog(LocalReaderFrame.this, - "Cannot import: " + url, "Imort error", - JOptionPane.ERROR_MESSAGE); - } else { - refreshBooks(type); - } + final Progress pg = new Progress("Importing " + url); + outOfUi(pg, new Runnable() { + public void run() { + Exception ex = null; + try { + Instance.getLibrary().imprt( + BasicReader.getUrl(url), pg); + } catch (IOException e) { + ex = e; + } + + final Exception e = ex; + + final boolean ok = (e == null); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + if (!ok) { + JOptionPane.showMessageDialog( + LocalReaderFrame.this, + "Cannot import: " + url, + e.getMessage(), + JOptionPane.ERROR_MESSAGE); + + setAllEnabled(true); + } else { + refreshBooks(type); + } + } + }); + } + }); } } }); @@ -167,4 +190,44 @@ class LocalReaderFrame extends JFrame { return bar; } + + private void outOfUi(final Progress pg, final Runnable run) { + pgBar.setProgress(pg); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + setAllEnabled(false); + pgBar.addActioListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + pgBar.setProgress(null); + setAllEnabled(true); + } + }); + } + }); + + new Thread(new Runnable() { + public void run() { + run.run(); + if (!pg.isDone()) { + pg.setProgress(pg.getMax()); + } + } + }).start(); + } + + public void setAllEnabled(boolean enabled) { + for (LocalReaderBook book : books) { + book.setEnabled(enabled); + book.validate(); + book.repaint(); + } + bar.setEnabled(enabled); + bookPane.setEnabled(enabled); + bookPane.validate(); + bookPane.repaint(); + setEnabled(enabled); + validate(); + repaint(); + } } diff --git a/src/be/nikiroo/fanfix/supported/BasicSupport.java b/src/be/nikiroo/fanfix/supported/BasicSupport.java index c47d05e6..be198416 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupport.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupport.java @@ -23,8 +23,8 @@ import be.nikiroo.fanfix.data.Paragraph; import be.nikiroo.fanfix.data.Paragraph.ParagraphType; import be.nikiroo.fanfix.data.Story; import be.nikiroo.utils.IOUtils; +import be.nikiroo.utils.Progress; import be.nikiroo.utils.StringUtils; -import be.nikiroo.utils.ui.Progress; /** * This class is the base class used by the other support classes. It can be @@ -377,8 +377,7 @@ public abstract class BasicSupport { chapIn.close(); } - pgChaps.setProgress(i); - i++; + pgChaps.setProgress(i++); } } else { pg.setProgress(100); diff --git a/src/be/nikiroo/fanfix/supported/Cbz.java b/src/be/nikiroo/fanfix/supported/Cbz.java index 295dc15a..b63ec5d4 100644 --- a/src/be/nikiroo/fanfix/supported/Cbz.java +++ b/src/be/nikiroo/fanfix/supported/Cbz.java @@ -14,7 +14,7 @@ import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.Paragraph; import be.nikiroo.fanfix.data.Story; -import be.nikiroo.utils.ui.Progress; +import be.nikiroo.utils.Progress; /** * Support class for CBZ files (works better with CBZ created with this program, diff --git a/src/be/nikiroo/fanfix/supported/E621.java b/src/be/nikiroo/fanfix/supported/E621.java index 5ebd6b31..cde7f0a4 100644 --- a/src/be/nikiroo/fanfix/supported/E621.java +++ b/src/be/nikiroo/fanfix/supported/E621.java @@ -13,8 +13,8 @@ import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Story; +import be.nikiroo.utils.Progress; import be.nikiroo.utils.StringUtils; -import be.nikiroo.utils.ui.Progress; /** * Support class for e621.net and