1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.ui.section.description;
|
5
|
|
6
|
import java.util.Collection;
|
7
|
import java.util.Comparator;
|
8
|
|
9
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
10
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
11
|
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
|
12
|
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
|
13
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
14
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
15
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
16
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
17
|
|
18
|
/**
|
19
|
* <p>
|
20
|
* DescriptionElementSourceSection class.
|
21
|
* </p>
|
22
|
*
|
23
|
* @author n.hoffmann
|
24
|
* @created Nov 17, 2009
|
25
|
* @version 1.0
|
26
|
*/
|
27
|
public class DescriptionElementSourceSection extends
|
28
|
AbstractEntityCollectionSection<DescriptionElementBase, DescriptionElementSource> {
|
29
|
|
30
|
private Reference defaultSource;
|
31
|
|
32
|
|
33
|
/**
|
34
|
* <p>
|
35
|
* Constructor for DescriptionElementSourceSection.
|
36
|
* </p>
|
37
|
*
|
38
|
* @param parentElement
|
39
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
40
|
* object.
|
41
|
* @param style
|
42
|
* a int.
|
43
|
* @param cdmFormFactory
|
44
|
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
|
45
|
* object.
|
46
|
* @param conversation
|
47
|
* a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
|
48
|
* object.
|
49
|
*/
|
50
|
public DescriptionElementSourceSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
|
51
|
ICdmFormElement parentElement, int style) {
|
52
|
super(cdmFormFactory, conversation, parentElement, "Sources", style);
|
53
|
}
|
54
|
|
55
|
/**
|
56
|
* <p>
|
57
|
* Constructor for DescriptionElementSourceSection.
|
58
|
* </p>
|
59
|
*
|
60
|
* @param parentElement
|
61
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
62
|
* object.
|
63
|
* @param style
|
64
|
* a int.
|
65
|
* @param cdmFormFactory
|
66
|
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
|
67
|
* object.
|
68
|
* @param defaultSource
|
69
|
* a default reference for new sources.
|
70
|
* @param conversation
|
71
|
* a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
|
72
|
* object.
|
73
|
*/
|
74
|
public DescriptionElementSourceSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
|
75
|
ICdmFormElement parentElement, Reference defaultSource, int style) {
|
76
|
super(cdmFormFactory, conversation, parentElement, "Sources", style);
|
77
|
this.defaultSource = defaultSource;
|
78
|
}
|
79
|
|
80
|
/** {@inheritDoc} */
|
81
|
@Override
|
82
|
public DescriptionElementSource createNewElement() {
|
83
|
DescriptionElementSource source = DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
|
84
|
if (defaultSource != null){
|
85
|
source.setCitation(defaultSource);
|
86
|
}
|
87
|
return source;
|
88
|
}
|
89
|
|
90
|
/** {@inheritDoc} */
|
91
|
@Override
|
92
|
public Collection<DescriptionElementSource> getCollection(DescriptionElementBase entity) {
|
93
|
return entity.getSources();
|
94
|
}
|
95
|
|
96
|
@Override
|
97
|
public Comparator<DescriptionElementSource> getComparator() {
|
98
|
return new SourceComparator();
|
99
|
}
|
100
|
|
101
|
/** {@inheritDoc} */
|
102
|
@Override
|
103
|
public String getEmptyString() {
|
104
|
return "No references yet.";
|
105
|
}
|
106
|
|
107
|
/** {@inheritDoc} */
|
108
|
@Override
|
109
|
protected String getTooltipString() {
|
110
|
return "Create a new reference";
|
111
|
}
|
112
|
|
113
|
/** {@inheritDoc} */
|
114
|
@Override
|
115
|
public void addElement(DescriptionElementSource element) {
|
116
|
getEntity().addSource(element);
|
117
|
}
|
118
|
|
119
|
/** {@inheritDoc} */
|
120
|
@Override
|
121
|
public void removeElement(DescriptionElementSource element) {
|
122
|
getEntity().removeSource(element);
|
123
|
}
|
124
|
|
125
|
/**
|
126
|
* {@inheritDoc}
|
127
|
*/
|
128
|
@Override
|
129
|
public DescriptionElementSource addExisting() {
|
130
|
return null;
|
131
|
}
|
132
|
|
133
|
/**
|
134
|
* {@inheritDoc}
|
135
|
*/
|
136
|
@Override
|
137
|
public boolean allowAddExisting() {
|
138
|
return false;
|
139
|
}
|
140
|
|
141
|
|
142
|
}
|