ref #8398 adapting taxeditor to changes in NameRelationship
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / name / NameDetailSection.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.name;
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.INonViralName;
17 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
18 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
21 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
22 import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
23
24 /**
25 * <p>NameDetailSection class.</p>
26 *
27 * @author n.hoffmann
28 * @created 05.06.2009
29 */
30 public class NameDetailSection extends AbstractCdmDetailSection<INonViralName> implements ITaxonBaseDetailSection{
31
32 private TaxonBase taxonBase;
33
34 /**
35 * <p>Constructor for NameDetailSection.</p>
36 *
37 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
38 * @param style a int.
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 selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
42 */
43 public NameDetailSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement,
44 ISelectionProvider selectionProvider, int style) {
45 super(cdmFormFactory, conversation, parentElement, selectionProvider, style);
46 }
47
48 /** {@inheritDoc} */
49 @Override
50 public void setTaxonBase(TaxonBase entity) {
51 this.taxonBase = entity;
52 INonViralName name = (INonViralName) HibernateProxyHelper.deproxy(entity.getName());
53 setEntity(name);
54 }
55
56 /** {@inheritDoc} */
57 @Override
58 public String getHeading() {
59 return "Scientific Name";
60 }
61
62 /** {@inheritDoc} */
63 @Override
64 protected void setSectionTitle() {
65 if(!isDisposed()){
66 String title = "";
67 if(getEntity() != null){
68 title = ": " + getEntity().getNameCache();
69 }
70 this.setText(getHeading() + title);
71 }
72 }
73
74 @Override
75 public TaxonBase getTaxonBase() {
76 return taxonBase;
77 }
78
79 @Override
80 protected AbstractCdmDetailElement<INonViralName> createCdmDetailElement(
81 AbstractCdmDetailSection<INonViralName> parentElement, int style) {
82 return formFactory.createNameDetailElement(parentElement, style);
83
84 }
85
86 public void updateContent(){
87 ((NameDetailElement)this.detailElement).updateContent();
88 }
89 }