949b7979f655c2c68ba8771588c39fe7ff7b6f2d
1 package eu
.etaxonomy
.taxeditor
.editor
;
3 import org
.eclipse
.core
.resources
.IMarker
;
4 import org
.eclipse
.jface
.text
.Position
;
5 import org
.eclipse
.jface
.text
.source
.Annotation
;
6 import org
.eclipse
.jface
.text
.source
.IAnnotationPresentation
;
7 import org
.eclipse
.swt
.graphics
.GC
;
8 import org
.eclipse
.swt
.graphics
.Image
;
9 import org
.eclipse
.swt
.graphics
.Point
;
10 import org
.eclipse
.swt
.graphics
.RGB
;
11 import org
.eclipse
.swt
.graphics
.Rectangle
;
12 import org
.eclipse
.swt
.widgets
.Canvas
;
14 import eu
.etaxonomy
.taxeditor
.store
.model
.ImageResources
;
16 public class ErrorAnnotation
extends Annotation
implements IAnnotationPresentation
{
17 private IMarker marker
;
20 private Position position
;
22 // error identifiers, images and colors
23 public static String ERROR_TYPE
= "error.type";
24 public static Image ERROR_IMAGE
= ImageResources
.getImage(ImageResources
.ACTIVE_DELETE_ICON
);
25 public static final RGB ERROR_RGB
= new RGB(255, 0, 0);
27 public ErrorAnnotation(IMarker marker
) {
31 public ErrorAnnotation(int line
, String text
) {
32 super(ERROR_TYPE
, false, text
);
38 public IMarker
getMarker() {
42 public int getLine() {
46 public String
getText() {
47 return "Error in the string " + text
;
50 public int getLayer() {
54 public String
getType() {
58 public Position
getPosition() {
62 public void setPosition(Position position
) {
63 this.position
= position
;
67 public void paint(GC gc
, Canvas canvas
, Rectangle bounds
) {
68 Point canvasSize
= canvas
.getSize();
75 if (y
+ h
> canvasSize
.y
)
86 Image image
= ImageResources
.getImage(ImageResources
.ERROR_ANNOTATION_ICON
);
88 Rectangle r
= image
.getBounds();
90 int destX
= x
+ w
- r
.width
;
91 int destY
= y
+ h
- r
.height
;
93 gc
.drawImage(image
, 0, 0, r
.width
, r
.height
, destX
, destY
, r
.width
, r
.height
);