Search in sources :

Example 16 with AnnotationPreference

use of org.eclipse.ui.texteditor.AnnotationPreference in project webtools.sourceediting by eclipse.

the class GotoAnnotationAction method isNavigationTarget.

/**
 * Returns whether the given annotation is configured as a target for the
 * "Go to Next/Previous Annotation" actions
 *
 * @param annotation
 *            the annotation
 * @return <code>true</code> if this is a target, <code>false</code>
 *         otherwise
 * @see Eclipse 3.0
 */
protected boolean isNavigationTarget(Annotation annotation) {
    Preferences preferences = EditorsUI.getPluginPreferences();
    AnnotationPreference preference = EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
    // See bug 41689
    // String key= forward ? preference.getIsGoToNextNavigationTargetKey()
    // : preference.getIsGoToPreviousNavigationTargetKey();
    String key = preference == null ? null : preference.getIsGoToNextNavigationTargetKey();
    return (key != null && preferences.getBoolean(key));
}
Also used : Preferences(org.eclipse.core.runtime.Preferences) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference)

Example 17 with AnnotationPreference

use of org.eclipse.ui.texteditor.AnnotationPreference 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 18 with AnnotationPreference

use of org.eclipse.ui.texteditor.AnnotationPreference 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)

Example 19 with AnnotationPreference

use of org.eclipse.ui.texteditor.AnnotationPreference 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 20 with AnnotationPreference

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

the class DelegatingAnnotationPreference method getAnnotationImageProvider.

@Override
public IAnnotationImageProvider getAnnotationImageProvider() {
    if (!isCached(IMAGE_PROVIDER)) {
        AnnotationPreference preference = getDefiningPreference(IMAGE_PROVIDER);
        if (preference != null) {
            fAnnotationImageProvider = preference.fAnnotationImageProvider;
            fAnnotationImageProviderAttribute = preference.fAnnotationImageProviderAttribute;
            fConfigurationElement = preference.fConfigurationElement;
        }
        markCached(IMAGE_PROVIDER);
    }
    return super.getAnnotationImageProvider();
}
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