}
}
@Override
public void valueChanged(ListSelectionEvent e) {
SearchResult result = null;
Document doc = staCode.getDocument();
boolean firstRun = true;
int offset = 0;
String linePrefix = "";
if (taResults.getSelectedRow() >= resultModel.getRowCount() || taResults.getSelectedRow() < 0) {
return;
}
result = resultModel.get(taResults.getSelectedRow());
staCode.setSyntaxEditingStyle(result.getSyntaxStyle());
try {
resetSyntaxTable();
for (LineMatch match : result.getMatches()) {
for (Line line : match.getLines()) {
offset = firstRun ? doc.getStartPosition().getOffset() : doc.getEndPosition().getOffset();
linePrefix = firstRun ? "" : "\n";
doc.insertString(offset,
String.format("%-5d\t", line.getLineNumber()) + line.getLine() + linePrefix, null);
firstRun = false;
}
//Add Separator
if (result.getMatchCount() > 1) //if more than one matches
{
String matchSeparator = "";
offset = firstRun ? doc.getStartPosition().getOffset() : doc.getEndPosition().getOffset();
linePrefix = firstRun ? "" : "\n";