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.supplemental;
|
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.media.Media;
|
16
|
import eu.etaxonomy.cdm.model.reference.ISourceable;
|
17
|
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
20
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
21
|
import eu.etaxonomy.taxeditor.ui.section.description.SourceComparator;
|
22
|
|
23
|
/**
|
24
|
* @author n.hoffmann
|
25
|
* @created Nov 17, 2009
|
26
|
*/
|
27
|
public class SourceSection extends AbstractEntityCollectionSection<ISourceable, IdentifiableSource> {
|
28
|
|
29
|
public SourceSection(CdmFormFactory cdmFormFactory, ICdmFormElement parentElement, int style) {
|
30
|
super(cdmFormFactory, parentElement, "Sources", style);
|
31
|
}
|
32
|
|
33
|
@Override
|
34
|
public IdentifiableSource createNewElement() {
|
35
|
ISourceable entity = getEntity();
|
36
|
OriginalSourceType type;
|
37
|
if(entity instanceof Media) {
|
38
|
type = OriginalSourceType.PrimaryMediaSource;
|
39
|
}
|
40
|
else{
|
41
|
//default
|
42
|
type = OriginalSourceType.PrimaryTaxonomicSource;
|
43
|
}
|
44
|
return IdentifiableSource.NewInstance(type);
|
45
|
}
|
46
|
|
47
|
@Override
|
48
|
public Collection<IdentifiableSource> getCollection(
|
49
|
ISourceable entity) {
|
50
|
return entity.getSources();
|
51
|
}
|
52
|
|
53
|
@Override
|
54
|
public Comparator<IdentifiableSource> getComparator() {
|
55
|
return new SourceComparator();
|
56
|
}
|
57
|
|
58
|
@Override
|
59
|
public String getEmptyString() {
|
60
|
return "No references yet.";
|
61
|
}
|
62
|
|
63
|
@Override
|
64
|
protected String getTooltipString() {
|
65
|
return "Create a new reference.";
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
public void addElement(IdentifiableSource element) {
|
70
|
getEntity().addSource(element);
|
71
|
}
|
72
|
|
73
|
@Override
|
74
|
public void removeElement(IdentifiableSource element) {
|
75
|
getEntity().removeSource(element);
|
76
|
}
|
77
|
|
78
|
@Override
|
79
|
public IdentifiableSource addExisting() {
|
80
|
// TODO Auto-generated method stub
|
81
|
return null;
|
82
|
}
|
83
|
|
84
|
@Override
|
85
|
public boolean allowAddExisting() {
|
86
|
// TODO Auto-generated method stub
|
87
|
return false;
|
88
|
}
|
89
|
}
|