44aa277454c44f4cf9c4a43b6ab2543971fa4ad6
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / name / AuthorshipDetailSection.java
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 org.eclipse.jface.viewers.ISelectionProvider;
14
15 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
17 import eu.etaxonomy.cdm.model.name.NonViralName;
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>AuthorshipDetailSection class.</p>
27 *
28 * @author n.hoffmann
29 * @created 05.06.2009
30 * @version 1.0
31 */
32 public class AuthorshipDetailSection extends AbstractCdmDetailSection<NonViralName> implements ITaxonBaseDetailSection {
33
34 private TaxonBase taxonBase;
35
36 /**
37 * <p>Constructor for AuthorshipDetailSection.</p>
38 *
39 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
40 * @param style a int.
41 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
42 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
43 * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
44 */
45 public AuthorshipDetailSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement,
46 ISelectionProvider selectionProvider, int style) {
47 super(cdmFormFactory, conversation, parentElement, selectionProvider, style);
48 }
49
50 /**
51 * {@inheritDoc}
52 *
53 * Author title is not in titleCache field
54 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#setSectionTitle()
55 */
56 @Override
57 protected void setSectionTitle() {
58 if(getEntity() != null){
59 String title = getHeading() + ": " + getEntity().getAuthorshipCache();
60 // we have to duplicate ampersands otherwise they are treated as
61 // mnenomic (see Label.setText() documentation)
62 // see also #4302
63 title = title.replace("&", "&&");
64 this.setText(title);
65 }
66 }
67
68 /** {@inheritDoc} */
69 @Override
70 public void setTaxonBase(TaxonBase entity) {
71 this.taxonBase = entity;
72 NonViralName name = (NonViralName) HibernateProxyHelper.deproxy(entity.getName());
73 setEntity(name);
74 }
75
76 /*
77 * (non-Javadoc)
78 * @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.AbstractCdmDetailSection#getHeading()
79 */
80 /** {@inheritDoc} */
81 @Override
82 public String getHeading() {
83 return "Authorship";
84 }
85
86 /* (non-Javadoc)
87 * @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#getTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
88 */
89 @Override
90 public TaxonBase getTaxonBase() {
91 return taxonBase;
92 }
93
94 /* (non-Javadoc)
95 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
96 */
97 @Override
98 protected AbstractCdmDetailElement<NonViralName> createCdmDetailElement(AbstractCdmDetailSection<NonViralName> parentElement, int style) {
99 return formFactory.createAuthorshipDetailElement(parentElement, style);
100 }
101
102 }