Project

General

Profile

Download (3.58 KB) Statistics
| Branch: | Tag: | Revision:
1 729887cf n.hoffmann
// $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 f211dd28 n.hoffmann
package eu.etaxonomy.taxeditor.ui.section.name;
12 729887cf n.hoffmann
13
import java.util.Collection;
14
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.jface.wizard.WizardDialog;
17
18 2d9a13f7 n.hoffmann
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19 729887cf n.hoffmann
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 f211dd28 n.hoffmann
import eu.etaxonomy.taxeditor.store.StoreUtil;
25 78222507 n.hoffmann
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
26
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
27 f211dd28 n.hoffmann
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
28
import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
29 729887cf n.hoffmann
30
/**
31 3be6ef3e n.hoffmann
 * <p>NameRelationshipDetailSection class.</p>
32
 *
33 729887cf n.hoffmann
 * @author n.hoffmann
34
 * @created Mar 18, 2010
35
 * @version 1.0
36
 */
37 6747dad6 n.hoffmann
public class NameRelationshipDetailSection extends AbstractEntityCollectionSection<TaxonNameBase, NameRelationship> implements ITaxonBaseDetailSection{
38
39
	private TaxonBase taxonBase;
40 729887cf n.hoffmann
41 3be6ef3e n.hoffmann
	/**
42
	 * <p>Constructor for NameRelationshipDetailSection.</p>
43
	 *
44 78222507 n.hoffmann
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
45 3be6ef3e n.hoffmann
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
46 78222507 n.hoffmann
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
47 3be6ef3e n.hoffmann
	 * @param style a int.
48
	 */
49 2d9a13f7 n.hoffmann
	public NameRelationshipDetailSection(CdmFormFactory formFactory, ConversationHolder conversation,
50 729887cf n.hoffmann
			ICdmFormElement parentElement, int style) {
51 2d9a13f7 n.hoffmann
		super(formFactory, conversation, parentElement, "Name Relationship", style);
52 729887cf n.hoffmann
	}
53
54 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
55 729887cf n.hoffmann
	@Override
56
	public void addElement(NameRelationship element) {
57
		//getEntity().addRelationship(element);
58
	}
59
60 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
61 729887cf n.hoffmann
	@Override
62
	public NameRelationship createNewElement() {
63
		
64
		NameRelationshipWizard wizard = new NameRelationshipWizard(this);
65 f211dd28 n.hoffmann
		WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), wizard);
66 729887cf n.hoffmann
		int status = dialog.open();
67
		
68
		if(status == IStatus.OK)
69
			return wizard.getNameRelationship();
70
		
71
		return null;
72
	}
73
74 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
75 729887cf n.hoffmann
	@Override
76
	public Collection<NameRelationship> getCollection(TaxonNameBase entity) {
77 cfcb0ce6 n.hoffmann
		Collection<NameRelationship> allNameRelationships = entity.getRelationsFromThisName();
78
		allNameRelationships.addAll(entity.getRelationsToThisName());
79
		return allNameRelationships;
80 729887cf n.hoffmann
	}
81
82 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
83 729887cf n.hoffmann
	@Override
84
	public String getEmptyString() {
85
		return "No name relationships yet.";
86
	}
87
88 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
89 729887cf n.hoffmann
	@Override
90
	protected String getTooltipString() {
91
		return "Add a new name relationship from this name.";
92
	}
93
94 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
95 729887cf n.hoffmann
	@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 3be6ef3e n.hoffmann
	/** {@inheritDoc} */
105 6747dad6 n.hoffmann
	public void setTaxonBase(TaxonBase entity) {
106
		this.taxonBase = entity;
107
		NonViralName name = (NonViralName) HibernateProxyHelper.deproxy(entity.getName());
108 729887cf n.hoffmann
		setEntity(name);
109
	}
110 6747dad6 n.hoffmann
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 729887cf n.hoffmann
}