.getFavoritesContainingProgram(mProgram);
boolean hasFavorites = favorites != null && favorites.length > 0;
mHighlight.setEnabled(hasFavorites);
Highlighter highlighter = mInfoEP.getHighlighter();
HTMLDocument document = (HTMLDocument) mInfoEP.getDocument();
highlighter.removeAllHighlights();
if (!hasFavorites
|| !ProgramInfo.getInstance().getSettings().getHighlightFavorite()) {
return;
}
DefaultHighlightPainter painter = new DefaultHighlightPainter(ProgramInfo
.getInstance().getSettings().getHighlightColor());
for (Favorite favorite : favorites) {
ProgramSearcher searcher = null;
try {
searcher = favorite.getSearcher();
} catch (TvBrowserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (searcher instanceof RegexSearcher) {
Pattern pattern = ((RegexSearcher) searcher).getPattern();
if (pattern != null) {
if (pattern.pattern().startsWith(".*")) {
pattern = Pattern.compile(pattern.pattern().substring(2));
}
if (pattern.pattern().endsWith(".*")) {
pattern = Pattern.compile(pattern.pattern().substring(0,
pattern.pattern().length() - 2));
}
for (HTMLDocument.Iterator it = document
.getIterator(HTML.Tag.CONTENT); it.isValid(); it.next()) {
try {
String fragment = document.getText(it.getStartOffset(), it
.getEndOffset()
- it.getStartOffset());
Matcher matcher = pattern.matcher(fragment);
while (matcher.find()) {
highlighter.addHighlight(it.getStartOffset() + matcher.start(),