1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for Annotation refresh problem (56760)

This commit is contained in:
Bogdan Gheorghe 2004-03-30 23:13:39 +00:00
parent c3f3e1e881
commit c2ca5725c1
3 changed files with 17 additions and 72 deletions

View file

@ -1,3 +1,11 @@
2004-03-30 Bogdan Gheorghe
Modified the AnnotationModel to solve all annotation refresh problems.
* src/org/eclipse/cdt/internal/ui/editor/CEditor.java
* src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotationModel.java
2004-03-30 Alain Magloire 2004-03-30 Alain Magloire
New set of icons from Chris Wiebe. New set of icons from Chris Wiebe.

View file

@ -51,7 +51,6 @@ import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.contentassist.ContentAssistant; import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistant; import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationAccess;
import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IOverviewRuler; import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISharedTextColors; import org.eclipse.jface.text.source.ISharedTextColors;
@ -80,7 +79,6 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.editors.text.TextEditor; import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.editors.text.TextEditorPreferenceConstants;
import org.eclipse.ui.editors.text.TextFileDocumentProvider; import org.eclipse.ui.editors.text.TextFileDocumentProvider;
import org.eclipse.ui.part.EditorActionBarContributor; import org.eclipse.ui.part.EditorActionBarContributor;
import org.eclipse.ui.part.IShowInSource; import org.eclipse.ui.part.IShowInSource;
@ -88,9 +86,7 @@ import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.texteditor.AnnotationPreference; import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.ContentAssistAction; import org.eclipse.ui.texteditor.ContentAssistAction;
import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
import org.eclipse.ui.texteditor.DefaultRangeIndicator; import org.eclipse.ui.texteditor.DefaultRangeIndicator;
import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.ui.texteditor.IEditorStatusLine;
import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.MarkerAnnotation; import org.eclipse.ui.texteditor.MarkerAnnotation;
@ -657,6 +653,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
if (nextError != null) { if (nextError != null) {
gotoMarker(nextError); gotoMarker(nextError);
IWorkbenchPage page = getSite().getPage(); IWorkbenchPage page = getSite().getPage();
@ -904,41 +901,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
c_file ? LANGUAGE_C : LANGUAGE_CPP); c_file ? LANGUAGE_C : LANGUAGE_CPP);
fSourceViewerDecorationSupport = fSourceViewerDecorationSupport =
new SourceViewerDecorationSupport(sourceViewer, fOverviewRuler, fAnnotationAccess, sharedColors); new SourceViewerDecorationSupport(sourceViewer, fOverviewRuler, fAnnotationAccess, sharedColors);
configureSourceViewerDecorationSupport();
getSourceViewerDecorationSupport(sourceViewer);
return sourceViewer; return sourceViewer;
} }
/**
* Creates the annotation access for this editor.
* @return the created annotation access
*/
protected IAnnotationAccess createAnnotationAccess() {
return new DefaultMarkerAnnotationAccess(fAnnotationPreferences);
}
protected void configureSourceViewerDecorationSupport() {
Iterator e = fAnnotationPreferences.getAnnotationPreferences().iterator();
while (e.hasNext())
fSourceViewerDecorationSupport.setAnnotationPreference((AnnotationPreference) e.next());
fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(
DefaultMarkerAnnotationAccess.UNKNOWN,
TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR,
TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION,
TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER,
0);
fSourceViewerDecorationSupport.setCharacterPairMatcher(fBracketMatcher);
fSourceViewerDecorationSupport.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR);
fSourceViewerDecorationSupport.setCursorLinePainterPreferenceKeys(
ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE,
ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
fSourceViewerDecorationSupport.setMarginPainterPreferenceKeys(
ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN,
ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR,
ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);
fSourceViewerDecorationSupport.setSymbolicFontName(getFontPropertyPreferenceKey());
}
/** Outliner context menu Id */ /** Outliner context menu Id */
protected String fOutlinerContextMenuId; protected String fOutlinerContextMenuId;

View file

@ -7,13 +7,14 @@ package org.eclipse.cdt.internal.ui.editor;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.jface.text.Position; import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.ui.texteditor.MarkerAnnotation; import org.eclipse.ui.texteditor.MarkerAnnotation;
import org.eclipse.ui.texteditor.MarkerUtilities;
import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel; import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
public class CMarkerAnnotationModel extends ResourceMarkerAnnotationModel { public class CMarkerAnnotationModel extends ResourceMarkerAnnotationModel {
/** /**
* Constructor for CMarkerAnnotationModel * Constructor for CMarkerAnnotationModel
*/ */
@ -25,6 +26,7 @@ public class CMarkerAnnotationModel extends ResourceMarkerAnnotationModel {
* @see AbstractMarkerAnnotationModel#createMarkerAnnotation(IMarker) * @see AbstractMarkerAnnotationModel#createMarkerAnnotation(IMarker)
*/ */
protected MarkerAnnotation createMarkerAnnotation(IMarker marker) { protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
String markerType = MarkerUtilities.getMarkerType(marker);
return new CMarkerAnnotation(marker, fDocument); return new CMarkerAnnotation(marker, fDocument);
} }
/** /**
@ -40,37 +42,4 @@ public class CMarkerAnnotationModel extends ResourceMarkerAnnotationModel {
super.modifyMarkerAnnotation(marker); super.modifyMarkerAnnotation(marker);
} }
/**
* Adds the given annotation to this model. Associates the
* annotation with the given position. If requested, all annotation
* model listeners are informed about this model change. If the annotation
* is already managed by this model nothing happens.
*
* @param annotation the annotation to add
* @param position the associate position
* @param fireModelChange indicates whether to notify all model listeners
*/
protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged){
if (!fAnnotations.containsKey(annotation)) {
// @@@ This is an unfortunate hack because we cannot override addAnnotationMarker() and if we
// update a marker position, there's no way to update the annotation
if(annotation instanceof CMarkerAnnotation) {
int start = ((CMarkerAnnotation)annotation).getErrorStart();
if(start != -1 && start != position.getOffset()) {
position.setOffset(start);
position.setLength(((CMarkerAnnotation)annotation).getErrorLength());
}
}
fAnnotations.put(annotation, position);
try {
addPosition(fDocument, position);
} catch (Exception e) {
}
if (fireModelChanged)
fireModelChanged();
}
}
} }