add sync option to search
authorNiki Roo <niki@nikiroo.be>
Sat, 13 Apr 2019 11:43:00 +0000 (13:43 +0200)
committerNiki Roo <niki@nikiroo.be>
Sat, 13 Apr 2019 11:43:00 +0000 (13:43 +0200)
src/be/nikiroo/fanfix/Main.java
src/be/nikiroo/fanfix/reader/Reader.java
src/be/nikiroo/fanfix/reader/cli/CliReader.java
src/be/nikiroo/fanfix/reader/tui/TuiReader.java
src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java
src/be/nikiroo/fanfix/reader/ui/GuiReader.java
src/be/nikiroo/fanfix/reader/ui/GuiReaderFrame.java

index 6fc49c549764cbba0a7439086c49e79e981af3ad..2437cae567310700509c7c9a08a0a59212c7b1ec 100644 (file)
@@ -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);
                                }
index fa170e44fcc64a3233ec2c09cba93fb31e84cb07..bd13e5cb8c032e6866b72c30693d625eae0815e1 100644 (file)
@@ -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 <b>start at 1</b>)
+        * @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
         *            <b>hierarchy</b>, <b>NOT</b> 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
index 6d9841830982533247e20dfcc8c5f2b9461a61af..bce2e2a456c09c1d3650fe01c7d5bb618273ee43 100644 (file)
@@ -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<SearchableTag> stags = search.getTags();
                String fqnTag = "";
index cc39dcde77e7173229c5cd597942e36721e6462b..640d628b3e32305a36089f6cfa25ed236dc7d83a 100644 (file)
@@ -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.");
+               }
        }
 }
index 85b1abcfb44f7af7419b757f21865b3f4ed8c3d2..6b8ce2b077b88eddfbb6c513343bfabad98508d7 100644 (file)
@@ -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);
        }
 
        /**
index 2a4d7a942d4f67c5e7dd50553bb5ac9ba39de8f0..6c3a35e5198827c603393f4c5c77d5bea9f3b6d9 100644 (file)
@@ -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.");
+               }
        }
 
        /**
index 77cd7e019ef4363113e7605330c7ae82386fea7a..dd192fb070b96ac391e9ba6677421869766aeddb 100644 (file)
@@ -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);