2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.dna
;
12 import java
.util
.Collection
;
13 import java
.util
.Comparator
;
14 import java
.util
.LinkedList
;
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
.ui
.section
.DefaultCdmBaseComparator
;
22 import eu
.etaxonomy
.taxeditor
.view
.search
.derivative
.DerivateLabelProvider
;
26 * @created May 11, 2011
29 public class SampleDesignationHistoryDetailSection
extends AbstractSampleDesignationDetailSection
{
34 * @param parentElement
37 public SampleDesignationHistoryDetailSection(CdmFormFactory formFactory
,
38 ConversationHolder conversation
, ICdmFormElement parentElement
,
40 super(formFactory
, conversation
, parentElement
, "Sample Designation History", style
);
44 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
47 public Collection
<Identifier
> getCollection(IdentifiableEntity
<?
> entity
) {
48 LinkedList
<Identifier
> sampleDesignations
= new LinkedList
<>();
49 for (Identifier identifier
: entity
.getIdentifiers()) {
50 if(identifier
.getType()!=null && identifier
.getType().equals(DerivateLabelProvider
.getSampleDesignationTerm())){
51 sampleDesignations
.add(identifier
);
54 if(sampleDesignations
.size()>0){
55 sampleDesignations
.removeFirst();//first is the current sample designation
57 return sampleDesignations
;
61 public Comparator
<Identifier
> getComparator() {
62 return new DefaultCdmBaseComparator
<>();
66 public void refresh() {
67 internalUpdateSection(false);
72 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
76 protected String
getTooltipString() {
77 return "Add a sample designation to the history";
81 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
85 public void addElement(Identifier sampleDesignation
) {
86 //The current sample designation is always the first one found.
87 //The following are recent sample designations with the most recent being
88 //the second one found and so on
89 Identifier currentSampleDesignation
= DerivateLabelProvider
.getCurrentSampleDesignation(getEntity());
90 int indexOfCurrentSampleDesignation
= getEntity().getIdentifiers().indexOf(currentSampleDesignation
);
91 getEntity().addIdentifier(indexOfCurrentSampleDesignation
+1, sampleDesignation
);
98 public Identifier
addExisting() {
106 public boolean allowAddExisting() {