3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.section
.name
;
13 import java
.util
.Collection
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
17 import org
.eclipse
.jface
.wizard
.WizardDialog
;
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
;
32 * <p>NameRelationshipDetailSection class.</p>
35 * @created Mar 18, 2010
38 public class NameRelationshipDetailSection
extends AbstractEntityCollectionSection
<TaxonNameBase
, NameRelationship
> implements ITaxonDetailSection
{
40 private static final Logger logger
= Logger
41 .getLogger(NameRelationshipDetailSection
.class);
44 * <p>Constructor for NameRelationshipDetailSection.</p>
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.
51 public NameRelationshipDetailSection(CdmFormFactory formFactory
, ConversationHolder conversation
,
52 ICdmFormElement parentElement
, int style
) {
53 super(formFactory
, conversation
, parentElement
, "Name Relationship", style
);
58 public void addElement(NameRelationship element
) {
59 //getEntity().addRelationship(element);
64 public NameRelationship
createNewElement() {
66 NameRelationshipWizard wizard
= new NameRelationshipWizard(this);
67 WizardDialog dialog
= new WizardDialog(EditorUtil
.getShell(), wizard
);
68 int status
= dialog
.open();
70 if(status
== IStatus
.OK
)
71 return wizard
.getNameRelationship();
78 public Collection
<NameRelationship
> getCollection(TaxonNameBase entity
) {
79 Collection
<NameRelationship
> allNameRelationships
= entity
.getRelationsFromThisName();
80 allNameRelationships
.addAll(entity
.getRelationsToThisName());
81 return allNameRelationships
;
86 public String
getEmptyString() {
87 return "No name relationships yet.";
92 protected String
getTooltipString() {
93 return "Add a new name relationship from this name.";
98 public void removeElement(NameRelationship element
) {
99 getEntity().removeNameRelationship(element
);
104 * @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#setTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
107 public void setTaxon(TaxonBase taxon
) {
108 NonViralName name
= (NonViralName
) HibernateProxyHelper
.deproxy(taxon
.getName());