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