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.section.name;
|
12
|
|
13
|
import java.util.Collection;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.eclipse.core.runtime.IStatus;
|
17
|
import org.eclipse.jface.wizard.WizardDialog;
|
18
|
|
19
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
20
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
21
|
import eu.etaxonomy.cdm.model.name.NameRelationship;
|
22
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
23
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
24
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
25
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
26
|
import eu.etaxonomy.taxeditor.forms.CdmFormFactory;
|
27
|
import eu.etaxonomy.taxeditor.forms.ICdmFormElement;
|
28
|
import eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection;
|
29
|
import eu.etaxonomy.taxeditor.section.ITaxonDetailSection;
|
30
|
|
31
|
/**
|
32
|
* <p>NameRelationshipDetailSection class.</p>
|
33
|
*
|
34
|
* @author n.hoffmann
|
35
|
* @created Mar 18, 2010
|
36
|
* @version 1.0
|
37
|
*/
|
38
|
public class NameRelationshipDetailSection extends AbstractEntityCollectionSection<TaxonNameBase, NameRelationship> implements ITaxonDetailSection{
|
39
|
|
40
|
private static final Logger logger = Logger
|
41
|
.getLogger(NameRelationshipDetailSection.class);
|
42
|
|
43
|
/**
|
44
|
* <p>Constructor for NameRelationshipDetailSection.</p>
|
45
|
*
|
46
|
* @param formFactory a {@link eu.etaxonomy.taxeditor.forms.CdmFormFactory} object.
|
47
|
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
48
|
* @param parentElement a {@link eu.etaxonomy.taxeditor.forms.ICdmFormElement} object.
|
49
|
* @param style a int.
|
50
|
*/
|
51
|
public NameRelationshipDetailSection(CdmFormFactory formFactory, ConversationHolder conversation,
|
52
|
ICdmFormElement parentElement, int style) {
|
53
|
super(formFactory, conversation, parentElement, "Name Relationship", style);
|
54
|
}
|
55
|
|
56
|
/** {@inheritDoc} */
|
57
|
@Override
|
58
|
public void addElement(NameRelationship element) {
|
59
|
//getEntity().addRelationship(element);
|
60
|
}
|
61
|
|
62
|
/** {@inheritDoc} */
|
63
|
@Override
|
64
|
public NameRelationship createNewElement() {
|
65
|
|
66
|
NameRelationshipWizard wizard = new NameRelationshipWizard(this);
|
67
|
WizardDialog dialog = new WizardDialog(EditorUtil.getShell(), wizard);
|
68
|
int status = dialog.open();
|
69
|
|
70
|
if(status == IStatus.OK)
|
71
|
return wizard.getNameRelationship();
|
72
|
|
73
|
return null;
|
74
|
}
|
75
|
|
76
|
/** {@inheritDoc} */
|
77
|
@Override
|
78
|
public Collection<NameRelationship> getCollection(TaxonNameBase entity) {
|
79
|
Collection<NameRelationship> allNameRelationships = entity.getRelationsFromThisName();
|
80
|
allNameRelationships.addAll(entity.getRelationsToThisName());
|
81
|
return allNameRelationships;
|
82
|
}
|
83
|
|
84
|
/** {@inheritDoc} */
|
85
|
@Override
|
86
|
public String getEmptyString() {
|
87
|
return "No name relationships yet.";
|
88
|
}
|
89
|
|
90
|
/** {@inheritDoc} */
|
91
|
@Override
|
92
|
protected String getTooltipString() {
|
93
|
return "Add a new name relationship from this name.";
|
94
|
}
|
95
|
|
96
|
/** {@inheritDoc} */
|
97
|
@Override
|
98
|
public void removeElement(NameRelationship element) {
|
99
|
getEntity().removeNameRelationship(element);
|
100
|
}
|
101
|
|
102
|
/*
|
103
|
* (non-Javadoc)
|
104
|
* @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#setTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
|
105
|
*/
|
106
|
/** {@inheritDoc} */
|
107
|
public void setTaxon(TaxonBase taxon) {
|
108
|
NonViralName name = (NonViralName) HibernateProxyHelper.deproxy(taxon.getName());
|
109
|
setEntity(name);
|
110
|
}
|
111
|
}
|