Search in sources :

Example 6 with AnnotationPreference

use of org.eclipse.ui.texteditor.AnnotationPreference in project eclipse.platform.text by eclipse.

the class QuickDiffConfigurationBlock method createQuickDiffModel.

private String[][] createQuickDiffModel(MarkerAnnotationPreferences preferences) {
    String[][] items = new String[3][];
    Iterator<AnnotationPreference> e = preferences.getAnnotationPreferences().iterator();
    while (e.hasNext()) {
        AnnotationPreference info = e.next();
        if (// $NON-NLS-1$
        info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange"))
            items[0] = new String[] { info.getColorPreferenceKey(), info.getOverviewRulerPreferenceKey(), TextEditorMessages.QuickDiffConfigurationBlock_changeColor };
        else if (// $NON-NLS-1$
        info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition"))
            items[1] = new String[] { info.getColorPreferenceKey(), info.getOverviewRulerPreferenceKey(), TextEditorMessages.QuickDiffConfigurationBlock_additionColor };
        else if (// $NON-NLS-1$
        info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffDeletion"))
            items[2] = new String[] { info.getColorPreferenceKey(), info.getOverviewRulerPreferenceKey(), TextEditorMessages.QuickDiffConfigurationBlock_deletionColor };
    }
    return items;
}
Also used : AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Example 7 with AnnotationPreference

use of org.eclipse.ui.texteditor.AnnotationPreference in project eclipse.platform.text by eclipse.

the class AnnotationHoverDelegate method getDelegate.

private DefaultTextHover getDelegate(ISourceViewer sourceViewer) {
    if (this.delegate == null || this.viewer != sourceViewer) {
        this.delegate = new DefaultTextHover(sourceViewer) {

            @Override
            protected boolean isIncluded(Annotation annotation) {
                if (annotation instanceof MarkerAnnotation) {
                    // this is handled by MarkerAnnotationHover
                    return false;
                }
                AnnotationPreference preference = EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
                if (preference == null)
                    return false;
                String key = preference.getTextPreferenceKey();
                if (key != null) {
                    if (!EditorsUI.getPreferenceStore().getBoolean(key))
                        return false;
                } else {
                    key = preference.getHighlightPreferenceKey();
                    if (key == null || !EditorsUI.getPreferenceStore().getBoolean(key))
                        return false;
                }
                return true;
            }
        };
        this.viewer = sourceViewer;
    }
    return this.delegate;
}
Also used : MarkerAnnotation(org.eclipse.ui.texteditor.MarkerAnnotation) DefaultTextHover(org.eclipse.jface.text.DefaultTextHover) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference) MarkerAnnotation(org.eclipse.ui.texteditor.MarkerAnnotation) Annotation(org.eclipse.jface.text.source.Annotation)

Example 8 with AnnotationPreference

use of org.eclipse.ui.texteditor.AnnotationPreference in project eclipse.platform.text by eclipse.

the class MarkerAnnotationHover method isIncluded.

protected static boolean isIncluded(Annotation annotation) {
    if (!(annotation instanceof MarkerAnnotation)) {
        return false;
    }
    AnnotationPreference preference = EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
    if (preference == null) {
        return false;
    }
    String key = preference.getTextPreferenceKey();
    if (key != null) {
        if (!EditorsUI.getPreferenceStore().getBoolean(key))
            return false;
    } else {
        key = preference.getHighlightPreferenceKey();
        if (key == null || !EditorsUI.getPreferenceStore().getBoolean(key))
            return false;
    }
    return true;
}
Also used : MarkerAnnotation(org.eclipse.ui.texteditor.MarkerAnnotation) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Example 9 with AnnotationPreference

use of org.eclipse.ui.texteditor.AnnotationPreference in project eclipse.platform.text by eclipse.

the class DelegatingAnnotationPreference method getAttributeValue.

private Object getAttributeValue(Object attribute) {
    if (!isCached(attribute)) {
        AnnotationPreference preference = getDefiningPreference(attribute);
        if (preference != null)
            setValue(attribute, preference.getValue(attribute));
        markCached(attribute);
    }
    return super.getValue(attribute);
}
Also used : AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Example 10 with AnnotationPreference

use of org.eclipse.ui.texteditor.AnnotationPreference in project eclipse.platform.text by eclipse.

the class DelegatingAnnotationPreference method getDefiningPreference.

private AnnotationPreference getDefiningPreference(Object attribute) {
    AnnotationPreference p = fLookup.getAnnotationPreferenceFragment(fType.getType());
    if (p != null && p.hasValue(attribute))
        return p;
    String[] superTypes = fType.getSuperTypes();
    for (int i = 0; i < superTypes.length; i++) {
        p = fLookup.getAnnotationPreferenceFragment(superTypes[i]);
        if (p != null && p.hasValue(attribute))
            return p;
    }
    return null;
}
Also used : AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Aggregations

AnnotationPreference (org.eclipse.ui.texteditor.AnnotationPreference)32 ArrayList (java.util.ArrayList)6 SourceViewerDecorationSupport (org.eclipse.ui.texteditor.SourceViewerDecorationSupport)5 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)4 IOverviewRuler (org.eclipse.jface.text.source.IOverviewRuler)4 OverviewRuler (org.eclipse.jface.text.source.OverviewRuler)4 DefaultMarkerAnnotationAccess (org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess)4 MarkerAnnotationPreferences (org.eclipse.ui.texteditor.MarkerAnnotationPreferences)4 Iterator (java.util.Iterator)3 Annotation (org.eclipse.jface.text.source.Annotation)2 AnnotationRulerColumn (org.eclipse.jface.text.source.AnnotationRulerColumn)2 CompositeRuler (org.eclipse.jface.text.source.CompositeRuler)2 IAnnotationAccess (org.eclipse.jface.text.source.IAnnotationAccess)2 ISharedTextColors (org.eclipse.jface.text.source.ISharedTextColors)2 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)2 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)2 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)2 Image (org.eclipse.swt.graphics.Image)2 OverlayKey (org.eclipse.ui.internal.editors.text.OverlayPreferenceStore.OverlayKey)2 MarkerAnnotation (org.eclipse.ui.texteditor.MarkerAnnotation)2