diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index 07df6a7204c..56d910230e8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -147,6 +147,7 @@ import org.eclipse.ui.part.ShowInContext; import org.eclipse.ui.preferences.ScopedPreferenceStore; import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; +import org.eclipse.ui.texteditor.AnnotationPreference; import org.eclipse.ui.texteditor.ChainedPreferenceStore; import org.eclipse.ui.texteditor.ContentAssistAction; import org.eclipse.ui.texteditor.IDocumentProvider; @@ -1635,6 +1636,17 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC sourceViewer.invalidateTextPresentation(); return; } + + if (affectsOverrideIndicatorAnnotations(event)) { + if (isShowingOverrideIndicators()) { + if (fOverrideIndicatorManager == null) + installOverrideIndicator(true); + } else { + if (fOverrideIndicatorManager != null) + uninstallOverrideIndicator(); + } + return; + } if (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) { if (fProjectionModelUpdater != null) { @@ -2456,7 +2468,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC if (isMarkingOccurrences()) installOccurrencesFinder(false); - installOverrideIndicator(true); + if(isShowingOverrideIndicators()) + installOverrideIndicator(false); } @@ -3515,6 +3528,53 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC } } + /** + * Determines whether the preference change encoded by the given event + * changes the override indication. + * + * @param event the event to be investigated + * @return true if event causes a change + * @since 5.3 + */ + protected boolean affectsOverrideIndicatorAnnotations(PropertyChangeEvent event) { + String key= event.getProperty(); + AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE); + if (key == null || preference == null) + return false; + + return key.equals(preference.getHighlightPreferenceKey()) + || key.equals(preference.getVerticalRulerPreferenceKey()) + || key.equals(preference.getOverviewRulerPreferenceKey()) + || key.equals(preference.getTextPreferenceKey()); + } + + /** + * Returns the boolean preference for the given key. + * + * @param store the preference store + * @param key the preference key + * @return true if the key exists in the store and its value is true + * @since 5.3 + */ + private boolean getBoolean(IPreferenceStore store, String key) { + return key != null && store.getBoolean(key); + } + + /** + * Tells whether override indicators are shown. + * + * @return true if the override indicators are shown + * @since 5.3 + */ + protected boolean isShowingOverrideIndicators() { + AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE); + IPreferenceStore store= getPreferenceStore(); + return getBoolean(store, preference.getHighlightPreferenceKey()) + || getBoolean(store, preference.getVerticalRulerPreferenceKey()) + || getBoolean(store, preference.getOverviewRulerPreferenceKey()) + || getBoolean(store, preference.getTextPreferenceKey()); + } + protected void installOverrideIndicator(boolean provideAST) { uninstallOverrideIndicator(); IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java index 0af24ea3853..e4a39ea49c0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java @@ -53,6 +53,8 @@ import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; public class OverrideIndicatorManager implements ICReconcilingListener { + static final String ANNOTATION_TYPE = "org.eclipse.cdt.ui.overrideIndicator"; //$NON-NLS-1$ + private static final String MESSAGE_SEPARATOR = ";\n"; //$NON-NLS-1$ public static class OverrideInfo {