X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Fui%2FGuiReader.java;h=0205e11489ba783b85102781c93d7932207489eb;hb=a67248cf983a1370625887c82ed7524e95b56dd1;hp=2ca61919cc5adb1aa714f3618e38e7b7f3f85bfb;hpb=7879b47fdbdcaf465327bcbee53a7e31331feb97;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReader.java b/src/be/nikiroo/fanfix/reader/ui/GuiReader.java index 2ca6191..0205e11 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReader.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReader.java @@ -25,6 +25,8 @@ import be.nikiroo.fanfix.library.BasicLibrary; import be.nikiroo.fanfix.library.CacheLibrary; import be.nikiroo.fanfix.reader.BasicReader; import be.nikiroo.fanfix.reader.Reader; +import be.nikiroo.fanfix.searchable.BasicSearchable; +import be.nikiroo.fanfix.searchable.SearchableTag; import be.nikiroo.fanfix.supported.SupportType; import be.nikiroo.utils.Progress; import be.nikiroo.utils.Version; @@ -218,17 +220,63 @@ class GuiReader extends BasicReader { super.start(target, program, sync); } } - + @Override - public void search(SupportType searchOn, String keywords, int page, int item) { - // TODO: !!! - throw new java.lang.IllegalStateException("Not implemented yet."); + public void search(boolean sync) throws IOException { + GuiReaderSearchFrame search = new GuiReaderSearchFrame(this); + if (sync) { + sync(search); + } else { + search.setVisible(true); + } } - + + @Override + public void search(SupportType searchOn, String keywords, int page, + int item, boolean sync) { + GuiReaderSearchFrame search = new GuiReaderSearchFrame(this); + search.search(searchOn, keywords, page, item); + if (sync) { + sync(search); + } else { + search.setVisible(true); + } + } + @Override - public void searchTag(SupportType searchOn, int page, int item, String... tags) { - // TODO: !!! - throw new java.lang.IllegalStateException("Not implemented yet."); + public void searchTag(final SupportType searchOn, final int page, + final int item, final boolean sync, final Integer... tags) { + + final GuiReaderSearchFrame search = new GuiReaderSearchFrame(this); + + final BasicSearchable searchable = BasicSearchable + .getSearchable(searchOn); + + Runnable action = new Runnable() { + @Override + public void run() { + SearchableTag tag = null; + try { + tag = searchable.getTag(tags); + } catch (IOException e) { + Instance.getTraceHandler().error(e); + } + + search.searchTag(searchOn, page, item, tag); + + if (sync) { + sync(search); + } else { + search.setVisible(true); + } + } + }; + + if (sync) { + action.run(); + } else { + new Thread(action).start(); + } } /** @@ -269,8 +317,6 @@ class GuiReader extends BasicReader { /** * "Open" the given {@link Story}. It usually involves starting an external * program adapted to the given file type. - *
- * Asynchronous method. * * @param luid * the luid of the {@link Story} to open @@ -314,6 +360,24 @@ class GuiReader extends BasicReader { } } + + /** + * "Prefetch" the given {@link Story}. + *
+ * Synchronous method. + * + * @param luid + * the luid of the {@link Story} to prefetch + * @param pg + * the optional progress (we may need to prepare the + * {@link Story} for reading + * + * @throws IOException + * in case of I/O errors + */ + void prefetch(String luid, Progress pg) throws IOException { + cacheLib.getFile(luid, pg); + } /** * Change the source of the given {@link Story} (the source is the main * information used to group the stories together).