1 |
e4428955
|
Patric Plitzner
|
/**
|
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 |
1c3cb06b
|
Patrick Plitzner
|
import java.util.Comparator;
|
14 |
e4428955
|
Patric Plitzner
|
|
15 |
fe371b32
|
Patric Plitzner
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
16 |
e4428955
|
Patric Plitzner
|
import eu.etaxonomy.cdm.model.common.Identifier;
|
17 |
|
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
18 |
|
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
19 |
1c3cb06b
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
|
20 |
f8cdd23e
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.view.search.derivative.DerivateLabelProvider;
|
21 |
e4428955
|
Patric Plitzner
|
|
22 |
|
|
/**
|
23 |
|
|
* @author pplitzner
|
24 |
|
|
* @date Oct 16, 2014
|
25 |
|
|
*/
|
26 |
|
|
public class CurrentSampleDesignationDetailSection extends AbstractSampleDesignationDetailSection {
|
27 |
|
|
|
28 |
|
|
public CurrentSampleDesignationDetailSection(CdmFormFactory formFactory,
|
29 |
8180822f
|
Andreas Müller
|
ICdmFormElement parentElement,
|
30 |
e4428955
|
Patric Plitzner
|
int style) {
|
31 |
8180822f
|
Andreas Müller
|
super(formFactory, parentElement, "Current Sample Designation", style);
|
32 |
e4428955
|
Patric Plitzner
|
}
|
33 |
|
|
|
34 |
|
|
@Override
|
35 |
|
|
public void refresh() {
|
36 |
|
|
internalUpdateSection(false);
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
@Override
|
40 |
fe371b32
|
Patric Plitzner
|
public Collection<Identifier> getCollection(IdentifiableEntity<?> entity) {
|
41 |
|
|
Identifier currentSampleDesignation = DerivateLabelProvider.getCurrentSampleDesignation(entity);
|
42 |
e577390b
|
Patric Plitzner
|
if(currentSampleDesignation!=null){
|
43 |
|
|
return Collections.singleton(currentSampleDesignation);
|
44 |
|
|
}
|
45 |
|
|
else{
|
46 |
|
|
return Collections.emptyList();
|
47 |
|
|
}
|
48 |
e4428955
|
Patric Plitzner
|
}
|
49 |
|
|
|
50 |
1c3cb06b
|
Patrick Plitzner
|
@Override
|
51 |
|
|
public Comparator<Identifier> getComparator() {
|
52 |
|
|
return new DefaultCdmBaseComparator<>();
|
53 |
|
|
}
|
54 |
|
|
|
55 |
e4428955
|
Patric Plitzner
|
@Override
|
56 |
|
|
protected String getTooltipString() {
|
57 |
|
|
return "Create new current sample designation";
|
58 |
|
|
}
|
59 |
|
|
|
60 |
e577390b
|
Patric Plitzner
|
@Override
|
61 |
fe371b32
|
Patric Plitzner
|
public void addElement(Identifier sampleDesignation) {
|
62 |
e577390b
|
Patric Plitzner
|
//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 |
f5b66699
|
Patrick Plitzner
|
@Override
|
69 |
|
|
public Identifier addExisting() {
|
70 |
|
|
return null;
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
@Override
|
74 |
|
|
public boolean allowAddExisting() {
|
75 |
|
|
return false;
|
76 |
|
|
}
|
77 |
97e308a9
|
Andreas Müller
|
}
|