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.occurrence.dna;
|
10
|
|
11
|
import java.util.Collection;
|
12
|
import java.util.Collections;
|
13
|
import java.util.Comparator;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
16
|
import eu.etaxonomy.cdm.model.common.Identifier;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
|
20
|
import eu.etaxonomy.taxeditor.view.search.derivative.DerivateLabelProvider;
|
21
|
|
22
|
/**
|
23
|
* @author pplitzner
|
24
|
* @date Oct 16, 2014
|
25
|
*/
|
26
|
public class CurrentSampleDesignationDetailSection extends AbstractSampleDesignationDetailSection {
|
27
|
|
28
|
public CurrentSampleDesignationDetailSection(CdmFormFactory formFactory,
|
29
|
ICdmFormElement parentElement,
|
30
|
int style) {
|
31
|
super(formFactory, parentElement, "Current Sample Designation", style);
|
32
|
}
|
33
|
|
34
|
@Override
|
35
|
public void refresh() {
|
36
|
internalUpdateSection(false);
|
37
|
}
|
38
|
|
39
|
@Override
|
40
|
public Collection<Identifier> getCollection(IdentifiableEntity<?> entity) {
|
41
|
Identifier currentSampleDesignation = DerivateLabelProvider.getCurrentSampleDesignation(entity);
|
42
|
if(currentSampleDesignation!=null){
|
43
|
return Collections.singleton(currentSampleDesignation);
|
44
|
}
|
45
|
else{
|
46
|
return Collections.emptyList();
|
47
|
}
|
48
|
}
|
49
|
|
50
|
@Override
|
51
|
public Comparator<Identifier> getComparator() {
|
52
|
return new DefaultCdmBaseComparator<>();
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
protected String getTooltipString() {
|
57
|
return "Create new current sample designation";
|
58
|
}
|
59
|
|
60
|
@Override
|
61
|
public void addElement(Identifier sampleDesignation) {
|
62
|
//The current sample designation is always the first one found.
|
63
|
//The following are recent sample designations with the most recent being
|
64
|
//the second one found and so on
|
65
|
getEntity().addIdentifier(0, sampleDesignation);
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
public Identifier addExisting() {
|
70
|
return null;
|
71
|
}
|
72
|
|
73
|
@Override
|
74
|
public boolean allowAddExisting() {
|
75
|
return false;
|
76
|
}
|
77
|
}
|