1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.ui.section.occurrence.dna;
|
12
|
|
13
|
import java.util.Collection;
|
14
|
import java.util.LinkedList;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
17
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
18
|
import eu.etaxonomy.cdm.model.common.Identifier;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
20
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
21
|
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
|
22
|
|
23
|
/**
|
24
|
* @author n.hoffmann
|
25
|
* @created May 11, 2011
|
26
|
* @version 1.0
|
27
|
*/
|
28
|
public class SampleDesignationHistoryDetailSection extends AbstractSampleDesignationDetailSection {
|
29
|
|
30
|
/**
|
31
|
* @param formFactory
|
32
|
* @param conversation
|
33
|
* @param parentElement
|
34
|
* @param style
|
35
|
*/
|
36
|
public SampleDesignationHistoryDetailSection(CdmFormFactory formFactory,
|
37
|
ConversationHolder conversation, ICdmFormElement parentElement,
|
38
|
int style) {
|
39
|
super(formFactory, conversation, parentElement, "Sample Designation History", style);
|
40
|
}
|
41
|
|
42
|
/* (non-Javadoc)
|
43
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
|
44
|
*/
|
45
|
@Override
|
46
|
public Collection<Identifier> getCollection(IdentifiableEntity<?> entity) {
|
47
|
LinkedList<Identifier> sampleDesignations = new LinkedList<Identifier>();
|
48
|
for (Identifier identifier : entity.getIdentifiers()) {
|
49
|
if(identifier.getType()!=null && identifier.getType().equals(DerivateLabelProvider.getSampleDesignationTerm())){
|
50
|
sampleDesignations.add(identifier);
|
51
|
}
|
52
|
}
|
53
|
if(sampleDesignations.size()>0){
|
54
|
sampleDesignations.removeFirst();//first is the current sample designation
|
55
|
}
|
56
|
return sampleDesignations;
|
57
|
}
|
58
|
|
59
|
@Override
|
60
|
public void refresh() {
|
61
|
internalUpdateSection(false);
|
62
|
}
|
63
|
|
64
|
|
65
|
/* (non-Javadoc)
|
66
|
* @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
|
67
|
*/
|
68
|
/** {@inheritDoc} */
|
69
|
@Override
|
70
|
protected String getTooltipString() {
|
71
|
return "Add a sample designation to the history";
|
72
|
}
|
73
|
|
74
|
/* (non-Javadoc)
|
75
|
* @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
|
76
|
*/
|
77
|
/** {@inheritDoc} */
|
78
|
@Override
|
79
|
public void addElement(Identifier sampleDesignation) {
|
80
|
//The current sample designation is always the first one found.
|
81
|
//The following are recent sample designations with the most recent being
|
82
|
//the second one found and so on
|
83
|
Identifier currentSampleDesignation = DerivateLabelProvider.getCurrentSampleDesignation(getEntity());
|
84
|
int indexOfCurrentSampleDesignation = getEntity().getIdentifiers().indexOf(currentSampleDesignation);
|
85
|
getEntity().addIdentifier(indexOfCurrentSampleDesignation+1, sampleDesignation);
|
86
|
}
|
87
|
|
88
|
}
|