X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Ftui%2FTuiReaderApplication.java;h=b6f31ff4e9b43b98e4fadf3bc655b66f02225fa4;hb=1feb447473d8176c3a218cc209c681fb41d468d1;hp=8cd5c0b90ce99ed820ba16725e45fb9ced3530ad;hpb=cd6b47c9288524cde80df6e90843293b2fe0677d;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java b/src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java index 8cd5c0b..b6f31ff 100644 --- a/src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java +++ b/src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java @@ -25,6 +25,7 @@ import be.nikiroo.fanfix.library.BasicLibrary; import be.nikiroo.fanfix.reader.BasicReader; import be.nikiroo.fanfix.reader.Reader; import be.nikiroo.fanfix.reader.tui.TuiReaderMainWindow.Mode; +import be.nikiroo.fanfix.supported.SupportType; import be.nikiroo.utils.Progress; /** @@ -56,9 +57,8 @@ class TuiReaderApplication extends TApplication implements Reader { super(backend); init(reader); - MetaData meta = getMeta(); - if (meta != null) { - read(); + if (getMeta() != null) { + read(false); } } @@ -72,8 +72,8 @@ class TuiReaderApplication extends TApplication implements Reader { } @Override - public void read() throws IOException { - read(getStory(null)); + public void read(boolean sync) throws IOException { + read(getStory(null), sync); } @Override @@ -82,7 +82,7 @@ class TuiReaderApplication extends TApplication implements Reader { } @Override - public Story getStory(Progress pg) { + public Story getStory(Progress pg) throws IOException { return reader.getStory(pg); } @@ -113,7 +113,11 @@ class TuiReaderApplication extends TApplication implements Reader { @Override public void browse(String source) { - reader.browse(source); + try { + reader.browse(source); + } catch (IOException e) { + Instance.getTraceHandler().error(e); + } } @Override @@ -126,7 +130,37 @@ class TuiReaderApplication extends TApplication implements Reader { reader.setChapter(chapter); } - public void read(Story story) throws IOException { + @Override + public void search(boolean sync) throws IOException { + reader.search(sync); + } + + @Override + public void search(SupportType searchOn, String keywords, int page, + int item, boolean sync) throws IOException { + reader.search(searchOn, keywords, page, item, sync); + } + + @Override + public void searchTag(SupportType searchOn, int page, int item, + boolean sync, Integer... tags) throws IOException { + reader.searchTag(searchOn, page, item, sync, tags); + } + + /** + * Open the given {@link Story} for reading. This may or may not start an + * external program to read said {@link Story}. + * + * @param story + * the {@link Story} to read + * @param sync + * execute the process synchronously (wait until it is terminated + * before returning) + * + * @throws IOException + * in case of I/O errors + */ + public void read(Story story, boolean sync) throws IOException { if (story == null) { throw new IOException("No story to read"); } @@ -137,7 +171,7 @@ class TuiReaderApplication extends TApplication implements Reader { window.maximize(); } else { try { - openExternal(getLibrary(), story.getMeta().getLuid()); + openExternal(getLibrary(), story.getMeta().getLuid(), sync); } catch (IOException e) { messageBox("Error when trying to open the story", e.getMessage(), TMessageBox.Type.OK); @@ -230,7 +264,7 @@ class TuiReaderApplication extends TApplication implements Reader { try { openfile = fileOpenBox("."); reader.setMeta(BasicReader.getUrl(openfile), null); - read(); + read(false); } catch (IOException e) { // TODO: i18n error("Fail to open file" @@ -342,8 +376,9 @@ class TuiReaderApplication extends TApplication implements Reader { } @Override - public void openExternal(BasicLibrary lib, String luid) throws IOException { - reader.openExternal(lib, luid); + public void openExternal(BasicLibrary lib, String luid, boolean sync) + throws IOException { + reader.openExternal(lib, luid, sync); } /**