X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FGuiReader.java;h=2f1b33961329179253fa6049ccaded8f3d774f11;hb=34eb62fc14c1f4db29e65ceb6b190811380aba7e;hp=cdf80d0c9fda7b3d02b0d4b7d045a011f877b551;hpb=5dd985cf7d5e2bb88b07fd43e7b4a4eda4647181;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/reader/GuiReader.java b/src/be/nikiroo/fanfix/reader/GuiReader.java index cdf80d0..2f1b339 100644 --- a/src/be/nikiroo/fanfix/reader/GuiReader.java +++ b/src/be/nikiroo/fanfix/reader/GuiReader.java @@ -13,10 +13,11 @@ import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import be.nikiroo.fanfix.Instance; -import be.nikiroo.fanfix.LocalLibrary; import be.nikiroo.fanfix.VersionCheck; import be.nikiroo.fanfix.bundles.UiConfig; +import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Story; +import be.nikiroo.fanfix.library.LocalLibrary; import be.nikiroo.fanfix.output.BasicOutput.OutputType; import be.nikiroo.utils.Progress; import be.nikiroo.utils.Version; @@ -71,17 +72,13 @@ class GuiReader extends BasicReader { @Override public void read() throws IOException { - if (getStory() == null) { + MetaData meta = getMeta(); + + if (meta == null) { throw new IOException("No story to read"); } - open(getStory().getMeta().getLuid(), null); - } - - @Override - public void read(int chapter) throws IOException { - // TODO: show a special page? - read(); + read(meta.getLuid(), null); } /** @@ -105,7 +102,7 @@ class GuiReader extends BasicReader { } try { - Story story = Instance.getLibrary().getStory(luid, pgGetStory); + Story story = getLibrary().getStory(luid, pgGetStory); if (story != null) { story = localLibrary.save(story, luid, pgSave); } else { @@ -159,6 +156,7 @@ class GuiReader extends BasicReader { // handle link events updateMessage.addHyperlinkListener(new HyperlinkListener() { + @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals( HyperlinkEvent.EventType.ACTIVATED)) @@ -177,6 +175,7 @@ class GuiReader extends BasicReader { final String typeFinal = type; EventQueue.invokeLater(new Runnable() { + @Override public void run() { if (updates.isNewVersionAvailable()) { int rep = JOptionPane.showConfirmDialog(null, @@ -189,8 +188,7 @@ class GuiReader extends BasicReader { } } - new GuiReaderFrame(GuiReader.this, typeFinal) - .setVisible(true); + new GuiReaderFrame(GuiReader.this, typeFinal).setVisible(true); } }); } @@ -208,27 +206,30 @@ class GuiReader extends BasicReader { void delete(String luid) { try { localLibrary.delete(luid); - Instance.getLibrary().delete(luid); + getLibrary().delete(luid); } catch (IOException e) { Instance.syserr(e); } } // open the given book - void open(String luid, Progress pg) throws IOException { + void read(String luid, Progress pg) throws IOException { File file = localLibrary.getFile(luid); if (file == null) { imprt(luid, pg); file = localLibrary.getFile(luid); } - open(getLibrary().getInfo(luid), file); + // TODO: show a special page for the chapter? + openExternal(getLibrary().getInfo(luid), file); } - void changeType(String luid, String newType) { + void changeType(String luid, String newSource) { try { - localLibrary.changeSource(luid, newType, null); - Instance.getLibrary().changeSource(luid, newType, null); + if (localLibrary.getInfo(luid) != null) { + localLibrary.changeSource(luid, newSource, null); + } + getLibrary().changeSource(luid, newSource, null); } catch (IOException e) { Instance.syserr(e); }