Search in sources :

Example 1 with IVerticalRulerExtension

use of org.eclipse.jface.text.source.IVerticalRulerExtension in project eclipse.platform.text by eclipse.

the class AbstractTextEditor method setFont.

/**
 * Sets the font for the given viewer sustaining selection and scroll position.
 *
 * @param sourceViewer the source viewer
 * @param font the font
 * @since 2.0
 */
private void setFont(ISourceViewer sourceViewer, Font font) {
    if (sourceViewer.getDocument() != null) {
        ISelectionProvider provider = sourceViewer.getSelectionProvider();
        ISelection selection = provider.getSelection();
        int topIndex = sourceViewer.getTopIndex();
        StyledText styledText = sourceViewer.getTextWidget();
        Control parent = styledText;
        if (sourceViewer instanceof ITextViewerExtension) {
            ITextViewerExtension extension = (ITextViewerExtension) sourceViewer;
            parent = extension.getControl();
        }
        parent.setRedraw(false);
        styledText.setFont(font);
        if (fVerticalRuler instanceof IVerticalRulerExtension) {
            IVerticalRulerExtension e = (IVerticalRulerExtension) fVerticalRuler;
            e.setFont(font);
        }
        provider.setSelection(selection);
        sourceViewer.setTopIndex(topIndex);
        if (parent instanceof Composite) {
            Composite composite = (Composite) parent;
            composite.layout(true);
        }
        parent.setRedraw(true);
    } else {
        StyledText styledText = sourceViewer.getTextWidget();
        styledText.setFont(font);
        if (fVerticalRuler instanceof IVerticalRulerExtension) {
            IVerticalRulerExtension e = (IVerticalRulerExtension) fVerticalRuler;
            e.setFont(font);
        }
    }
}
Also used : IVerticalRulerExtension(org.eclipse.jface.text.source.IVerticalRulerExtension) Control(org.eclipse.swt.widgets.Control) ITextViewerExtension(org.eclipse.jface.text.ITextViewerExtension) StyledText(org.eclipse.swt.custom.StyledText) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) Composite(org.eclipse.swt.widgets.Composite) ISelection(org.eclipse.jface.viewers.ISelection) Point(org.eclipse.swt.graphics.Point)

Aggregations

ITextViewerExtension (org.eclipse.jface.text.ITextViewerExtension)1 IVerticalRulerExtension (org.eclipse.jface.text.source.IVerticalRulerExtension)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 StyledText (org.eclipse.swt.custom.StyledText)1 Point (org.eclipse.swt.graphics.Point)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1