From f76de46507bf17695ce3c6e3a4b1b698d3182ebd Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sat, 13 Apr 2019 13:43:00 +0200 Subject: [PATCH] add sync option to search --- src/be/nikiroo/fanfix/Main.java | 4 ++-- src/be/nikiroo/fanfix/reader/Reader.java | 12 +++++++--- .../nikiroo/fanfix/reader/cli/CliReader.java | 6 ++--- .../nikiroo/fanfix/reader/tui/TuiReader.java | 22 ++++++++++++------- .../reader/tui/TuiReaderApplication.java | 9 ++++---- .../nikiroo/fanfix/reader/ui/GuiReader.java | 17 +++++++++----- .../fanfix/reader/ui/GuiReaderFrame.java | 2 +- 7 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/be/nikiroo/fanfix/Main.java b/src/be/nikiroo/fanfix/Main.java index 6fc49c5..2437cae 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 fa170e4..bd13e5c 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 6d98418..bce2e2a 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 cc39dcd..640d628 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 85b1abc..6b8ce2b 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 2a4d7a9..6c3a35e 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 77cd7e0..dd192fb 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); -- 2.27.0