1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.ui.section.supplemental;
|
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.common.IIdentifiableEntity;
|
11
|
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
|
12
|
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
|
13
|
import eu.etaxonomy.cdm.model.media.Media;
|
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
|
import eu.etaxonomy.taxeditor.ui.section.description.SourceComparator;
|
18
|
|
19
|
/**
|
20
|
* <p>SourceSection class.</p>
|
21
|
*
|
22
|
* @author n.hoffmann
|
23
|
* @created Nov 17, 2009
|
24
|
* @version 1.0
|
25
|
*/
|
26
|
public class SourceSection extends AbstractEntityCollectionSection<IIdentifiableEntity, IdentifiableSource> {
|
27
|
|
28
|
/**
|
29
|
* <p>Constructor for SourceSection.</p>
|
30
|
*
|
31
|
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
|
32
|
* @param style a int.
|
33
|
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
|
34
|
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
35
|
*/
|
36
|
public SourceSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
|
37
|
super(cdmFormFactory, conversation, parentElement, "Sources", style);
|
38
|
}
|
39
|
|
40
|
/** {@inheritDoc} */
|
41
|
@Override
|
42
|
public IdentifiableSource createNewElement() {
|
43
|
IIdentifiableEntity entity = getEntity();
|
44
|
OriginalSourceType type;
|
45
|
if(entity instanceof Media) {
|
46
|
type = OriginalSourceType.PrimaryMediaSource;
|
47
|
}
|
48
|
else{
|
49
|
//default
|
50
|
type = OriginalSourceType.PrimaryTaxonomicSource;
|
51
|
}
|
52
|
return IdentifiableSource.NewInstance(type);
|
53
|
}
|
54
|
|
55
|
/** {@inheritDoc} */
|
56
|
@Override
|
57
|
public Collection<IdentifiableSource> getCollection(
|
58
|
IIdentifiableEntity entity) {
|
59
|
return entity.getSources();
|
60
|
}
|
61
|
|
62
|
@Override
|
63
|
public Comparator<IdentifiableSource> getComparator() {
|
64
|
return new SourceComparator();
|
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(IdentifiableSource element) {
|
82
|
getEntity().addSource(element);
|
83
|
}
|
84
|
|
85
|
/** {@inheritDoc} */
|
86
|
@Override
|
87
|
public void removeElement(IdentifiableSource element) {
|
88
|
getEntity().removeSource(element);
|
89
|
}
|
90
|
|
91
|
/**
|
92
|
* {@inheritDoc}
|
93
|
*/
|
94
|
@Override
|
95
|
public IdentifiableSource addExisting() {
|
96
|
// TODO Auto-generated method stub
|
97
|
return null;
|
98
|
}
|
99
|
|
100
|
/**
|
101
|
* {@inheritDoc}
|
102
|
*/
|
103
|
@Override
|
104
|
public boolean allowAddExisting() {
|
105
|
// TODO Auto-generated method stub
|
106
|
return false;
|
107
|
}
|
108
|
|
109
|
}
|