I assume you are using TreeViewer.
You can use a StyledCellLabelProvider to set different styles for parts of the label string. The DelegatingStyledCellLabelProvider class is derived from this class to make things a bit easier. Set up the label provider using:
viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(myLabelProvider));
where myLabelProvider is a class implementing DelegatingStyledCellLabelProvider.IStyledLabelProvider. The provider has a getImage method as usual plus:
public StyledString getStyledText(Object element)
which uses a StyledString which allows you to apply different styles to the text. Something like:
StyledString text = new StyledString();
text.append("unstyled text");
text.append("styled text with decorations style", StyledString.DECORATIONS_STYLER);
as well as the predefined StyledString.Styler values you can define your own. The DefaultStyler class lets you use colors defined in the JFace color registry.
A simple version of a styler to set the background to yellow would be:
class HighlightStyler extends Styler
{
@Override
public void applyStyles(final TextStyle textStyle)
{
textStyle.background = Display.getDefault().getSystemColor(SWT.COLOR_YELLOW);
}
}