Search in sources :

Example 1 with AnnotationRulerColumn

use of org.eclipse.jface.text.source.AnnotationRulerColumn 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);
    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 2 with AnnotationRulerColumn

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

the class GroovyScriptPage method createVerticalRuler.

@Override
protected IVerticalRuler createVerticalRuler() {
    final Display display = Display.getCurrent();
    CompositeRuler ruler = new CompositeRuler(3);
    AnnotationRulerColumn annotations = SimpleAnnotationUtil.createDefaultAnnotationRuler(annotationModel);
    ruler.addDecorator(0, annotations);
    LineNumberRulerColumn lineNumbers = new LineNumberRulerColumn();
    // SWT.COLOR_INFO_BACKGROUND));
    lineNumbers.setBackground(display.getSystemColor(SWT.COLOR_GRAY));
    // SWT.COLOR_INFO_FOREGROUND));
    lineNumbers.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
    lineNumbers.setFont(JFaceResources.getTextFont());
    ruler.addDecorator(1, lineNumbers);
    return ruler;
}
Also used : AnnotationRulerColumn(org.eclipse.jface.text.source.AnnotationRulerColumn) LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) Display(org.eclipse.swt.widgets.Display)

Example 3 with AnnotationRulerColumn

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

the class AnnotationColumn method initialize.

/**
 * Initializes the given line number ruler column from the preference store.
 */
private void initialize() {
    if (fDelegate == null)
        fDelegate = new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, new DefaultMarkerAnnotationAccess());
    IPreferenceStore store = getPreferenceStore();
    if (store != null && fDelegate instanceof AnnotationRulerColumn) {
        final AnnotationRulerColumn column = (AnnotationRulerColumn) fDelegate;
        // initial set up
        for (Iterator<AnnotationPreference> iter2 = fAnnotationPreferences.getAnnotationPreferences().iterator(); iter2.hasNext(); ) {
            AnnotationPreference preference = iter2.next();
            String key = preference.getVerticalRulerPreferenceKey();
            boolean showAnnotation = true;
            if (key != null && store.contains(key))
                showAnnotation = store.getBoolean(key);
            if (showAnnotation)
                column.addAnnotationType(preference.getAnnotationType());
        }
        column.addAnnotationType(Annotation.TYPE_UNKNOWN);
        // link to preference store
        fPropertyListener = new IPropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent event) {
                String property = event.getProperty();
                AnnotationPreference annotationPreference = getVerticalRulerAnnotationPreference(property);
                if (annotationPreference != null && property.equals(annotationPreference.getVerticalRulerPreferenceKey())) {
                    Object type = annotationPreference.getAnnotationType();
                    if (getPreferenceStore().getBoolean(property))
                        column.addAnnotationType(type);
                    else
                        column.removeAnnotationType(type);
                    column.redraw();
                }
            }
        };
        store.addPropertyChangeListener(fPropertyListener);
    }
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) AnnotationRulerColumn(org.eclipse.jface.text.source.AnnotationRulerColumn) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) DefaultMarkerAnnotationAccess(org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Example 4 with AnnotationRulerColumn

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

the class SimpleAnnotationUtil method createDefaultAnnotationRuler.

/**
 * Create a default annotation ruler configured for displaying
 * {@link SimpleAnnotations}.
 *
 * @param annotationModel the annotation model
 * @return the annotation ruler
 */
public static AnnotationRulerColumn createDefaultAnnotationRuler(IAnnotationModel annotationModel) {
    AnnotationRulerColumn annotations = new AnnotationRulerColumn(annotationModel, 12, new SimpleAnnotations());
    // error
    annotations.addAnnotationType(SimpleAnnotations.TYPE_ERROR);
    // warning
    annotations.addAnnotationType(SimpleAnnotations.TYPE_WARN);
    // information
    annotations.addAnnotationType(SimpleAnnotations.TYPE_INFO);
    annotations.setHover(new DefaultAnnotationHover());
    return annotations;
}
Also used : AnnotationRulerColumn(org.eclipse.jface.text.source.AnnotationRulerColumn) DefaultAnnotationHover(org.eclipse.jface.text.source.DefaultAnnotationHover)

Aggregations

AnnotationRulerColumn (org.eclipse.jface.text.source.AnnotationRulerColumn)4 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 CompositeRuler (org.eclipse.jface.text.source.CompositeRuler)2 DefaultAnnotationHover (org.eclipse.jface.text.source.DefaultAnnotationHover)2 LineNumberRulerColumn (org.eclipse.jface.text.source.LineNumberRulerColumn)2 AnnotationPreference (org.eclipse.ui.texteditor.AnnotationPreference)2 JavaSourceViewer (org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer)1 SimpleJavaSourceViewerConfiguration (org.eclipse.jdt.internal.ui.text.SimpleJavaSourceViewerConfiguration)1 DefaultInformationControl (org.eclipse.jface.text.DefaultInformationControl)1 IInformationControl (org.eclipse.jface.text.IInformationControl)1 IInformationControlCreator (org.eclipse.jface.text.IInformationControlCreator)1 IAnnotationHover (org.eclipse.jface.text.source.IAnnotationHover)1 IOverviewRuler (org.eclipse.jface.text.source.IOverviewRuler)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 OverviewRuler (org.eclipse.jface.text.source.OverviewRuler)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1 DefaultMarkerAnnotationAccess (org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess)1