1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.ui.section.description;
|
5
|
|
6
|
import java.util.ArrayList;
|
7
|
import java.util.Collection;
|
8
|
import java.util.Collections;
|
9
|
import java.util.List;
|
10
|
|
11
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
12
|
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
|
13
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
14
|
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
|
15
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
16
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
17
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
18
|
|
19
|
/**
|
20
|
* <p>
|
21
|
* DescriptionElementSourceSection class.
|
22
|
* </p>
|
23
|
*
|
24
|
* @author n.hoffmann
|
25
|
* @created Nov 17, 2009
|
26
|
* @version 1.0
|
27
|
*/
|
28
|
public class DescriptionElementSourceSection extends
|
29
|
AbstractEntityCollectionSection<DescriptionElementBase, DescriptionElementSource> {
|
30
|
|
31
|
/**
|
32
|
* <p>
|
33
|
* Constructor for DescriptionElementSourceSection.
|
34
|
* </p>
|
35
|
*
|
36
|
* @param parentElement
|
37
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
38
|
* object.
|
39
|
* @param style
|
40
|
* a int.
|
41
|
* @param cdmFormFactory
|
42
|
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
|
43
|
* object.
|
44
|
* @param conversation
|
45
|
* a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
|
46
|
* object.
|
47
|
*/
|
48
|
public DescriptionElementSourceSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
|
49
|
ICdmFormElement parentElement, int style) {
|
50
|
super(cdmFormFactory, conversation, parentElement, "References", style);
|
51
|
}
|
52
|
|
53
|
/** {@inheritDoc} */
|
54
|
@Override
|
55
|
public DescriptionElementSource createNewElement() {
|
56
|
return DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
|
57
|
}
|
58
|
|
59
|
/** {@inheritDoc} */
|
60
|
@Override
|
61
|
public Collection<DescriptionElementSource> getCollection(DescriptionElementBase entity) {
|
62
|
List<DescriptionElementSource> sources = new ArrayList<DescriptionElementSource>(entity.getSources());
|
63
|
Collections.sort(sources, new SourceComparator());
|
64
|
return sources;
|
65
|
}
|
66
|
|
67
|
/** {@inheritDoc} */
|
68
|
@Override
|
69
|
public String getEmptyString() {
|
70
|
return "No references yet.";
|
71
|
}
|
72
|
|
73
|
/** {@inheritDoc} */
|
74
|
@Override
|
75
|
protected String getTooltipString() {
|
76
|
return "Create a new reference";
|
77
|
}
|
78
|
|
79
|
/** {@inheritDoc} */
|
80
|
@Override
|
81
|
public void addElement(DescriptionElementSource element) {
|
82
|
getEntity().addSource(element);
|
83
|
}
|
84
|
|
85
|
/** {@inheritDoc} */
|
86
|
@Override
|
87
|
public void removeElement(DescriptionElementSource element) {
|
88
|
getEntity().removeSource(element);
|
89
|
}
|
90
|
}
|