1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.ui.section.supplemental;
|
5
|
|
6
|
import java.util.Collection;
|
7
|
|
8
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
9
|
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
|
10
|
import eu.etaxonomy.cdm.model.common.Annotation;
|
11
|
import eu.etaxonomy.cdm.model.common.AnnotationType;
|
12
|
import eu.etaxonomy.cdm.model.common.Language;
|
13
|
import eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade;
|
14
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
15
|
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
|
16
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
17
|
|
18
|
/**
|
19
|
* <p>AnnotationSection class.</p>
|
20
|
*
|
21
|
* @author n.hoffmann
|
22
|
* @created Nov 5, 2009
|
23
|
* @version 1.0
|
24
|
*/
|
25
|
public class AnnotationSection extends AbstractEntityCollectionSection<AnnotatableEntity, Annotation>{
|
26
|
|
27
|
/**
|
28
|
* <p>Constructor for AnnotationSection.</p>
|
29
|
*
|
30
|
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
|
31
|
* @param style a int.
|
32
|
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade} object.
|
33
|
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
34
|
*/
|
35
|
public AnnotationSection(CdmFormFactoryFacade cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
|
36
|
super(cdmFormFactory, conversation, parentElement, "Annotations", style);
|
37
|
}
|
38
|
|
39
|
/** {@inheritDoc} */
|
40
|
@Override
|
41
|
public Annotation createNewElement() {
|
42
|
String text = "";
|
43
|
AnnotationType type = AnnotationType.EDITORIAL();
|
44
|
Language language = CdmStore.getDefaultLanguage();
|
45
|
|
46
|
return Annotation.NewInstance(text, type, language);
|
47
|
}
|
48
|
|
49
|
/** {@inheritDoc} */
|
50
|
@Override
|
51
|
public Collection<Annotation> getCollection(AnnotatableEntity entity) {
|
52
|
return entity.getAnnotations();
|
53
|
}
|
54
|
|
55
|
/** {@inheritDoc} */
|
56
|
@Override
|
57
|
public String getEmptyString() {
|
58
|
return "No annotations yet.";
|
59
|
}
|
60
|
|
61
|
/** {@inheritDoc} */
|
62
|
@Override
|
63
|
protected String getTooltipString() {
|
64
|
return "Create a new annotation";
|
65
|
}
|
66
|
|
67
|
/** {@inheritDoc} */
|
68
|
@Override
|
69
|
public void addElement(Annotation element) {
|
70
|
getEntity().addAnnotation(element);
|
71
|
}
|
72
|
|
73
|
/** {@inheritDoc} */
|
74
|
@Override
|
75
|
public void removeElement(Annotation element) {
|
76
|
getEntity().removeAnnotation(element);
|
77
|
}
|
78
|
}
|