Je sais que cela a été demandé il y a un certain temps, mais au cas où quelqu'un est à la recherche d'une autre solution, je pensais que je posterais les suivantes:
Puisque vous êtes en mesure d'utiliser la méthode SetTextColor, alors vous devriez être en mesure pour utiliser aussi la méthode changeTextPresentation.
Dans le cas de mon plug-in, j'ai une textListener qui appelle la méthode TextChanged I réenregistrés. J'ai fait ce qui suit pour ajouter une couleur d'arrière-plan en utilisant la méthode changeTextPresentation. Ce faisant, j'ai pu obtenir un fond vert avec un premier plan noir. Pas que je le veuille, bien sûr, mais juste pour tester.
public void TextChanged(TextEvent event){
...
TextPresentation presentation = new TextPresentation();
TextAttribute attr = new TextAttribute(new ColorManager().getColor(MyConstants.BLACK),
new ColorManager().getColor(MyConstants.GREEN), style);
presentation.addStyleRange(new StyleRange(startOffset, tokLength, attr.getForeground(),
attr.getBackground());
sourceViewer.changeTextPresentation(presentation, true); //sourceViewer is a global variable passed to my TextListener class constructor.
}