1
|
/**
|
2
|
* Copyright (C) 2013 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.ui.section.supplemental;
|
10
|
|
11
|
import java.util.Collection;
|
12
|
import java.util.Comparator;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
|
15
|
import eu.etaxonomy.cdm.model.common.Annotation;
|
16
|
import eu.etaxonomy.cdm.model.common.AnnotationType;
|
17
|
import eu.etaxonomy.cdm.model.common.Language;
|
18
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
21
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
22
|
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
|
23
|
|
24
|
/**
|
25
|
* @author n.hoffmann
|
26
|
* @created Nov 5, 2009
|
27
|
*/
|
28
|
public class AnnotationSection extends AbstractEntityCollectionSection<AnnotatableEntity, Annotation>{
|
29
|
|
30
|
public AnnotationSection(CdmFormFactory cdmFormFactory, ICdmFormElement parentElement, int style) {
|
31
|
super(cdmFormFactory, parentElement, "Annotations", style);
|
32
|
}
|
33
|
|
34
|
@Override
|
35
|
public Annotation createNewElement() {
|
36
|
String text = "";
|
37
|
AnnotationType type = AnnotationType.EDITORIAL();
|
38
|
Language language = CdmStore.getDefaultLanguage();
|
39
|
|
40
|
return Annotation.NewInstance(text, type, language);
|
41
|
}
|
42
|
|
43
|
@Override
|
44
|
public Collection<Annotation> getCollection(AnnotatableEntity entity) {
|
45
|
return entity.getAnnotations();
|
46
|
}
|
47
|
|
48
|
@Override
|
49
|
public Comparator<Annotation> getComparator() {
|
50
|
return new DefaultCdmBaseComparator<>();
|
51
|
}
|
52
|
|
53
|
@Override
|
54
|
public String getEmptyString() {
|
55
|
return "No annotations yet.";
|
56
|
}
|
57
|
|
58
|
@Override
|
59
|
protected String getTooltipString() {
|
60
|
return "Create a new annotation";
|
61
|
}
|
62
|
|
63
|
@Override
|
64
|
public void addElement(Annotation element) {
|
65
|
getEntity().addAnnotation(element);
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
public void removeElement(Annotation element) {
|
70
|
getEntity().removeAnnotation(element);
|
71
|
}
|
72
|
|
73
|
@Override
|
74
|
public Annotation addExisting() {
|
75
|
// TODO Auto-generated method stub
|
76
|
return null;
|
77
|
}
|
78
|
|
79
|
@Override
|
80
|
public boolean allowAddExisting() {
|
81
|
// TODO Auto-generated method stub
|
82
|
return false;
|
83
|
}
|
84
|
}
|