Search in sources :

Example 1 with ITextViewerExtension4

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

the class InlinedAnnotationSupport method install.

/**
 * Install the inlined annotation support for the given viewer.
 *
 * @param viewer the source viewer
 * @param painter the annotation painter to use to draw the inlined annotations.
 */
public void install(ISourceViewer viewer, AnnotationPainter painter) {
    Assert.isNotNull(viewer);
    Assert.isNotNull(painter);
    fViewer = viewer;
    fPainter = painter;
    initPainter();
    StyledText text = fViewer.getTextWidget();
    if (text == null || text.isDisposed()) {
        return;
    }
    if (fViewer instanceof ITextViewerExtension4) {
        updateStylesWidth = new UpdateStylesWidth();
        ((ITextViewerExtension4) fViewer).addTextPresentationListener(updateStylesWidth);
    }
    visibleLines = new VisibleLines();
    fViewer.addViewportListener(visibleLines);
    text.addMouseListener(fMouseTracker);
    text.addMouseTrackListener(fMouseTracker);
    text.addMouseMoveListener(fMouseTracker);
    setColor(text.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) ITextViewerExtension4(org.eclipse.jface.text.ITextViewerExtension4)

Example 2 with ITextViewerExtension4

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

the class InlinedAnnotationSupport method uninstall.

/**
 * Unisntall the inlined annotation support
 */
public void uninstall() {
    StyledText text = this.fViewer.getTextWidget();
    if (text != null && !text.isDisposed()) {
        text.removeMouseListener(this.fMouseTracker);
        text.removeMouseTrackListener(this.fMouseTracker);
        text.removeMouseMoveListener(this.fMouseTracker);
    }
    if (fViewer != null) {
        if (fViewer instanceof ITextViewerExtension4) {
            ((ITextViewerExtension4) fViewer).removeTextPresentationListener(updateStylesWidth);
        }
        fViewer.removeViewportListener(visibleLines);
    }
    if (visibleLines != null) {
        visibleLines.uninstall();
        visibleLines = null;
    }
    disposeFont();
    fViewer = null;
    fPainter = null;
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) ITextViewerExtension4(org.eclipse.jface.text.ITextViewerExtension4)

Example 3 with ITextViewerExtension4

use of org.eclipse.jface.text.ITextViewerExtension4 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 4 with ITextViewerExtension4

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

the class SourceViewerDecorationSupport method updateAnnotationPainter.

/**
 * Updates the annotation painter.
 * @since 3.0
 */
private void updateAnnotationPainter() {
    if (fAnnotationPainter == null)
        return;
    fAnnotationPainter.paint(IPainter.CONFIGURATION);
    if (!fAnnotationPainter.isPaintingAnnotations()) {
        if (fSourceViewer instanceof ITextViewerExtension2) {
            ITextViewerExtension2 extension = (ITextViewerExtension2) fSourceViewer;
            extension.removePainter(fAnnotationPainter);
        }
        if (fSourceViewer instanceof ITextViewerExtension4)
            ((ITextViewerExtension4) fSourceViewer).removeTextPresentationListener(fAnnotationPainter);
        fAnnotationPainter.deactivate(true);
        fAnnotationPainter.dispose();
        fAnnotationPainter = null;
    }
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) ITextViewerExtension4(org.eclipse.jface.text.ITextViewerExtension4)

Example 5 with ITextViewerExtension4

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

the class DefaultHyperlinkPresenter method install.

@Override
public void install(ITextViewer textViewer) {
    Assert.isNotNull(textViewer);
    fTextViewer = textViewer;
    fTextViewer.addTextInputListener(this);
    if (fTextViewer instanceof ITextViewerExtension4)
        ((ITextViewerExtension4) fTextViewer).addTextPresentationListener(this);
    if (fPreferenceStore != null) {
        fIsUsingNativeLinkColor = fPreferenceStore.getBoolean(HYPERLINK_COLOR_SYSTEM_DEFAULT);
        if (!fIsUsingNativeLinkColor)
            fColor = createColorFromPreferenceStore();
        fPreferenceStore.addPropertyChangeListener(this);
    } else if (fRGB != null) {
        StyledText text = fTextViewer.getTextWidget();
        if (text != null && !text.isDisposed())
            fColor = new Color(text.getDisplay(), fRGB);
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) ITextViewerExtension4(org.eclipse.jface.text.ITextViewerExtension4) Color(org.eclipse.swt.graphics.Color)

Aggregations

ITextViewerExtension4 (org.eclipse.jface.text.ITextViewerExtension4)6 StyledText (org.eclipse.swt.custom.StyledText)3 ITextViewerExtension2 (org.eclipse.jface.text.ITextViewerExtension2)2 IDocument (org.eclipse.jface.text.IDocument)1 ISourceViewerExtension5 (org.eclipse.jface.text.source.ISourceViewerExtension5)1 Color (org.eclipse.swt.graphics.Color)1