Search in sources :

Example 1 with ITextViewerExtension2

use of org.eclipse.jface.text.ITextViewerExtension2 in project xtext-eclipse by eclipse.

the class DefaultContentViewer method configureSourceViewer.

@Override
protected void configureSourceViewer(ISourceViewer sourceViewer) {
    sourceViewer.setEditable(false);
    sourceViewer.configure(sourceViewerConfiguration);
    if (sourceViewer instanceof ITextViewerExtension6) {
        ITextViewerExtension6 textViewerExtension6 = (ITextViewerExtension6) sourceViewer;
        textViewerExtension6.setHyperlinkDetectors(null, sourceViewerConfiguration.getHyperlinkStateMask(sourceViewer));
    }
    if (sourceViewer instanceof ITextViewerExtension2) {
        ITextViewerExtension2 textViewerExtension2 = (ITextViewerExtension2) sourceViewer;
        String[] configuredContentTypes = sourceViewerConfiguration.getConfiguredContentTypes(sourceViewer);
        for (String contentType : configuredContentTypes) {
            textViewerExtension2.removeTextHovers(contentType);
        }
    }
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) ITextViewerExtension6(org.eclipse.jface.text.ITextViewerExtension6)

Example 2 with ITextViewerExtension2

use of org.eclipse.jface.text.ITextViewerExtension2 in project eclipse.platform.text by eclipse.

the class BracketMatchingReconciler method install.

@Override
public void install(ITextViewer textViewer) {
    if (textViewer instanceof ITextViewerExtension2 && textViewer instanceof SourceViewer) {
        fSourceViewer = (SourceViewer) textViewer;
        fMatchingCharacterPainter = new MatchingCharacterPainter(fSourceViewer, fCharacterPairMatcher);
        fMatchingCharacterPainter.setColor(new Color(Display.getCurrent(), fBoxingRGB));
        fMatchingCharacterPainter.setHighlightCharacterAtCaretLocation(true);
        fMatchingCharacterPainter.setHighlightEnclosingPeerCharacters(true);
        fSourceViewer.addPainter(fMatchingCharacterPainter);
    }
}
Also used : MatchingCharacterPainter(org.eclipse.jface.text.source.MatchingCharacterPainter) ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) SourceViewer(org.eclipse.jface.text.source.SourceViewer) Color(org.eclipse.swt.graphics.Color)

Example 3 with ITextViewerExtension2

use of org.eclipse.jface.text.ITextViewerExtension2 in project eclipse.platform.text by eclipse.

the class ShowWhitespaceCharactersAction method uninstallPainter.

/**
 * Remove the painter from the current editor.
 */
private void uninstallPainter() {
    if (fWhitespaceCharPainter == null)
        return;
    ITextViewer viewer = getTextViewer();
    if (viewer instanceof ITextViewerExtension2)
        ((ITextViewerExtension2) viewer).removePainter(fWhitespaceCharPainter);
    fWhitespaceCharPainter.deactivate(true);
    fWhitespaceCharPainter = null;
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) ITextViewer(org.eclipse.jface.text.ITextViewer)

Example 4 with ITextViewerExtension2

use of org.eclipse.jface.text.ITextViewerExtension2 in project eclipse.platform.text by eclipse.

the class SourceViewerDecorationSupport method showAnnotations.

/**
 * Enables annotations in the source viewer for the given annotation type.
 *
 * @param annotationType the annotation type
 * @param updatePainter if <code>true</code> update the annotation painter
 * @since 3.0
 */
private void showAnnotations(Object annotationType, boolean updatePainter) {
    if (fSourceViewer instanceof ITextViewerExtension2) {
        if (fAnnotationPainter == null) {
            fAnnotationPainter = createAnnotationPainter();
            if (fSourceViewer instanceof ITextViewerExtension4)
                ((ITextViewerExtension4) fSourceViewer).addTextPresentationListener(fAnnotationPainter);
            ITextViewerExtension2 extension = (ITextViewerExtension2) fSourceViewer;
            extension.addPainter(fAnnotationPainter);
            if (fSourceViewer instanceof ISourceViewerExtension5)
                ((ISourceViewerExtension5) fSourceViewer).setCodeMiningAnnotationPainter(fAnnotationPainter);
        }
        fAnnotationPainter.setAnnotationTypeColor(annotationType, getAnnotationTypeColor(annotationType));
        Object decorationType = getAnnotationDecorationType(annotationType);
        if (decorationType != null)
            fAnnotationPainter.addAnnotationType(annotationType, decorationType);
        else
            fAnnotationPainter.addHighlightAnnotationType(annotationType);
        if (updatePainter)
            updateAnnotationPainter();
    }
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) ITextViewerExtension4(org.eclipse.jface.text.ITextViewerExtension4) ISourceViewerExtension5(org.eclipse.jface.text.source.ISourceViewerExtension5)

Example 5 with ITextViewerExtension2

use of org.eclipse.jface.text.ITextViewerExtension2 in project eclipse.platform.text by eclipse.

the class SourceViewerDecorationSupport method hideMargin.

/**
 * Hides the margin.
 */
private void hideMargin() {
    if (fMarginPainter != null) {
        if (fSourceViewer instanceof ITextViewerExtension2) {
            ITextViewerExtension2 extension = (ITextViewerExtension2) fSourceViewer;
            extension.removePainter(fMarginPainter);
            fMarginPainter.deactivate(true);
            fMarginPainter.dispose();
            fMarginPainter = null;
        }
    }
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2)

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