Iterator<DataSearchResultMatch> matches = searchResult.getMatches(cell);
if (matches != null) {
int lastEndOffset = 0;
SimpleTextAttributes searchResultAttributes = configTextAttributes.getSearchResult();
DataSearchResultMatch selectedMatch = searchResult.getSelectedMatch();
if (selectedMatch != null && selectedMatch.getCell() == cell) {
searchResultAttributes = configTextAttributes.getSelection();
}
int valueLength = formattedUserValue.length();
int lastOffset = Math.max(0, valueLength);
while (matches.hasNext()) {
DataSearchResultMatch match = matches.next();
if (match.getStartOffset() > lastEndOffset) {
int startOffset = Math.min(lastOffset, lastEndOffset);
int endOffset = Math.min(lastOffset, match.getStartOffset());
append(formattedUserValue.substring(startOffset, endOffset), textAttributes);
}
int startOffset = Math.min(lastOffset, match.getStartOffset());
int endOffset = Math.min(lastOffset, match.getEndOffset());
append(formattedUserValue.substring(startOffset, endOffset), searchResultAttributes);
lastEndOffset = match.getEndOffset();
}
if (lastEndOffset < valueLength) {
append(formattedUserValue.substring(lastEndOffset), textAttributes);
}