Project

General

Profile

Download (3.48 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.TaxonName;
21
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
22
import eu.etaxonomy.taxeditor.store.StoreUtil;
23
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
24
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
25
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
26
import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
27

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

    
36
	private TaxonBase taxonBase;
37

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

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

    
57
	/** {@inheritDoc} */
58
	@Override
59
	public NameRelationship createNewElement() {
60

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

    
65
		if(status == IStatus.OK) {
66
            return wizard.getNameRelationship();
67
        }
68

    
69
		return null;
70
	}
71

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

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

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

    
92
	/** {@inheritDoc} */
93
	@Override
94
	public void removeElement(NameRelationship element) {
95
		getEntity().removeNameRelationship(element);
96
	}
97

    
98
	/** {@inheritDoc} */
99
	@Override
100
    public void setTaxonBase(TaxonBase entity) {
101
		this.taxonBase = entity;
102
		TaxonName name = HibernateProxyHelper.deproxy(entity.getName());
103
		setEntity(name);
104
	}
105

    
106
	@Override
107
	public TaxonBase getTaxonBase() {
108
		return taxonBase;
109
	}
110

    
111
    /**
112
     * {@inheritDoc}
113
     */
114
    @Override
115
    public NameRelationship addExisting() {
116
        return null;
117
    }
118

    
119
    /**
120
     * {@inheritDoc}
121
     */
122
    @Override
123
    public boolean allowAddExisting() {
124
        return false;
125
    }
126
}
(9-9/21)