Project

General

Profile

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

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

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

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

    
38
	private TaxonBase taxonBase;
39

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

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

    
59
	/** {@inheritDoc} */
60
	@Override
61
	public NameRelationship createNewElement() {
62

    
63
		NameRelationshipWizard wizard = new NameRelationshipWizard(this);
64
		WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), wizard);
65
		int status = dialog.open();
66

    
67
		if(status == IStatus.OK) {
68
            return wizard.getNameRelationship();
69
        }
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
	@Override
106
    public void setTaxonBase(TaxonBase entity) {
107
		this.taxonBase = entity;
108
		NonViralName name = (NonViralName) HibernateProxyHelper.deproxy(entity.getName());
109
		setEntity(name);
110
	}
111

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

    
120
    /**
121
     * {@inheritDoc}
122
     */
123
    @Override
124
    public NameRelationship addExisting() {
125
        return null;
126
    }
127

    
128
    /**
129
     * {@inheritDoc}
130
     */
131
    @Override
132
    public boolean allowAddExisting() {
133
        return false;
134
    }
135
}
(9-9/21)