if (element instanceof String) {
return new StyledString((String) element);
}
if (element instanceof Hit) {
Hit hit = (Hit) element;
StyledString result = new StyledString();
StyledString.Styler courierNewSmall = new StyledString.Styler() {
@Override
public void applyStyles(TextStyle textStyle) {
textStyle.font = new Font(null, "Courier New",
defaultFont.getHeight() - 1, SWT.NORMAL);
}
};
StyledString.Styler courierNew = new StyledString.Styler() {
@Override
public void applyStyles(TextStyle textStyle) {
textStyle.font = new Font(null, "Courier New",
defaultFont.getHeight(), SWT.NORMAL);
}
};
StyledString.Styler courierNewGrey = new StyledString.Styler() {
@Override
public void applyStyles(TextStyle textStyle) {
textStyle.font = new Font(null, "Courier New",
defaultFont.getHeight(), SWT.NORMAL);
textStyle.foreground = JFaceResources.getColorRegistry().get(
JFacePreferences.QUALIFIER_COLOR);
}
};
result.append(hit.getLineno() + " ", courierNewSmall);
String line = hit.getLine();
int startidx = line.indexOf("<b>");
int endidx = line.indexOf("</b>");
String before = line.substring(0, startidx);
String term = line.substring(startidx + "<b>".length(), endidx);