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
;
15 import eu
.etaxonomy
.taxeditor
.store
.model
.Resources
;
17 public class ErrorAnnotation
extends Annotation
implements IAnnotationPresentation
{
18 private IMarker marker
;
21 private Position position
;
23 // error identifiers, images and colors
24 public static String ERROR_TYPE
= "error.type";
25 public static Image ERROR_IMAGE
= ImageResources
.getImage(ImageResources
.ACTIVE_DELETE_ICON
);
26 public static final RGB ERROR_RGB
= new RGB(255, 0, 0);
28 public ErrorAnnotation(IMarker marker
) {
32 public ErrorAnnotation(int line
, String text
) {
33 super(ERROR_TYPE
, false, text
);
39 public IMarker
getMarker() {
43 public int getLine() {
47 public String
getText() {
48 return "Error in the string " + text
;
51 public int getLayer() {
55 public String
getType() {
59 public Position
getPosition() {
63 public void setPosition(Position position
) {
64 this.position
= position
;
68 public void paint(GC gc
, Canvas canvas
, Rectangle bounds
) {
69 Point canvasSize
= canvas
.getSize();
76 if (y
+ h
> canvasSize
.y
)
87 Image image
= ImageResources
.getImage(ImageResources
.ERROR_ANNOTATION_ICON
);
89 Rectangle r
= image
.getBounds();
91 int destX
= x
+ w
- r
.width
;
92 int destY
= y
+ h
- r
.height
;
94 gc
.drawImage(image
, 0, 0, r
.width
, r
.height
, destX
, destY
, r
.width
, r
.height
);