X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FLocalReaderFrame.java;h=4e8d9ace0f801b45f3089152c534a45dc6ef3aaa;hp=7ce16cc48a8bc487c9ccfa7e5c37479b850f010d;hb=5130ce84f2b7fce5b451aed15fdaa12bc663331f;hpb=2284842831ea46e89b97dd22b6e294caad361f30 diff --git a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java index 7ce16cc..4e8d9ac 100644 --- a/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/LocalReaderFrame.java @@ -3,6 +3,8 @@ package be.nikiroo.fanfix.reader; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Frame; +import java.awt.Toolkit; +import java.awt.datatransfer.DataFlavor; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -38,6 +40,7 @@ import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.output.BasicOutput.OutputType; import be.nikiroo.fanfix.reader.LocalReaderBook.BookActionListener; import be.nikiroo.utils.Progress; +import be.nikiroo.utils.Version; import be.nikiroo.utils.ui.ProgressBar; import be.nikiroo.utils.ui.WrapLayout; @@ -71,7 +74,7 @@ class LocalReaderFrame extends JFrame { * the type of {@link Story} to load, or NULL for all types */ public LocalReaderFrame(LocalReader reader, String type) { - super("Fanfix Library"); + super(String.format("Fanfix %s Library", Version.getCurrentVersion())); this.reader = reader; @@ -450,15 +453,11 @@ class LocalReaderFrame extends JFrame { private void outOfUi(final Progress pg, final Runnable run) { pgBar.setProgress(pg); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - setEnabled(false); - pgBar.addActioListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - pgBar.setProgress(null); - setEnabled(true); - } - }); + setEnabled(false); + pgBar.addActioListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + pgBar.setProgress(null); + setEnabled(true); } }); @@ -489,19 +488,32 @@ class LocalReaderFrame extends JFrame { private void imprt(boolean askUrl) { JFileChooser fc = new JFileChooser(); - String url; + Object url; if (askUrl) { + String clipboard = ""; + try { + clipboard = ("" + Toolkit.getDefaultToolkit() + .getSystemClipboard().getData(DataFlavor.stringFlavor)) + .trim(); + } catch (Exception e) { + // No data will be handled + } + + if (clipboard == null || !clipboard.startsWith("http")) { + clipboard = ""; + } + url = JOptionPane.showInputDialog(LocalReaderFrame.this, "url of the story to import?", "Importing from URL", - JOptionPane.QUESTION_MESSAGE); + JOptionPane.QUESTION_MESSAGE, null, null, clipboard); } else if (fc.showOpenDialog(this) != JFileChooser.CANCEL_OPTION) { url = fc.getSelectedFile().getAbsolutePath(); } else { url = null; } - if (url != null && !url.isEmpty()) { - imprt(url, null); + if (url != null && !url.toString().isEmpty()) { + imprt(url.toString(), null); } } @@ -532,6 +544,7 @@ class LocalReaderFrame extends JFrame { SwingUtilities.invokeLater(new Runnable() { public void run() { if (!ok) { + Instance.syserr(e); JOptionPane.showMessageDialog( LocalReaderFrame.this, "Cannot import: " + url, e.getMessage(),