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.section.name;
|
12
|
|
13
|
import java.util.Collection;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
18
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
19
|
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
|
20
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
21
|
import eu.etaxonomy.cdm.model.name.Rank;
|
22
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
|
23
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
24
|
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
|
25
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
26
|
import eu.etaxonomy.taxeditor.forms.CdmFormFactory;
|
27
|
import eu.etaxonomy.taxeditor.forms.ICdmFormElement;
|
28
|
import eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection;
|
29
|
import eu.etaxonomy.taxeditor.section.ITaxonDetailSection;
|
30
|
|
31
|
/**
|
32
|
* <p>TypeDesignationSection class.</p>
|
33
|
*
|
34
|
* @author n.hoffmann
|
35
|
* @created May 17, 2010
|
36
|
* @version 1.0
|
37
|
*/
|
38
|
public class TypeDesignationSection extends AbstractEntityCollectionSection<TaxonNameBase, TypeDesignationBase> implements ITaxonDetailSection {
|
39
|
|
40
|
private static final Logger logger = Logger
|
41
|
.getLogger(TypeDesignationSection.class);
|
42
|
|
43
|
/**
|
44
|
* <p>Constructor for TypeDesignationSection.</p>
|
45
|
*
|
46
|
* @param formFactory a {@link eu.etaxonomy.taxeditor.forms.CdmFormFactory} object.
|
47
|
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
48
|
* @param parentElement a {@link eu.etaxonomy.taxeditor.forms.ICdmFormElement} object.
|
49
|
* @param style a int.
|
50
|
*/
|
51
|
public TypeDesignationSection(CdmFormFactory formFactory, ConversationHolder conversation,
|
52
|
ICdmFormElement parentElement, int style) {
|
53
|
super(formFactory, conversation, parentElement, "Type Designations", style);
|
54
|
}
|
55
|
|
56
|
|
57
|
|
58
|
/** {@inheritDoc} */
|
59
|
@Override
|
60
|
public void addElement(TypeDesignationBase element) {
|
61
|
getEntity().addTypeDesignation(element, false);
|
62
|
}
|
63
|
|
64
|
/** {@inheritDoc} */
|
65
|
@Override
|
66
|
public TypeDesignationBase createNewElement() {
|
67
|
if(isSpecimenType()){
|
68
|
return SpecimenTypeDesignation.NewInstance();
|
69
|
}else{
|
70
|
return NameTypeDesignation.NewInstance();
|
71
|
}
|
72
|
}
|
73
|
|
74
|
/** {@inheritDoc} */
|
75
|
@Override
|
76
|
public Collection<TypeDesignationBase> getCollection(TaxonNameBase entity) {
|
77
|
return entity.getTypeDesignations();
|
78
|
}
|
79
|
|
80
|
/** {@inheritDoc} */
|
81
|
@Override
|
82
|
public String getEmptyString() {
|
83
|
return "No type designations yet.";
|
84
|
}
|
85
|
|
86
|
/** {@inheritDoc} */
|
87
|
@Override
|
88
|
protected String getTooltipString() {
|
89
|
return "Add a type designation";
|
90
|
}
|
91
|
|
92
|
/** {@inheritDoc} */
|
93
|
@Override
|
94
|
public void removeElement(TypeDesignationBase element) {
|
95
|
getEntity().removeTypeDesignation(element);
|
96
|
}
|
97
|
|
98
|
/*
|
99
|
* (non-Javadoc)
|
100
|
* @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#setTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
|
101
|
*/
|
102
|
/** {@inheritDoc} */
|
103
|
public void setTaxon(TaxonBase taxon) {
|
104
|
NonViralName name = (NonViralName) HibernateProxyHelper.deproxy(taxon.getName());
|
105
|
setEntity(name);
|
106
|
}
|
107
|
|
108
|
private boolean isSpecimenType(){
|
109
|
Rank rank = getEntity().getRank();
|
110
|
return rank.isSpecies() || rank.isInfraSpecific();
|
111
|
}
|
112
|
}
|