use of org.eclipse.jface.text.ITextViewerExtension2 in project webtools.sourceediting by eclipse.
the class HighlighterHyperlinkPresenter method highlightRegion.
private void highlightRegion(IRegion region) {
if (region.equals(fActiveRegion))
return;
repairRepresentation();
StyledText text = fTextViewer.getTextWidget();
if (text == null || text.isDisposed())
return;
// Underline
int offset = 0;
int length = 0;
if (fTextViewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension = (ITextViewerExtension5) fTextViewer;
IRegion widgetRange = extension.modelRange2WidgetRange(region);
if (widgetRange == null)
return;
offset = widgetRange.getOffset();
length = widgetRange.getLength();
} else {
offset = region.getOffset() - fTextViewer.getVisibleRegion().getOffset();
length = region.getLength();
}
// needs to clean background due to StructuredTextEditor's highlighter
text.redrawRange(offset, length, true);
// Invalidate region ==> apply text presentation
fActiveRegion = region;
if (fTextViewer instanceof ITextViewerExtension2)
((ITextViewerExtension2) fTextViewer).invalidateTextPresentation(region.getOffset(), region.getLength());
else
fTextViewer.invalidateTextPresentation();
}
Aggregations