merge from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / dna / CurrentSampleDesignationDetailSection.java
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.Collections;
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 *
25 * @author pplitzner
26 * @date Oct 16, 2014
27 *
28 */
29 public class CurrentSampleDesignationDetailSection extends AbstractSampleDesignationDetailSection {
30
31 public CurrentSampleDesignationDetailSection(CdmFormFactory formFactory,
32 ConversationHolder conversation, ICdmFormElement parentElement,
33 int style) {
34 super(formFactory, conversation, parentElement, "Current Sample Designation", style);
35 }
36
37 @Override
38 public void refresh() {
39 internalUpdateSection(false);
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 Identifier currentSampleDesignation = DerivateLabelProvider.getCurrentSampleDesignation(entity);
48 if(currentSampleDesignation!=null){
49 return Collections.singleton(currentSampleDesignation);
50 }
51 else{
52 return Collections.emptyList();
53 }
54 }
55
56 /* (non-Javadoc)
57 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
58 */
59 /** {@inheritDoc} */
60 @Override
61 protected String getTooltipString() {
62 return "Create new current sample designation";
63 }
64
65 /* (non-Javadoc)
66 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
67 */
68 /** {@inheritDoc} */
69 @Override
70 public void addElement(Identifier sampleDesignation) {
71 //The current sample designation is always the first one found.
72 //The following are recent sample designations with the most recent being
73 //the second one found and so on
74 getEntity().addIdentifier(0, sampleDesignation);
75 }
76
77 }