Search in sources :

Example 1 with OverviewRuler

use of org.eclipse.jface.text.source.OverviewRuler in project hale by halestudio.

the class SimpleAnnotationUtil method createDefaultOverviewRuler.

/**
 * Create a default overview ruler configured for displaying
 * {@link SimpleAnnotations}.
 *
 * @param width the ruler width
 * @param colorManager the color manager
 * @param annotationModel the annotation model
 * @return the overview ruler
 */
public static IOverviewRuler createDefaultOverviewRuler(int width, ISharedTextColors colorManager, IAnnotationModel annotationModel) {
    IOverviewRuler ruler = new OverviewRuler(new SimpleAnnotations(), width, colorManager);
    // type configuration
    // error (including header)
    ruler.addAnnotationType(SimpleAnnotations.TYPE_ERROR);
    ruler.addHeaderAnnotationType(SimpleAnnotations.TYPE_ERROR);
    ruler.setAnnotationTypeColor(SimpleAnnotations.TYPE_ERROR, colorManager.getColor(new RGB(255, 0, 0)));
    ruler.setAnnotationTypeLayer(SimpleAnnotations.TYPE_ERROR, IAnnotationAccessExtension.DEFAULT_LAYER);
    // warning
    ruler.addAnnotationType(SimpleAnnotations.TYPE_WARN);
    ruler.setAnnotationTypeColor(SimpleAnnotations.TYPE_WARN, colorManager.getColor(new RGB(255, 255, 0)));
    ruler.setAnnotationTypeLayer(SimpleAnnotations.TYPE_WARN, IAnnotationAccessExtension.DEFAULT_LAYER);
    // information
    ruler.addAnnotationType(SimpleAnnotations.TYPE_INFO);
    ruler.setAnnotationTypeColor(SimpleAnnotations.TYPE_INFO, colorManager.getColor(new RGB(0, 0, 255)));
    ruler.setAnnotationTypeLayer(SimpleAnnotations.TYPE_INFO, IAnnotationAccessExtension.DEFAULT_LAYER);
    ruler.setModel(annotationModel);
    return ruler;
}
Also used : IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) OverviewRuler(org.eclipse.jface.text.source.OverviewRuler) RGB(org.eclipse.swt.graphics.RGB)

Example 2 with OverviewRuler

use of org.eclipse.jface.text.source.OverviewRuler in project xtext-xtend by eclipse.

the class DerivedSourceView method createSourceViewer.

@Override
protected SourceViewer createSourceViewer(Composite parent) {
    IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
    IOverviewRuler overviewRuler = new OverviewRuler(defaultMarkerAnnotationAccess, OVERVIEW_RULER_WIDTH, getSharedTextColors());
    AnnotationRulerColumn annotationRulerColumn = new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, defaultMarkerAnnotationAccess);
    @SuppressWarnings("unchecked") List<AnnotationPreference> annotationPreferences = markerAnnotationPreferences.getAnnotationPreferences();
    for (AnnotationPreference annotationPreference : annotationPreferences) {
        String key = annotationPreference.getVerticalRulerPreferenceKey();
        boolean showAnnotation = true;
        if (key != null && store.contains(key)) {
            showAnnotation = store.getBoolean(key);
        }
        if (showAnnotation) {
            annotationRulerColumn.addAnnotationType(annotationPreference.getAnnotationType());
        }
    }
    annotationRulerColumn.addAnnotationType(Annotation.TYPE_UNKNOWN);
    lineNumberRulerColumn = new LineNumberRulerColumn();
    CompositeRuler compositeRuler = new CompositeRuler();
    compositeRuler.addDecorator(0, annotationRulerColumn);
    compositeRuler.addDecorator(1, lineNumberRulerColumn);
    javaSourceViewer = new JavaSourceViewer(parent, compositeRuler, overviewRuler, true, SWT.V_SCROLL | SWT.H_SCROLL, store);
    javaSourceViewerConfiguration = new SimpleJavaSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, true) {

        @Override
        public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
            return new IInformationControlCreator() {

                @Override
                public IInformationControl createInformationControl(final Shell parent) {
                    return new DefaultInformationControl(parent, true);
                }
            };
        }

        @Override
        public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
            return new DefaultAnnotationHover();
        }
    };
    javaSourceViewer.configure(javaSourceViewerConfiguration);
    javaSourceViewer.setEditable(false);
    javaSourceViewer.showAnnotations(true);
    sourceViewerDecorationSupport = new SourceViewerDecorationSupport(javaSourceViewer, overviewRuler, defaultMarkerAnnotationAccess, getSharedTextColors());
    for (AnnotationPreference annotationPreference : annotationPreferences) {
        sourceViewerDecorationSupport.setAnnotationPreference(annotationPreference);
    }
    sourceViewerDecorationSupport.install(preferenceStoreAccess.getPreferenceStore());
    return javaSourceViewer;
}
Also used : LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) SimpleJavaSourceViewerConfiguration(org.eclipse.jdt.internal.ui.text.SimpleJavaSourceViewerConfiguration) DefaultInformationControl(org.eclipse.jface.text.DefaultInformationControl) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) SourceViewerDecorationSupport(org.eclipse.ui.texteditor.SourceViewerDecorationSupport) IAnnotationHover(org.eclipse.jface.text.source.IAnnotationHover) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) AnnotationRulerColumn(org.eclipse.jface.text.source.AnnotationRulerColumn) Shell(org.eclipse.swt.widgets.Shell) IInformationControl(org.eclipse.jface.text.IInformationControl) JavaSourceViewer(org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer) OverviewRuler(org.eclipse.jface.text.source.OverviewRuler) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) DefaultAnnotationHover(org.eclipse.jface.text.source.DefaultAnnotationHover)

