private List<MetaData> stories = new ArrayList<MetaData>();
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;
submitKeywords.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- search(keywordsField.getText(), 0);
+ search(keywordsField.getText(), 0, null);
}
});
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;
}
return storyItem;
}
- private void fireAction() {
+ private void fireAction(final Runnable inUi) {
GuiReaderSearchFrame.inUi(new Runnable() {
@Override
public void run() {
GuiReaderSearchFrame.error(e);
}
}
+
+ if (inUi != null) {
+ inUi.run();
+ }
}
});
}
stories = new ArrayList<MetaData>();
}
- fireAction();
+ fireAction(null);
}
}
}).start();
// 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<MetaData> stories = new ArrayList<MetaData>();
int storyItem = 0;
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<MetaData> stories = new ArrayList<MetaData>();
int storyItem = 0;
this.stories = stories;
this.storyItem = storyItem;
- fireAction();
+ fireAction(inUi);
return maxPage;
}