1
|
/**
|
2
|
* Copyright (C) 2007 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.description;
|
10
|
|
11
|
import java.util.Collection;
|
12
|
import java.util.Comparator;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
|
15
|
import eu.etaxonomy.cdm.model.description.DescriptionBase;
|
16
|
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
20
|
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
|
21
|
|
22
|
/**
|
23
|
* @author n.hoffmann
|
24
|
* @created Mar 18, 2010
|
25
|
*/
|
26
|
public class DescriptionSourceSection extends
|
27
|
AbstractEntityCollectionSection<DescriptionBase, IdentifiableSource>{
|
28
|
|
29
|
public DescriptionSourceSection(CdmFormFactory cdmFormFactory,
|
30
|
ICdmFormElement parentElement, int style) {
|
31
|
super(cdmFormFactory, parentElement, "Sources", style);
|
32
|
}
|
33
|
|
34
|
@Override
|
35
|
public void addElement(IdentifiableSource element) {
|
36
|
getEntity().addSource(element);
|
37
|
}
|
38
|
|
39
|
@Override
|
40
|
public IdentifiableSource createNewElement() {
|
41
|
OriginalSourceType ost = OriginalSourceType.PrimaryTaxonomicSource;
|
42
|
return IdentifiableSource.NewInstance(ost);
|
43
|
}
|
44
|
|
45
|
@Override
|
46
|
public Collection<IdentifiableSource> getCollection(DescriptionBase entity) {
|
47
|
return entity.getSources();
|
48
|
}
|
49
|
|
50
|
@Override
|
51
|
public Comparator<IdentifiableSource> getComparator() {
|
52
|
return new DefaultCdmBaseComparator<>();
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
public String getEmptyString() {
|
57
|
return "No description sources yet.";
|
58
|
}
|
59
|
|
60
|
@Override
|
61
|
protected String getTooltipString() {
|
62
|
return "Add a reference as source for this description";
|
63
|
}
|
64
|
|
65
|
@Override
|
66
|
public void removeElement(IdentifiableSource element) {
|
67
|
getEntity().removeSource(element);
|
68
|
}
|
69
|
|
70
|
@Override
|
71
|
public IdentifiableSource addExisting() {
|
72
|
return null;
|
73
|
}
|
74
|
|
75
|
@Override
|
76
|
public boolean allowAddExisting() {
|
77
|
return false;
|
78
|
}
|
79
|
}
|