Project

General

Profile

Download (2.38 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 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
package eu.etaxonomy.taxeditor.ui.section.taxon;
10

    
11
import org.apache.commons.lang.StringUtils;
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.TaxonName;
17
import eu.etaxonomy.cdm.model.taxon.Taxon;
18
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
19
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
23
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
24
import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
25

    
26
/**
27
 * @author n.hoffmann
28
 * @date Dec 1, 2011
29
 *
30
 */
31
public class TaxonRelationshipDetailSection extends AbstractCdmDetailSection<TaxonRelationship> implements ITaxonBaseDetailSection {
32
	Taxon taxon;
33
	TaxonName name;
34

    
35
	public TaxonRelationshipDetailSection(CdmFormFactory formFactory,
36
			ConversationHolder conversation, ICdmFormElement parentElement,
37
			ISelectionProvider selectionProvider, int style) {
38
		super(formFactory, conversation, parentElement,  selectionProvider, style);
39
	}
40

    
41
	@Override
42
	public String getHeading() {
43
		
44
		return getEntity() != null ? StringUtils.replace( getEntity().getType().getLabel(), "for", ""): "Taxon Relation";
45
	}
46

    
47
	/* (non-Javadoc)
48
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
49
	 */
50
	@Override
51
	protected AbstractCdmDetailElement<TaxonRelationship> createCdmDetailElement(AbstractCdmDetailSection<TaxonRelationship> parentElement, int style) {
52
	    return formFactory.createTaxonRelationshipDetailElement(parentElement);
53
	}
54

    
55
	/** {@inheritDoc} */
56
	@Override
57
    public void setTaxonBase(TaxonBase taxon) {
58
		this.taxon = (Taxon)taxon;
59
		TaxonName name = HibernateProxyHelper.deproxy(taxon.getName());
60
		setName(name);
61
	}
62

    
63
	@Override
64
	public TaxonBase getTaxonBase() {
65
		return taxon;
66
	}
67
	
68
	private void setName(TaxonName name){
69
		this.name = name;
70
	}
71

    
72
}
(7-7/8)