3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.section
.name
;
13 import java
.util
.Collection
;
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
.forms
.CdmFormFactory
;
25 import eu
.etaxonomy
.taxeditor
.forms
.ICdmFormElement
;
26 import eu
.etaxonomy
.taxeditor
.section
.AbstractEntityCollectionSection
;
27 import eu
.etaxonomy
.taxeditor
.section
.ITaxonDetailSection
;
30 * <p>ProtologueSection class.</p>
33 * @created Nov 5, 2009
36 public class ProtologueSection
extends AbstractEntityCollectionSection
<TaxonNameBase
, DescriptionElementBase
> implements ITaxonDetailSection
{
39 * <p>Constructor for ProtologueSection.</p>
41 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.forms.CdmFormFactory} object.
42 * @param parentElement a {@link eu.etaxonomy.taxeditor.forms.ICdmFormElement} object.
44 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
46 public ProtologueSection(CdmFormFactory cdmFormFactory
, ConversationHolder conversation
, ICdmFormElement parentElement
, int style
) {
47 super(cdmFormFactory
, conversation
, parentElement
, "Protologues", style
);
52 public DescriptionElementBase
createNewElement() {
53 return TextData
.NewInstance(Feature
.PROTOLOGUE());
59 public Collection
<DescriptionElementBase
> getCollection(
60 TaxonNameBase entity
) {
61 return getTaxonNameDescription(entity
).getElements();
67 public String
getEmptyString() {
68 return "No protologues yet.";
74 protected String
getTooltipString() {
75 return "Create a new protologue";
80 public void addElement(DescriptionElementBase element
) {
81 getTaxonNameDescription(getEntity()).addElement(element
);
86 public void removeElement(DescriptionElementBase element
) {
87 getTaxonNameDescription(getEntity()).removeElement(element
);
91 public void setTaxon(TaxonBase taxon
) {
93 NonViralName name
= (NonViralName
) HibernateProxyHelper
.deproxy(taxon
.getName());
98 private TaxonNameDescription
getTaxonNameDescription(TaxonNameBase name
){
99 // FIXME does not handle multiple name descriptions at the moment
100 if(name
.getDescriptions().size() == 0){
101 name
.addDescription(TaxonNameDescription
.NewInstance(name
));
103 return (TaxonNameDescription
) name
.getDescriptions().iterator().next();