Search in sources :

Example 21 with ITextViewerExtension2

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();
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) StyledText(org.eclipse.swt.custom.StyledText) ITextViewerExtension5(org.eclipse.jface.text.ITextViewerExtension5) Point(org.eclipse.swt.graphics.Point) IRegion(org.eclipse.jface.text.IRegion)

Aggregations

ITextViewerExtension2 (org.eclipse.jface.text.ITextViewerExtension2)21 StyledText (org.eclipse.swt.custom.StyledText)5 Point (org.eclipse.swt.graphics.Point)4 ITextViewer (org.eclipse.jface.text.ITextViewer)3 ITextViewerExtension5 (org.eclipse.jface.text.ITextViewerExtension5)3 ITextViewerExtension4 (org.eclipse.jface.text.ITextViewerExtension4)2 WhitespaceCharacterPainter (org.eclipse.jface.text.WhitespaceCharacterPainter)2 Annotation (org.eclipse.jface.text.source.Annotation)2 AnnotationPainter (org.eclipse.jface.text.source.AnnotationPainter)2 IAnnotationAccess (org.eclipse.jface.text.source.IAnnotationAccess)2 ISourceViewerExtension5 (org.eclipse.jface.text.source.ISourceViewerExtension5)2 MatchingCharacterPainter (org.eclipse.jface.text.source.MatchingCharacterPainter)2 ArrayList (java.util.ArrayList)1 IAction (org.eclipse.jface.action.IAction)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Separator (org.eclipse.jface.action.Separator)1 SubMenuManager (org.eclipse.jface.action.SubMenuManager)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1