mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 10:15:39 +02:00
Bug 322753 - It should be possible to disable the override indicator
Patch from Marc-Andre Laperle
This commit is contained in:
parent
a0b5fe2c89
commit
59d692e064
2 changed files with 63 additions and 1 deletions
|
@ -147,6 +147,7 @@ import org.eclipse.ui.part.ShowInContext;
|
||||||
import org.eclipse.ui.preferences.ScopedPreferenceStore;
|
import org.eclipse.ui.preferences.ScopedPreferenceStore;
|
||||||
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
|
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
|
||||||
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
|
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
|
||||||
|
import org.eclipse.ui.texteditor.AnnotationPreference;
|
||||||
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
|
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
|
||||||
import org.eclipse.ui.texteditor.ContentAssistAction;
|
import org.eclipse.ui.texteditor.ContentAssistAction;
|
||||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||||
|
@ -1636,6 +1637,17 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
||||||
return;
|
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 (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
|
||||||
if (fProjectionModelUpdater != null) {
|
if (fProjectionModelUpdater != null) {
|
||||||
fProjectionModelUpdater.uninstall();
|
fProjectionModelUpdater.uninstall();
|
||||||
|
@ -2456,7 +2468,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
||||||
if (isMarkingOccurrences())
|
if (isMarkingOccurrences())
|
||||||
installOccurrencesFinder(false);
|
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) {
|
protected void installOverrideIndicator(boolean provideAST) {
|
||||||
uninstallOverrideIndicator();
|
uninstallOverrideIndicator();
|
||||||
IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
|
IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
|
||||||
|
|
|
@ -53,6 +53,8 @@ import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
|
||||||
|
|
||||||
public class OverrideIndicatorManager implements ICReconcilingListener {
|
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$
|
private static final String MESSAGE_SEPARATOR = ";\n"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static class OverrideInfo {
|
public static class OverrideInfo {
|
||||||
|
|
Loading…
Add table
Reference in a new issue