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