From c2ca5725c1998e130f7455e180eeacd1106c5a11 Mon Sep 17 00:00:00 2001 From: Bogdan Gheorghe Date: Tue, 30 Mar 2004 23:13:39 +0000 Subject: [PATCH] Fix for Annotation refresh problem (56760) --- core/org.eclipse.cdt.ui/ChangeLog | 8 ++++ .../cdt/internal/ui/editor/CEditor.java | 40 ++---------------- .../ui/editor/CMarkerAnnotationModel.java | 41 +++---------------- 3 files changed, 17 insertions(+), 72 deletions(-) diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 607a392db63..ba7248d7fae 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -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 New set of icons from Chris Wiebe. 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 5ce5fed5ce1..40025c354f1 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 @@ -51,7 +51,6 @@ import org.eclipse.jface.text.Position; import org.eclipse.jface.text.contentassist.ContentAssistant; import org.eclipse.jface.text.contentassist.IContentAssistant; 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.IOverviewRuler; 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.actions.ActionGroup; 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.part.EditorActionBarContributor; 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.AnnotationPreference; import org.eclipse.ui.texteditor.ContentAssistAction; -import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess; import org.eclipse.ui.texteditor.DefaultRangeIndicator; -import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.MarkerAnnotation; @@ -657,6 +653,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS if (nextError != null) { + gotoMarker(nextError); IWorkbenchPage page = getSite().getPage(); @@ -904,41 +901,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS c_file ? LANGUAGE_C : LANGUAGE_CPP); fSourceViewerDecorationSupport = new SourceViewerDecorationSupport(sourceViewer, fOverviewRuler, fAnnotationAccess, sharedColors); - configureSourceViewerDecorationSupport(); + + getSourceViewerDecorationSupport(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 */ protected String fOutlinerContextMenuId; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotationModel.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotationModel.java index 90f780e1c78..ce6d2ba1a57 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotationModel.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotationModel.java @@ -7,13 +7,14 @@ package org.eclipse.cdt.internal.ui.editor; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.source.Annotation; +import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; import org.eclipse.ui.texteditor.MarkerAnnotation; +import org.eclipse.ui.texteditor.MarkerUtilities; import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel; + public class CMarkerAnnotationModel extends ResourceMarkerAnnotationModel { - + /** * Constructor for CMarkerAnnotationModel */ @@ -25,6 +26,7 @@ public class CMarkerAnnotationModel extends ResourceMarkerAnnotationModel { * @see AbstractMarkerAnnotationModel#createMarkerAnnotation(IMarker) */ protected MarkerAnnotation createMarkerAnnotation(IMarker marker) { + String markerType = MarkerUtilities.getMarkerType(marker); return new CMarkerAnnotation(marker, fDocument); } /** @@ -40,37 +42,4 @@ public class CMarkerAnnotationModel extends ResourceMarkerAnnotationModel { 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(); - } - } }