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 org
.eclipse
.jface
.util
.IPropertyChangeListener
;
13 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.widgets
.Composite
;
17 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
18 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
19 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationshipType
;
20 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
21 import eu
.etaxonomy
.taxeditor
.ui
.AbstractEntityCollectionElementWizardPage
;
22 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
27 * NameRelationshipWizardPage class.
31 * @created Jun 1, 2010
34 public class NameRelationshipWizardPage
extends AbstractEntityCollectionElementWizardPage
implements
35 IPropertyChangeListener
{
37 private EntitySelectionElement
<TaxonNameBase
> selection_relatedTo
;
39 private TermComboElement
<NameRelationshipType
> combo_relationshipType
;
41 private final TaxonNameBase entity
;
43 private NameRelationshipType type
;
45 private TaxonNameBase toName
;
49 * Constructor for NameRelationshipWizardPage.
52 * @param callingSection
54 * {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
57 protected NameRelationshipWizardPage(
58 NameRelationshipDetailSection callingSection
) {
59 super("NameRelationshipWizardPage");
60 setTitle("New Name Relationship");
61 setDescription(callingSection
.getEntity().getTitleCache());
62 this.entity
= callingSection
.getEntity();
63 this.formFactory
= callingSection
.getFormFactory();
65 formFactory
.addPropertyChangeListener(this);
72 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
77 public void createControl(Composite parent
) {
78 super.createControl(parent
);
80 combo_relationshipType
= formFactory
.createDefinedTermComboElement(TermType
.NameRelationshipType
,
81 rootElement
, "Name Relationship Type", null, SWT
.NULL
);
83 selection_relatedTo
= formFactory
84 .createSelectionElement(TaxonNameBase
.class,
85 ((NameRelationshipWizard
) getWizard())
86 .getConversationHolder(), rootElement
,
87 "Related to", null, EntitySelectionElement
.ALL
,
97 * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
99 public NameRelationship
getNameRelationship() {
100 return entity
.addRelationshipToName(toName
, type
, null, null, null);
105 public void propertyChange(PropertyChangeEvent event
) {
109 Object eventSource
= event
.getSource();
110 if (eventSource
== combo_relationshipType
) {
111 type
= combo_relationshipType
.getSelection();
112 } else if (eventSource
== selection_relatedTo
) {
113 toName
= selection_relatedTo
.getEntity();
116 boolean complete
= type
!= null && toName
!= null;
117 setPageComplete(complete
);