From: Niki Roo Date: Sat, 13 Apr 2019 11:43:00 +0000 (+0200) Subject: add sync option to search X-Git-Tag: fanfix-swing-0.0.1~12^2~159 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=f76de46507bf17695ce3c6e3a4b1b698d3182ebd;p=fanfix-swing.git add sync option to search --- diff --git a/src/be/nikiroo/fanfix/Main.java b/src/be/nikiroo/fanfix/Main.java index 6fc49c54..2437cae5 100644 --- a/src/be/nikiroo/fanfix/Main.java +++ b/src/be/nikiroo/fanfix/Main.java @@ -501,7 +501,7 @@ public class Main { } else { try { BasicReader.getReader().search(searchOn, search, page, - item); + item, true); } catch (IOException e1) { Instance.getTraceHandler().error(e1); } @@ -538,7 +538,7 @@ public class Main { try { BasicReader.getReader().searchTag(searchOn, page, item, - tags.toArray(new Integer[] {})); + true, tags.toArray(new Integer[] {})); } catch (IOException e1) { Instance.getTraceHandler().error(e1); } diff --git a/src/be/nikiroo/fanfix/reader/Reader.java b/src/be/nikiroo/fanfix/reader/Reader.java index fa170e44..bd13e5cb 100644 --- a/src/be/nikiroo/fanfix/reader/Reader.java +++ b/src/be/nikiroo/fanfix/reader/Reader.java @@ -183,12 +183,15 @@ public interface Reader { * @param item * the item to select (0 = do not select a specific item but show * all the page, items start at 1) + * @param sync + * execute the process synchronously (wait until it is terminated + * before returning) * * @throws IOException * in case of I/O error */ - public void search(SupportType searchOn, String keywords, int page, int item) - throws IOException; + public void search(SupportType searchOn, String keywords, int page, + int item, boolean sync) throws IOException; /** * Search based upon a hierarchy of tags, or search for (sub)tags. @@ -212,6 +215,9 @@ public interface Reader { * @param item * the item to select (0 = do not select a specific item but show * all the page, items start at 1) + * @param sync + * execute the process synchronously (wait until it is terminated + * before returning) * @param tags * the tags indices to search for (this is a tag * hierarchy, NOT a multiple tags choice) @@ -220,7 +226,7 @@ public interface Reader { * in case of I/O error */ public void searchTag(SupportType searchOn, int page, int item, - Integer... tags) throws IOException; + boolean sync, Integer... tags) throws IOException; /** * Open the {@link Story} with an external reader (the program should be diff --git a/src/be/nikiroo/fanfix/reader/cli/CliReader.java b/src/be/nikiroo/fanfix/reader/cli/CliReader.java index 6d984183..bce2e2a4 100644 --- a/src/be/nikiroo/fanfix/reader/cli/CliReader.java +++ b/src/be/nikiroo/fanfix/reader/cli/CliReader.java @@ -102,14 +102,14 @@ class CliReader extends BasicReader { } @Override - public void search(SupportType searchOn, String keywords, int page, int item) - throws IOException { + public void search(SupportType searchOn, String keywords, int page, + int item, boolean sync) throws IOException { } @Override public void searchTag(SupportType searchOn, int page, int item, - Integer... tags) throws IOException { + boolean sync, Integer... tags) throws IOException { BasicSearchable search = BasicSearchable.getSearchable(searchOn); List stags = search.getTags(); String fqnTag = ""; diff --git a/src/be/nikiroo/fanfix/reader/tui/TuiReader.java b/src/be/nikiroo/fanfix/reader/tui/TuiReader.java index cc39dcde..640d628b 100644 --- a/src/be/nikiroo/fanfix/reader/tui/TuiReader.java +++ b/src/be/nikiroo/fanfix/reader/tui/TuiReader.java @@ -71,16 +71,22 @@ class TuiReader extends BasicReader { Instance.getTraceHandler().error(e); } } - + @Override - public void search(SupportType searchOn, String keywords, int page, int item) { - // TODO: !!! - throw new java.lang.IllegalStateException("Not implemented yet."); + public void search(SupportType searchOn, String keywords, int page, + int item, boolean sync) { + // TODO + if (sync) { + throw new java.lang.IllegalStateException("Not implemented yet."); + } } - + @Override - public void searchTag(SupportType searchOn, int page, int item, String... tags) { - // TODO: !!! - throw new java.lang.IllegalStateException("Not implemented yet."); + public void searchTag(SupportType searchOn, int page, int item, + boolean sync, Integer... tags) { + // TODO + if (sync) { + throw new java.lang.IllegalStateException("Not implemented yet."); + } } } diff --git a/src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java b/src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java index 85b1abcf..6b8ce2b0 100644 --- a/src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java +++ b/src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java @@ -127,14 +127,15 @@ class TuiReaderApplication extends TApplication implements Reader { } @Override - public void search(SupportType searchOn, String keywords, int page, int item) throws IOException { - reader.search(searchOn, keywords, page, item); + 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, - Integer... tags) throws IOException { - reader.searchTag(searchOn, page, item, tags); + boolean sync, Integer... tags) throws IOException { + reader.searchTag(searchOn, page, item, sync, tags); } /** diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReader.java b/src/be/nikiroo/fanfix/reader/ui/GuiReader.java index 2a4d7a94..6c3a35e5 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReader.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReader.java @@ -220,16 +220,21 @@ class GuiReader extends BasicReader { } @Override - public void search(SupportType searchOn, String keywords, int page, int item) { - // TODO: !!! - throw new java.lang.IllegalStateException("Not implemented yet."); + public void search(SupportType searchOn, String keywords, int page, + int item, boolean sync) { + // TODO + if (sync) { + throw new java.lang.IllegalStateException("Not implemented yet."); + } } @Override public void searchTag(SupportType searchOn, int page, int item, - Integer... tags) { - // TODO: !!! - throw new java.lang.IllegalStateException("Not implemented yet."); + boolean sync, Integer... tags) { + // TODO + if (sync) { + throw new java.lang.IllegalStateException("Not implemented yet."); + } } /** diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java index 77cd7e01..dd192fb0 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java @@ -192,7 +192,7 @@ class GuiReaderFrame extends JFrame implements FrameHelper { searchItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - reader.search(type, "", 1, 0); + reader.search(type, "", 1, 0, false); } }); search.add(searchItem);