1 11 package org.eclipse.ui.texteditor; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.core.resources.IMarker; 16 import org.eclipse.jface.text.source.Annotation; 17 import org.eclipse.ui.internal.editors.text.EditorsPlugin; 18 19 20 26 public class SimpleMarkerAnnotation extends Annotation { 27 28 private IMarker fMarker; 29 30 36 public SimpleMarkerAnnotation(IMarker marker) { 37 this(EditorsPlugin.getDefault().getAnnotationTypeLookup().getAnnotationType(marker), marker); 38 } 39 40 46 public SimpleMarkerAnnotation(String annotationType, IMarker marker) { 47 super(annotationType, true, null); 48 Assert.isNotNull(marker); 49 fMarker= marker; 50 } 51 52 57 public IMarker getMarker() { 58 return fMarker; 59 } 60 61 68 public boolean equals(Object o) { 69 if (o != null && o.getClass() == getClass()) 70 return fMarker.equals(((SimpleMarkerAnnotation) o).fMarker); 71 return false; 72 } 73 74 77 public int hashCode() { 78 return fMarker.hashCode(); 79 } 80 81 88 public void update() { 89 updateType(); 90 } 91 92 97 private void updateType() { 98 String annotationType= EditorsPlugin.getDefault().getAnnotationTypeLookup().getAnnotationType(fMarker); 99 if (annotationType != null && !annotationType.equals(getType())) 100 setType(annotationType); 101 } 102 103 106 public String getText() { 107 return MarkerUtilities.getMessage(fMarker); 108 } 109 } 110 | Popular Tags |