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 Relationships", 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
|
|
72
|
return null;
|
73
|
}
|
74
|
|
75
|
/** {@inheritDoc} */
|
76
|
@Override
|
77
|
public Collection<NameRelationship> getCollection(TaxonNameBase entity) {
|
78
|
Collection<NameRelationship> allNameRelationships = entity.getRelationsFromThisName();
|
79
|
allNameRelationships.addAll(entity.getRelationsToThisName());
|
80
|
return allNameRelationships;
|
81
|
}
|
82
|
|
83
|
/** {@inheritDoc} */
|
84
|
@Override
|
85
|
public String getEmptyString() {
|
86
|
return "No name relationships yet.";
|
87
|
}
|
88
|
|
89
|
/** {@inheritDoc} */
|
90
|
@Override
|
91
|
protected String getTooltipString() {
|
92
|
return "Add a new name relationship from this name.";
|
93
|
}
|
94
|
|
95
|
/** {@inheritDoc} */
|
96
|
@Override
|
97
|
public void removeElement(NameRelationship element) {
|
98
|
getEntity().removeNameRelationship(element);
|
99
|
}
|
100
|
|
101
|
/*
|
102
|
* (non-Javadoc)
|
103
|
* @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#setTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
|
104
|
*/
|
105
|
/** {@inheritDoc} */
|
106
|
@Override
|
107
|
public void setTaxonBase(TaxonBase entity) {
|
108
|
this.taxonBase = entity;
|
109
|
NonViralName name = (NonViralName) HibernateProxyHelper.deproxy(entity.getName());
|
110
|
setEntity(name);
|
111
|
}
|
112
|
|
113
|
/* (non-Javadoc)
|
114
|
* @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#getTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
|
115
|
*/
|
116
|
@Override
|
117
|
public TaxonBase getTaxonBase() {
|
118
|
return taxonBase;
|
119
|
}
|
120
|
}
|