Merge branch 'develop' into LibrAlign
[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.name.TaxonNameBase;
17 import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
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 * @version 1.0
31 */
32 public class NomenclaturalReferenceDetailSection extends
33 AbstractCdmDetailSection<TaxonNameBase> implements ITaxonBaseDetailSection{
34
35 private TaxonBase taxonBase;
36
37 /**
38 * <p>Constructor for NomenclaturalReferenceDetailSection.</p>
39 *
40 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
41 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
42 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
43 * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
44 * @param style a int.
45 */
46 public NomenclaturalReferenceDetailSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
47 ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
48 super(cdmFormFactory, conversation, parentElement, selectionProvider, style);
49 }
50
51 /** {@inheritDoc} */
52 @Override
53 public String getHeading() {
54 return "Nomenclatural Reference";
55 }
56
57 /** {@inheritDoc} */
58 @Override
59 public void setTaxonBase(TaxonBase entity) {
60 this.taxonBase = entity;
61 TaxonNameBase name = (TaxonNameBase) HibernateProxyHelper.deproxy(entity.getName());
62 setEntity(name);
63 }
64
65 /** {@inheritDoc} */
66 @Override
67 protected void setSectionTitle() {
68 String title = "";
69 if(getEntity() != null && getEntity().getNomenclaturalReference() != null){
70 INomenclaturalReference reference = getEntity().getNomenclaturalReference();
71 String nomenclaturalCitation = reference.getNomenclaturalCitation(getEntity().getNomenclaturalMicroReference());
72 title = ": " + nomenclaturalCitation;
73 }
74 this.setText(getHeading() + title);
75 }
76
77 /* (non-Javadoc)
78 * @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#getTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
79 */
80 @Override
81 public TaxonBase getTaxonBase() {
82 return taxonBase;
83 }
84
85 /* (non-Javadoc)
86 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
87 */
88 @Override
89 protected AbstractCdmDetailElement<TaxonNameBase> createCdmDetailElement(AbstractCdmDetailSection<TaxonNameBase> parentElement, int style) {
90 return formFactory.createNomenclaturalReferenceDetailElement(parentElement, style);
91 }
92 }