1
|
package eu.etaxonomy.taxeditor.singlesource.editor.name.container;
|
2
|
|
3
|
import javax.naming.OperationNotSupportedException;
|
4
|
|
5
|
import org.apache.log4j.Logger;
|
6
|
import org.eclipse.swt.graphics.GC;
|
7
|
import org.eclipse.swt.graphics.Image;
|
8
|
import org.eclipse.swt.graphics.RGB;
|
9
|
import org.eclipse.swt.graphics.Rectangle;
|
10
|
import org.eclipse.swt.widgets.Canvas;
|
11
|
|
12
|
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
|
13
|
import eu.etaxonomy.taxeditor.model.ImageResources;
|
14
|
import eu.etaxonomy.taxeditor.singlesource.ImplementationLoader;
|
15
|
|
16
|
/**
|
17
|
* <p>EditorAnnotation class.</p>
|
18
|
*
|
19
|
* @author n.hoffmann
|
20
|
* @version $Id: $
|
21
|
*/
|
22
|
public class EditorAnnotationFacade implements IEditorAnnotation {
|
23
|
private static final Logger logger = Logger
|
24
|
.getLogger(EditorAnnotationFacade.class);
|
25
|
|
26
|
protected IEditorAnnotation IMPL;
|
27
|
|
28
|
private Object marker;
|
29
|
|
30
|
/**
|
31
|
* <p>Constructor for NameViewer.</p>
|
32
|
*
|
33
|
* @param parent a {@link org.eclipse.swt.widgets.Composite} object.
|
34
|
*/
|
35
|
public EditorAnnotationFacade(EditorAnnotationFacade.EditorAnnotationType type, Integer line, String text) throws OperationNotSupportedException {
|
36
|
|
37
|
IMPL = (IEditorAnnotation)ImplementationLoader.newInstance(EditorAnnotationFacade.class, type, line, text);
|
38
|
}
|
39
|
|
40
|
public enum EditorAnnotationType{
|
41
|
WARNING(ImageResources.WARNING_ANNOTATION_ICON, 244, 200, 45),
|
42
|
ERROR(ImageResources.ERROR_ANNOTATION_ICON, 255, 0, 0);
|
43
|
|
44
|
public Image image;
|
45
|
public RGB color;
|
46
|
|
47
|
EditorAnnotationType(String imageResource, int r, int g, int b){
|
48
|
image = ImageResources.getImage(imageResource);
|
49
|
color = new RGB(r, g, b);
|
50
|
}
|
51
|
|
52
|
/**
|
53
|
* @param problem
|
54
|
* @return
|
55
|
*/
|
56
|
public static EditorAnnotationType getTypeByProblem(
|
57
|
ParserProblem problem) {
|
58
|
if (problem.isWarning()) {
|
59
|
return WARNING;
|
60
|
}else if (problem.isError()) {
|
61
|
return ERROR;
|
62
|
}
|
63
|
return null;
|
64
|
}
|
65
|
|
66
|
}
|
67
|
|
68
|
// // error identifiers, images and colors
|
69
|
// /** Constant <code>ERROR_TYPE="editor.error.type"</code> */
|
70
|
// public static String ERROR_TYPE = "editor.error.type";
|
71
|
// /** Constant <code>ERROR_IMAGE</code> */
|
72
|
// public static Image ERROR_IMAGE = ImageResources.getImage(ImageResources.ERROR_ANNOTATION_ICON);
|
73
|
// /** Constant <code>ERROR_RGB</code> */
|
74
|
// public static final RGB ERROR_RGB = new RGB(255, 0, 0);
|
75
|
//
|
76
|
// /** Constant <code>WARNING_TYPE="editor.warning.type"</code> */
|
77
|
// public static String WARNING_TYPE = "editor.warning.type";
|
78
|
// /** Constant <code>WARNING_IMAGE</code> */
|
79
|
// public static Image WARNING_IMAGE = ImageResources.getImage(ImageResources.WARNING_ANNOTATION_ICON);
|
80
|
// /** Constant <code>WARNING_RGB</code> */
|
81
|
// public static final RGB WARNING_RGB = new RGB(244, 200, 45);
|
82
|
|
83
|
|
84
|
public EditorAnnotationFacade(ParserProblem problem) throws OperationNotSupportedException {
|
85
|
this(EditorAnnotationType.getTypeByProblem(problem), 0, problem.getMessage());
|
86
|
}
|
87
|
|
88
|
|
89
|
/**
|
90
|
* <p>Constructor for EditorAnnotation.</p>
|
91
|
*
|
92
|
* @param marker a org.eclipse.core.resources.IMarker object.
|
93
|
* @throws OperationNotSupportedException
|
94
|
*/
|
95
|
public EditorAnnotationFacade(Object marker) throws OperationNotSupportedException {
|
96
|
IMPL.setMarker(marker);
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* <p>Constructor for EditorAnnotation.</p>
|
101
|
*
|
102
|
* @param line a int.
|
103
|
* @param text a {@link java.lang.String} object.
|
104
|
* @throws OperationNotSupportedException
|
105
|
*/
|
106
|
public EditorAnnotationFacade(int line, String text) throws OperationNotSupportedException {
|
107
|
this(EditorAnnotationType.ERROR, line, text);
|
108
|
}
|
109
|
|
110
|
/**
|
111
|
* <p>Getter for the field <code>marker</code>.</p>
|
112
|
*
|
113
|
* @return a org.eclipse.core.resources.IMarker object.
|
114
|
* @throws OperationNotSupportedException
|
115
|
*/
|
116
|
public Object getMarker() throws OperationNotSupportedException {
|
117
|
return IMPL.getMarker();
|
118
|
}
|
119
|
|
120
|
public void setMarker(Object marker) throws OperationNotSupportedException {
|
121
|
IMPL.setMarker(marker);
|
122
|
}
|
123
|
|
124
|
/**
|
125
|
* <p>Getter for the field <code>line</code>.</p>
|
126
|
*
|
127
|
* @return a int.
|
128
|
* @throws OperationNotSupportedException
|
129
|
*/
|
130
|
public int getLine() throws OperationNotSupportedException {
|
131
|
return IMPL.getLine();
|
132
|
}
|
133
|
|
134
|
/**
|
135
|
* <p>Getter for the field <code>text</code>.</p>
|
136
|
*
|
137
|
* @return a {@link java.lang.String} object.
|
138
|
* @throws OperationNotSupportedException
|
139
|
*/
|
140
|
@Override
|
141
|
public String getText() throws OperationNotSupportedException {
|
142
|
return IMPL.getText();
|
143
|
}
|
144
|
|
145
|
/* (non-Javadoc)
|
146
|
* @see eu.etaxonomy.taxeditor.singlesource.editor.name.container.IEditorAnnotation#getLayer()
|
147
|
*/
|
148
|
@Override
|
149
|
public int getLayer() throws OperationNotSupportedException {
|
150
|
return IMPL.getLayer();
|
151
|
}
|
152
|
|
153
|
|
154
|
/**
|
155
|
* <p>Getter for the field <code>position</code>.</p>
|
156
|
*
|
157
|
* @return a {@link org.eclipse.jface.text.Position} object.
|
158
|
* @throws OperationNotSupportedException
|
159
|
*/
|
160
|
public Object getPosition() throws OperationNotSupportedException {
|
161
|
return IMPL.getPosition();
|
162
|
}
|
163
|
|
164
|
/**
|
165
|
* <p>Setter for the field <code>position</code>.</p>
|
166
|
*
|
167
|
* @param position a {@link org.eclipse.jface.text.Position} object.
|
168
|
* @throws OperationNotSupportedException
|
169
|
*/
|
170
|
public void setPosition(Object position) throws OperationNotSupportedException {
|
171
|
IMPL.setPosition(position);
|
172
|
}
|
173
|
|
174
|
|
175
|
/* (non-Javadoc)
|
176
|
* @see eu.etaxonomy.taxeditor.singlesource.editor.name.container.IEditorAnnotation#paint(org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle)
|
177
|
*/
|
178
|
@Override
|
179
|
public void paint(GC gc, Canvas canvas, Rectangle bounds) throws OperationNotSupportedException {
|
180
|
IMPL.paint(gc, canvas, bounds);
|
181
|
}
|
182
|
}
|