Search in sources :

Example 16 with ITextViewerExtension2

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

the class SourceViewerDecorationSupport method hideCursorLine.

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

Example 17 with ITextViewerExtension2

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

the class CodeMiningDemo method addAnnotationPainter.

private static void addAnnotationPainter(ISourceViewer viewer) {
    IAnnotationAccess annotationAccess = new IAnnotationAccess() {

        @Override
        public Object getType(Annotation annotation) {
            return annotation.getType();
        }

        @Override
        public boolean isMultiLine(Annotation annotation) {
            return true;
        }

        @Override
        public boolean isTemporary(Annotation annotation) {
            return true;
        }
    };
    AnnotationPainter painter = new AnnotationPainter(viewer, annotationAccess);
    ((ITextViewerExtension2) viewer).addPainter(painter);
    // Register this annotation painter as CodeMining annotation painter.
    ((ISourceViewerExtension5) viewer).setCodeMiningAnnotationPainter(painter);
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) IAnnotationAccess(org.eclipse.jface.text.source.IAnnotationAccess) ISourceViewerExtension5(org.eclipse.jface.text.source.ISourceViewerExtension5) AnnotationPainter(org.eclipse.jface.text.source.AnnotationPainter) Annotation(org.eclipse.jface.text.source.Annotation)

Example 18 with ITextViewerExtension2

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

the class InlinedAnnotationDemo method createAnnotationPainter.

/**
 * Create annotation painter.
 *
 * @param viewer
 *            the viewer.
 * @return annotation painter.
 */
private static AnnotationPainter createAnnotationPainter(ISourceViewer viewer) {
    IAnnotationAccess annotationAccess = new IAnnotationAccess() {

        @Override
        public Object getType(Annotation annotation) {
            return annotation.getType();
        }

        @Override
        public boolean isMultiLine(Annotation annotation) {
            return true;
        }

        @Override
        public boolean isTemporary(Annotation annotation) {
            return true;
        }
    };
    AnnotationPainter painter = new AnnotationPainter(viewer, annotationAccess);
    ((ITextViewerExtension2) viewer).addPainter(painter);
    return painter;
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) IAnnotationAccess(org.eclipse.jface.text.source.IAnnotationAccess) AnnotationPainter(org.eclipse.jface.text.source.AnnotationPainter) LineContentAnnotation(org.eclipse.jface.text.source.inlined.LineContentAnnotation) Annotation(org.eclipse.jface.text.source.Annotation) AbstractInlinedAnnotation(org.eclipse.jface.text.source.inlined.AbstractInlinedAnnotation) LineHeaderAnnotation(org.eclipse.jface.text.source.inlined.LineHeaderAnnotation)

Example 19 with ITextViewerExtension2

use of org.eclipse.jface.text.ITextViewerExtension2 in project webtools.sourceediting by eclipse.

the class StructuredTextEditor method updateHoverBehavior.

/*
	 * Update the hovering behavior depending on the preferences.
	 */
private void updateHoverBehavior() {
    SourceViewerConfiguration configuration = getSourceViewerConfiguration();
    String[] types = configuration.getConfiguredContentTypes(getSourceViewer());
    ISourceViewer sourceViewer = getSourceViewer();
    if (sourceViewer == null)
        return;
    for (int i = 0; i < types.length; i++) {
        String t = types[i];
        if (sourceViewer instanceof ITextViewerExtension2) {
            // Remove existing hovers
            ((ITextViewerExtension2) sourceViewer).removeTextHovers(t);
            int[] stateMasks = configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t);
            if (stateMasks != null) {
                for (int j = 0; j < stateMasks.length; j++) {
                    int stateMask = stateMasks[j];
                    ITextHover textHover = configuration.getTextHover(sourceViewer, t, stateMask);
                    ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, stateMask);
                }
            } else {
                ITextHover textHover = configuration.getTextHover(sourceViewer, t);
                ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
            }
        } else
            sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t);
    }
}
Also used : SourceViewerConfiguration(org.eclipse.jface.text.source.SourceViewerConfiguration) ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) ITextHover(org.eclipse.jface.text.ITextHover) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) Point(org.eclipse.swt.graphics.Point)

Example 20 with ITextViewerExtension2

use of org.eclipse.jface.text.ITextViewerExtension2 in project webtools.sourceediting by eclipse.

the class SemanticHighlightingPresenter method invalidateTextPresentation.

/**
 * Invalidate text presentation of all positions.
 */
private void invalidateTextPresentation() {
    if (fSourceViewer instanceof ITextViewerExtension2) {
        final ITextViewerExtension2 viewer = (ITextViewerExtension2) fSourceViewer;
        for (int i = 0, n = fPositions.size(); i < n; i++) {
            Position position = (Position) fPositions.get(i);
            viewer.invalidateTextPresentation(position.getOffset(), position.getLength());
        }
    } else {
        fSourceViewer.invalidateTextPresentation();
    }
}
Also used : ITextViewerExtension2(org.eclipse.jface.text.ITextViewerExtension2) HighlightedPosition(org.eclipse.wst.sse.ui.internal.style.SemanticHighlightingManager.HighlightedPosition) Position(org.eclipse.jface.text.Position)

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