1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.ui.section.supplemental;
|
5
|
|
6
|
import org.eclipse.swt.events.SelectionListener;
|
7
|
|
8
|
import eu.etaxonomy.cdm.model.common.Annotation;
|
9
|
import eu.etaxonomy.cdm.model.common.AnnotationType;
|
10
|
import eu.etaxonomy.cdm.model.term.TermType;
|
11
|
import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
|
12
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
13
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
14
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
15
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
16
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
17
|
|
18
|
/**
|
19
|
* <p>AnnotationElement class.</p>
|
20
|
*
|
21
|
* @author nho
|
22
|
*/
|
23
|
public class AnnotationElement extends AbstractEntityCollectionElement<Annotation>{
|
24
|
|
25
|
private TextWithLabelElement text;
|
26
|
private TermComboElement<AnnotationType> combo_annotationType;
|
27
|
|
28
|
/**
|
29
|
* <p>Constructor for AnnotationElement.</p>
|
30
|
*
|
31
|
* @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
|
32
|
* @param annotation a {@link eu.etaxonomy.cdm.model.common.Annotation} object.
|
33
|
* @param style a int.
|
34
|
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
|
35
|
* @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
|
36
|
*/
|
37
|
public AnnotationElement(CdmFormFactory cdmFormFactory, AbstractFormSection formElement, Annotation annotation, SelectionListener removeListener, int style) {
|
38
|
super(cdmFormFactory, formElement, annotation, removeListener, null, style);
|
39
|
}
|
40
|
|
41
|
@Override
|
42
|
public void createControls(ICdmFormElement element, int style) {
|
43
|
combo_annotationType = formFactory.createDefinedTermComboElement(TermType.AnnotationType, this, "Annotation Type", null, style);
|
44
|
|
45
|
text = formFactory.createMultiLineTextWithLabel(this, "Annotation", 100, style);
|
46
|
}
|
47
|
|
48
|
@Override
|
49
|
public void setEntity(Annotation entity) {
|
50
|
this.entity = entity;
|
51
|
combo_annotationType.setSelection(getEntity().getAnnotationType());
|
52
|
text.setText(entity.getText());
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
public void handleEvent(Object eventSource) {
|
57
|
if(eventSource == combo_annotationType){
|
58
|
getEntity().setAnnotationType(combo_annotationType.getSelection());
|
59
|
}else if(eventSource == text){
|
60
|
getEntity().setText(text.getText());
|
61
|
}
|
62
|
}
|
63
|
}
|