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.description.DescriptionElementBase;
|
18
|
import eu.etaxonomy.cdm.model.description.Feature;
|
19
|
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
|
20
|
import eu.etaxonomy.cdm.model.description.TextData;
|
21
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
22
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
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>ProtologueSection class.</p>
|
31
|
*
|
32
|
* @author n.hoffmann
|
33
|
* @created Nov 5, 2009
|
34
|
* @version 1.0
|
35
|
*/
|
36
|
public class ProtologueSection extends AbstractEntityCollectionSection<TaxonNameBase, DescriptionElementBase> implements ITaxonBaseDetailSection{
|
37
|
|
38
|
private TaxonBase taxonBase;
|
39
|
|
40
|
/**
|
41
|
* <p>Constructor for ProtologueSection.</p>
|
42
|
*
|
43
|
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.singlesource.ui.forms.CdmFormFactoryFacade} object.
|
44
|
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
|
45
|
* @param style a int.
|
46
|
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
47
|
*/
|
48
|
public ProtologueSection(CdmFormFactoryFacade cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
|
49
|
super(cdmFormFactory, conversation, parentElement, "Protologues", style);
|
50
|
}
|
51
|
|
52
|
/** {@inheritDoc} */
|
53
|
@Override
|
54
|
public DescriptionElementBase createNewElement() {
|
55
|
return TextData.NewInstance(Feature.PROTOLOGUE());
|
56
|
}
|
57
|
|
58
|
|
59
|
/** {@inheritDoc} */
|
60
|
@Override
|
61
|
public Collection<DescriptionElementBase> getCollection(
|
62
|
TaxonNameBase entity) {
|
63
|
return getTaxonNameDescription(entity).getElements();
|
64
|
}
|
65
|
|
66
|
|
67
|
/** {@inheritDoc} */
|
68
|
@Override
|
69
|
public String getEmptyString() {
|
70
|
return "No protologues yet.";
|
71
|
}
|
72
|
|
73
|
|
74
|
/** {@inheritDoc} */
|
75
|
@Override
|
76
|
protected String getTooltipString() {
|
77
|
return "Create a new protologue";
|
78
|
}
|
79
|
|
80
|
/** {@inheritDoc} */
|
81
|
@Override
|
82
|
public void addElement(DescriptionElementBase element) {
|
83
|
getTaxonNameDescription(getEntity()).addElement(element);
|
84
|
}
|
85
|
|
86
|
/** {@inheritDoc} */
|
87
|
@Override
|
88
|
public void removeElement(DescriptionElementBase element) {
|
89
|
getTaxonNameDescription(getEntity()).removeElement(element);
|
90
|
}
|
91
|
|
92
|
/** {@inheritDoc} */
|
93
|
public void setTaxonBase(TaxonBase entity) {
|
94
|
this.taxonBase = entity;
|
95
|
NonViralName name = (NonViralName) HibernateProxyHelper.deproxy(entity.getName());
|
96
|
setEntity(name);
|
97
|
}
|
98
|
|
99
|
private TaxonNameDescription getTaxonNameDescription(TaxonNameBase name){
|
100
|
// FIXME does not handle multiple name descriptions at the moment
|
101
|
if(name.getDescriptions().size() == 0){
|
102
|
name.addDescription(TaxonNameDescription.NewInstance(name));
|
103
|
}
|
104
|
return (TaxonNameDescription) name.getDescriptions().iterator().next();
|
105
|
}
|
106
|
|
107
|
/* (non-Javadoc)
|
108
|
* @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#getTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
|
109
|
*/
|
110
|
@Override
|
111
|
public TaxonBase getTaxonBase() {
|
112
|
return taxonBase;
|
113
|
}
|
114
|
}
|