2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.name
;
12 import java
.util
.Collection
;
14 import org
.eclipse
.core
.runtime
.IStatus
;
15 import org
.eclipse
.jface
.wizard
.WizardDialog
;
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
;
29 * <p>NameRelationshipDetailSection class.</p>
32 * @created Mar 18, 2010
34 public class NameRelationshipDetailSection
extends AbstractEntityCollectionSection
<TaxonName
, NameRelationship
> implements ITaxonBaseDetailSection
{
36 private TaxonBase taxonBase
;
39 * <p>Constructor for NameRelationshipDetailSection.</p>
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.
46 public NameRelationshipDetailSection(CdmFormFactory formFactory
, ConversationHolder conversation
,
47 ICdmFormElement parentElement
, int style
) {
48 super(formFactory
, conversation
, parentElement
, "Name Relationships", style
);
53 public void addElement(NameRelationship element
) {
54 //getEntity().addRelationship(element);
59 public NameRelationship
createNewElement() {
61 NameRelationshipWizard wizard
= new NameRelationshipWizard(this);
62 WizardDialog dialog
= new WizardDialog(StoreUtil
.getShell(), wizard
);
63 int status
= dialog
.open();
65 if(status
== IStatus
.OK
) {
66 return wizard
.getNameRelationship();
74 public Collection
<NameRelationship
> getCollection(TaxonName entity
) {
75 Collection
<NameRelationship
> allNameRelationships
= entity
.getRelationsFromThisName();
76 allNameRelationships
.addAll(entity
.getRelationsToThisName());
77 return allNameRelationships
;
82 public String
getEmptyString() {
83 return "No name relationships yet.";
88 protected String
getTooltipString() {
89 return "Add a new name relationship from this name.";
94 public void removeElement(NameRelationship element
) {
95 getEntity().removeNameRelationship(element
);
100 public void setTaxonBase(TaxonBase entity
) {
101 this.taxonBase
= entity
;
102 TaxonName name
= HibernateProxyHelper
.deproxy(entity
.getName());
107 public TaxonBase
getTaxonBase() {
115 public NameRelationship
addExisting() {
123 public boolean allowAddExisting() {