X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Fui%2FGuiReaderSearchByNamePanel.java;h=a627d3a9e0b65c70c1abccad31bbc5b28c341e82;hp=625dc93e2d4c9fd84d364994a9093f1f57b315c1;hb=ce5a42e7154962bd11539d3bd62821881b734821;hpb=2f1e78931b11c6372a535671105896b94d6b19ba diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderSearchByNamePanel.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderSearchByNamePanel.java index 625dc93..a627d3a 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderSearchByNamePanel.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderSearchByNamePanel.java @@ -54,10 +54,12 @@ public class GuiReaderSearchByNamePanel extends JPanel { private List stories = new ArrayList(); private int storyItem; - // will throw illegalArgEx if bad support type + // will throw illegalArgEx if bad support type, NULL allowed public GuiReaderSearchByNamePanel(SupportType supportType) { setLayout(new BorderLayout()); + // TODO: check if null really is OK for supportType (must be) + setSupportType(supportType); page = 1; searchByTags = false; @@ -83,7 +85,7 @@ public class GuiReaderSearchByNamePanel extends JPanel { submitKeywords.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - search(keywordsField.getText(), 0); + search(keywordsField.getText(), 0, null); } }); @@ -107,11 +109,14 @@ public class GuiReaderSearchByNamePanel extends JPanel { public void setSupportType(SupportType supportType) { BasicSearchable searchable = BasicSearchable.getSearchable(supportType); - if (searchable == null) { + if (searchable == null && supportType != null) { throw new java.lang.IllegalArgumentException( "Unupported support type: " + supportType); } + // TODO: if <>, reset all + // if new, set the base tags + this.supportType = supportType; this.searchable = searchable; } @@ -144,7 +149,7 @@ public class GuiReaderSearchByNamePanel extends JPanel { return storyItem; } - private void fireAction() { + private void fireAction(final Runnable inUi) { GuiReaderSearchFrame.inUi(new Runnable() { @Override public void run() { @@ -164,6 +169,10 @@ public class GuiReaderSearchByNamePanel extends JPanel { GuiReaderSearchFrame.error(e); } } + + if (inUi != null) { + inUi.run(); + } } }); } @@ -329,7 +338,7 @@ public class GuiReaderSearchByNamePanel extends JPanel { stories = new ArrayList(); } - fireAction(); + fireAction(null); } } }).start(); @@ -367,7 +376,7 @@ public class GuiReaderSearchByNamePanel extends JPanel { // item 0 = no selection, else = default selection // return: maxpage - public int search(String keywords, int item) { + public int search(String keywords, int item, Runnable inUi) { List stories = new ArrayList(); int storyItem = 0; @@ -400,14 +409,14 @@ public class GuiReaderSearchByNamePanel extends JPanel { this.stories = stories; this.storyItem = storyItem; - fireAction(); + fireAction(inUi); return maxPage; } // tag: null = base tags // return: max pages - public int searchTag(SearchableTag tag, int item) { + public int searchTag(SearchableTag tag, int item, Runnable inUi) { List stories = new ArrayList(); int storyItem = 0; @@ -461,7 +470,7 @@ public class GuiReaderSearchByNamePanel extends JPanel { this.stories = stories; this.storyItem = storyItem; - fireAction(); + fireAction(inUi); return maxPage; }