cnode = (CategoryNode)n;
else // patternnode
cnode = (CategoryNode)n.getParent();
final CategoryNode catnode = cnode;
TaskWorker tworker = new TaskWorker(yoshikoder){
YKDictionaryReportDialog dia;
Map<YKDocument,EntryFrequencyMap> efmMap;
protected void doWork() throws Exception {
EntryFrequencyMap efm = null;
for (YKDocument doc : concmap.keySet()) {
TokenList tlist = new TokenListImpl();
Concordance conc = concmap.get(doc);
for (Iterator iter = conc.iterator(); iter.hasNext();) {
ConcordanceLine line = (ConcordanceLine) iter.next();
for (Iterator iterator = line.getLeftHandSide().iterator(); iterator.hasNext();) {
Token token = (Token) iterator.next();
tlist.add(token);
}
for (Iterator iterator = line.getRightHandSide().iterator(); iterator.hasNext();) {
Token token = (Token) iterator.next();
tlist.add(token);
}
}
efm = new EntryFrequencyMap(yoshikoder.getDictionary(), tlist);
efmMap.put(doc, efm);
}
// FIXME use efmMap in the report, not the most recent one!
YKDocument fake =
YKDocumentFactory.createDummyDocument("Concordance", "none", "UTF-8");
DictionaryFrequencyReport reportcatsonly =
new DictionaryFrequencyReport("Concordance Report",
catnode.getName() + " applied to current concordance",
yoshikoder.getDictionary().getName(),
fake, efm, false);
DictionaryFrequencyReport reportcatsandpats =
new DictionaryFrequencyReport("Concordance Report",
catnode.getName() + "applied to current concordance",
yoshikoder.getDictionary().getName(),
fake, efm, true);
dia = new YKDictionaryReportDialog(yoshikoder, reportcatsonly, reportcatsandpats, onlyShowCats);
}
protected void onSuccess() {
dia.setVisible(true);
onlyShowCats = !dia.getCurrentReport().getShowPatterns();
}
protected void onError() {
if (e instanceof TokenizationException){
DialogUtil.yelp(yoshikoder, "Tokenization Error", e);
} else if (e instanceof IOException){
DialogUtil.yelp(yoshikoder, "Input/Ouput Error", e);
} else {
DialogUtil.yelp(yoshikoder, "Error", e);
}
}
};
tworker.start();
}