Example 3 with OverviewRuler

use of org.eclipse.jface.text.source.OverviewRuler in project tmdm-studio-se by Talend.

the class ElementFKInfoFormatHelper method createOverviewRuler.

public static IOverviewRuler createOverviewRuler() {
    IOverviewRuler ruler = new OverviewRuler(getAnnotationAccess(), VERTICAL_RULER_WIDTH, getSharedColors());
    Iterator<?> e = getAnnotationPreferences().getAnnotationPreferences().iterator();
    while (e.hasNext()) {
        AnnotationPreference preference = (AnnotationPreference) e.next();
        if (preference.contributesToHeader()) {
            ruler.addHeaderAnnotationType(preference.getAnnotationType());
        }
    }
    return ruler;
}
Also used : IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) OverviewRuler(org.eclipse.jface.text.source.OverviewRuler) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Example 4 with OverviewRuler

use of org.eclipse.jface.text.source.OverviewRuler in project tmdm-studio-se by Talend.

the class XMLSourceViewerHelper method createOverviewRuler.

public IOverviewRuler createOverviewRuler() {
    IOverviewRuler ruler = new OverviewRuler(getAnnotationAccess(), VERTICAL_RULER_WIDTH, getSharedColors());
    Iterator e = getAnnotationPreferences().getAnnotationPreferences().iterator();
    while (e.hasNext()) {
        AnnotationPreference preference = (AnnotationPreference) e.next();
        if (preference.contributesToHeader()) {
            ruler.addHeaderAnnotationType(preference.getAnnotationType());
        }
    }
    return ruler;
}
Also used : IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) Iterator(java.util.Iterator) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) OverviewRuler(org.eclipse.jface.text.source.OverviewRuler) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Example 5 with OverviewRuler

use of org.eclipse.jface.text.source.OverviewRuler in project tdi-studio-se by Talend.

the class TalendJavaSourceViewer method initializeViewer.

private static ReconcilerViewer initializeViewer(Composite composite, int styles, boolean checkCode, IDocument document, int visibleOffset) {
    IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess();
    ISharedTextColors sharedColors = JavaPlugin.getDefault().getJavaTextTools().getColorManager();
    IOverviewRuler overviewRuler = null;
    IVerticalRuler verticalRuler = null;
    if (checkCode) {
        overviewRuler = new OverviewRuler(annotationAccess, 12, sharedColors);
        Iterator e = EditorsPlugin.getDefault().getMarkerAnnotationPreferences().getAnnotationPreferences().iterator();
        while (e.hasNext()) {
            AnnotationPreference preference = (AnnotationPreference) e.next();
            if (preference.contributesToHeader()) {
                overviewRuler.addHeaderAnnotationType(preference.getAnnotationType());
            }
        }
    }
    verticalRuler = new CompositeRuler(12);
    ReconcilerViewer viewer = new TalendJavaSourceViewer(composite, verticalRuler, overviewRuler, checkCode, styles, annotationAccess, sharedColors, checkCode, document);
    if (visibleOffset != -1) {
        viewer.setVisibleRegion(visibleOffset, 0);
    }
    return viewer;
}
Also used : IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) ISharedTextColors(org.eclipse.jface.text.source.ISharedTextColors) DefaultMarkerAnnotationAccess(org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess) IAnnotationAccess(org.eclipse.jface.text.source.IAnnotationAccess) IVerticalRuler(org.eclipse.jface.text.source.IVerticalRuler) Iterator(java.util.Iterator) OverviewRuler(org.eclipse.jface.text.source.OverviewRuler) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference) ReconcilerViewer(org.talend.designer.core.ui.viewer.ReconcilerViewer)

Aggregations

IOverviewRuler (org.eclipse.jface.text.source.IOverviewRuler)6 OverviewRuler (org.eclipse.jface.text.source.OverviewRuler)6 AnnotationPreference (org.eclipse.ui.texteditor.AnnotationPreference)4 Iterator (java.util.Iterator)2 CompositeRuler (org.eclipse.jface.text.source.CompositeRuler)2 JavaSourceViewer (org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer)1 SimpleJavaSourceViewerConfiguration (org.eclipse.jdt.internal.ui.text.SimpleJavaSourceViewerConfiguration)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 DefaultInformationControl (org.eclipse.jface.text.DefaultInformationControl)1 IInformationControl (org.eclipse.jface.text.IInformationControl)1 IInformationControlCreator (org.eclipse.jface.text.IInformationControlCreator)1 AnnotationRulerColumn (org.eclipse.jface.text.source.AnnotationRulerColumn)1 DefaultAnnotationHover (org.eclipse.jface.text.source.DefaultAnnotationHover)1 IAnnotationAccess (org.eclipse.jface.text.source.IAnnotationAccess)1 IAnnotationHover (org.eclipse.jface.text.source.IAnnotationHover)1 ISharedTextColors (org.eclipse.jface.text.source.ISharedTextColors)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 IVerticalRuler (org.eclipse.jface.text.source.IVerticalRuler)1 LineNumberRulerColumn (org.eclipse.jface.text.source.LineNumberRulerColumn)1 RGB (org.eclipse.swt.graphics.RGB)1