Merge branch 'release/5.18.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / reference / NomenclaturalReferenceDetailSection.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor.ui.section.reference;
11
12 import org.eclipse.jface.viewers.ISelectionProvider;
13
14 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
15 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
16 import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
17 import eu.etaxonomy.cdm.model.name.TaxonName;
18 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
19 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
22 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
23 import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
24
25 /**
26 * <p>NomenclaturalReferenceDetailSection class.</p>
27 *
28 * @author n.hoffmann
29 * @created Mar 12, 2010
30 */
31 public class NomenclaturalReferenceDetailSection extends
32 AbstractCdmDetailSection<TaxonName> implements ITaxonBaseDetailSection{
33
34 private TaxonBase<?> taxonBase;
35
36 /**
37 * <p>Constructor for NomenclaturalReferenceDetailSection.</p>
38 *
39 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
40 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
41 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
42 * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
43 * @param style a int.
44 */
45 public NomenclaturalReferenceDetailSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
46 ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
47 super(cdmFormFactory, conversation, parentElement, selectionProvider, style);
48 }
49
50 @Override
51 public String getHeading() {
52 return "Nomenclatural Source";
53 }
54
55 @Override
56 public void setTaxonBase(TaxonBase entity) {
57 this.taxonBase = entity;
58 TaxonName name = HibernateProxyHelper.deproxy(entity.getName());
59 setEntity(name);
60 }
61
62 @Override
63 protected void setSectionTitle() {
64 String title = "";
65 if(getEntity() != null && getEntity().getNomenclaturalSource() != null){
66 DescriptionElementSource reference = getEntity().getNomenclaturalSource();
67 if (reference != null && reference.getCitation() != null){
68 String nomenclaturalCitation = reference.getCitation().getNomenclaturalCitation(reference.getCitationMicroReference());
69 title = ": " + nomenclaturalCitation;
70 }
71
72 }
73 this.setText(getHeading() + title);
74 }
75
76 @Override
77 public TaxonBase getTaxonBase() {
78 return taxonBase;
79 }
80
81 @Override
82 protected AbstractCdmDetailElement<TaxonName> createCdmDetailElement(
83 AbstractCdmDetailSection<TaxonName> parentElement, int style) {
84 return formFactory.createNomenclaturalReferenceDetailElement(parentElement, style);
85 }
86 }