1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Bug 322753 - It should be possible to disable the override indicator

Patch from Marc-Andre Laperle
This commit is contained in:
Anton Leherbauer 2010-09-23 12:08:50 +00:00
parent a0b5fe2c89
commit 59d692e064
2 changed files with 63 additions and 1 deletions

View file

@ -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 <code>true</code> 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 <code>true</code> if the key exists in the store and its value is <code>true</code>
* @since 5.3
*/
private boolean getBoolean(IPreferenceStore store, String key) {
return key != null && store.getBoolean(key);
}
/**
* Tells whether override indicators are shown.
*
* @return <code>true</code> 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());

View file

@ -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 {