--- /dev/null
+package eu.etaxonomy.taxeditor.editor.name.container;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationPresentation;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+
+import eu.etaxonomy.taxeditor.model.ImageResources;
+
+/**
+ * <p>EditorAnnotation class.</p>
+ *
+ * @author n.hoffmann
+ * @version $Id: $
+ */
+public class EditorAnnotation extends Annotation implements IAnnotationPresentation {
+ private static final Logger logger = Logger
+ .getLogger(EditorAnnotation.class);
+ private IMarker marker;
+ private String text;
+ private int line;
+ private Position position;
+
+ // error identifiers, images and colors
+ /** Constant <code>ERROR_TYPE="editor.error.type"</code> */
+ public static String ERROR_TYPE = "editor.error.type";
+ /** Constant <code>ERROR_IMAGE</code> */
+ public static Image ERROR_IMAGE = ImageResources.getImage(ImageResources.ERROR_ANNOTATION_ICON);
+ /** Constant <code>ERROR_RGB</code> */
+ public static final RGB ERROR_RGB = new RGB(255, 0, 0);
+
+ /** Constant <code>WARNING_TYPE="editor.warning.type"</code> */
+ public static String WARNING_TYPE = "editor.warning.type";
+ /** Constant <code>WARNING_IMAGE</code> */
+ public static Image WARNING_IMAGE = ImageResources.getImage(ImageResources.WARNING_ANNOTATION_ICON);
+ /** Constant <code>WARNING_RGB</code> */
+ public static final RGB WARNING_RGB = new RGB(244, 200, 45);
+
+ /**
+ * <p>Constructor for EditorAnnotation.</p>
+ *
+ * @param marker a org.eclipse.core.resources.IMarker object.
+ */
+ public EditorAnnotation(IMarker marker) {
+ this.marker = marker;
+ }
+
+ /**
+ * <p>Constructor for EditorAnnotation.</p>
+ *
+ * @param line a int.
+ * @param text a {@link java.lang.String} object.
+ */
+ public EditorAnnotation(int line, String text) {
+ this(ERROR_TYPE, line, text);
+ }
+
+ /**
+ * <p>Constructor for EditorAnnotation.</p>
+ *
+ * @param type a {@link java.lang.String} object.
+ * @param line a int.
+ * @param text a {@link java.lang.String} object.
+ */
+ public EditorAnnotation(String type, int line, String text) {
+ super(type, false, text);
+ this.marker = null;
+ this.line = line;
+ this.text = text;
+ }
+
+ /**
+ * <p>Getter for the field <code>marker</code>.</p>
+ *
+ * @return a org.eclipse.core.resources.IMarker object.
+ */
+ public IMarker getMarker() {
+ return marker;
+ }
+
+ /**
+ * <p>Getter for the field <code>line</code>.</p>
+ *
+ * @return a int.
+ */
+ public int getLine() {
+ return line;
+ }
+
+ /**
+ * <p>Getter for the field <code>text</code>.</p>
+ *
+ * @return a {@link java.lang.String} object.
+ */
+ public String getText() {
+ if (ERROR_TYPE.equals(getType())) {
+ return "Error: " + text;
+ }
+ if (WARNING_TYPE.equals(getType())) {
+ return "Warning: " + text;
+ }
+ return super.getText();
+ }
+
+ /**
+ * @return
+ */
+ private Image getImage() {
+ if (ERROR_TYPE.equals(getType())) {
+ return ERROR_IMAGE;
+ }
+ if (WARNING_TYPE.equals(getType())) {
+ return WARNING_IMAGE;
+ }
+ logger.warn("No image for type " + getType());
+ return null;
+ }
+
+ /**
+ * <p>getLayer</p>
+ *
+ * @return a int.
+ */
+ public int getLayer() {
+ return 3;
+ }
+
+
+ /**
+ * <p>Getter for the field <code>position</code>.</p>
+ *
+ * @return a {@link org.eclipse.jface.text.Position} object.
+ */
+ public Position getPosition() {
+ return position;
+ }
+
+ /**
+ * <p>Setter for the field <code>position</code>.</p>
+ *
+ * @param position a {@link org.eclipse.jface.text.Position} object.
+ */
+ public void setPosition(Position position) {
+ this.position = position;
+ }
+
+
+ /** {@inheritDoc} */
+ public void paint(GC gc, Canvas canvas, Rectangle bounds) {
+ Point canvasSize= canvas.getSize();
+
+ int x= 0;
+ int y= bounds.y;
+ int w= canvasSize.x;
+ int h= bounds.height;
+
+ if (y + h > canvasSize.y)
+ h= canvasSize.y - y;
+
+ if (y < 0) {
+ h= h + y;
+ y= 0;
+ }
+
+ if (h <= 0)
+ return;
+
+ Image image = getImage();
+
+ if (image == null) {
+ return;
+ }
+
+ Rectangle r = image.getBounds();
+
+ int destX = x + w - r.width;
+ int destY = y + h - r.height;
+
+ gc.drawImage(image, 0, 0, r.width, r.height, destX, destY, r.width, r.height);
+ }
+}