X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Fui%2FGuiReader.java;h=0205e11489ba783b85102781c93d7932207489eb;hb=c4cefaa04ec122fc02efb6542451a31fdf722c32;hp=f4a932b3b899ef3fc48826bbe0b3aaa913a68d90;hpb=5bc9573be46f09ac92207e104915bd5babbd6d63;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReader.java b/src/be/nikiroo/fanfix/reader/ui/GuiReader.java index f4a932b..0205e11 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReader.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReader.java @@ -25,6 +25,9 @@ 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; import be.nikiroo.utils.ui.UIUtils; @@ -218,6 +221,64 @@ class GuiReader extends BasicReader { } } + @Override + 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(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(); + } + } + /** * Delete the {@link Story} from the cache if it is present, but NOT * from the main library. @@ -256,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 @@ -301,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).