Project

General

Profile

Download (3.58 KB) Statistics
| Branch: | Tag: | Revision:
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 java.util.Collection;
14

    
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.jface.wizard.WizardDialog;
17

    
18
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
20
import eu.etaxonomy.cdm.model.name.NameRelationship;
21
import eu.etaxonomy.cdm.model.name.NonViralName;
22
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
23
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
24
import eu.etaxonomy.taxeditor.store.StoreUtil;
25
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
26
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
27
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
28
import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
29

    
30
/**
31
 * <p>NameRelationshipDetailSection class.</p>
32
 *
33
 * @author n.hoffmann
34
 * @created Mar 18, 2010
35
 * @version 1.0
36
 */
37
public class NameRelationshipDetailSection extends AbstractEntityCollectionSection<TaxonNameBase, NameRelationship> implements ITaxonBaseDetailSection{
38

    
39
	private TaxonBase taxonBase;
40

    
41
	/**
42
	 * <p>Constructor for NameRelationshipDetailSection.</p>
43
	 *
44
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
45
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
46
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
47
	 * @param style a int.
48
	 */
49
	public NameRelationshipDetailSection(CdmFormFactory formFactory, ConversationHolder conversation,
50
			ICdmFormElement parentElement, int style) {
51
		super(formFactory, conversation, parentElement, "Name Relationship", style);
52
	}
53

    
54
	/** {@inheritDoc} */
55
	@Override
56
	public void addElement(NameRelationship element) {
57
		//getEntity().addRelationship(element);
58
	}
59

    
60
	/** {@inheritDoc} */
61
	@Override
62
	public NameRelationship createNewElement() {
63
		
64
		NameRelationshipWizard wizard = new NameRelationshipWizard(this);
65
		WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), wizard);
66
		int status = dialog.open();
67
		
68
		if(status == IStatus.OK)
69
			return wizard.getNameRelationship();
70
		
71
		return null;
72
	}
73

    
74
	/** {@inheritDoc} */
75
	@Override
76
	public Collection<NameRelationship> getCollection(TaxonNameBase entity) {
77
		Collection<NameRelationship> allNameRelationships = entity.getRelationsFromThisName();
78
		allNameRelationships.addAll(entity.getRelationsToThisName());
79
		return allNameRelationships;
80
	}
81

    
82
	/** {@inheritDoc} */
83
	@Override
84
	public String getEmptyString() {
85
		return "No name relationships yet.";
86
	}
87

    
88
	/** {@inheritDoc} */
89
	@Override
90
	protected String getTooltipString() {
91
		return "Add a new name relationship from this name.";
92
	}
93

    
94
	/** {@inheritDoc} */
95
	@Override
96
	public void removeElement(NameRelationship element) {
97
		getEntity().removeNameRelationship(element);
98
	}	
99
	
100
	/*
101
	 * (non-Javadoc)
102
	 * @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#setTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
103
	 */
104
	/** {@inheritDoc} */
105
	public void setTaxonBase(TaxonBase entity) {
106
		this.taxonBase = entity;
107
		NonViralName name = (NonViralName) HibernateProxyHelper.deproxy(entity.getName());
108
		setEntity(name);
109
	}
110

    
111
	/* (non-Javadoc)
112
	 * @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#getTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
113
	 */
114
	@Override
115
	public TaxonBase getTaxonBase() {
116
		return taxonBase;
117
	}
118
}
(9-9/25)