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
.ui
.section
.name
;
13 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
14 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
18 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
19 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
20 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationshipType
;
21 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
22 import eu
.etaxonomy
.taxeditor
.ui
.AbstractEntityCollectionElementWizardPage
;
23 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
28 * NameRelationshipWizardPage class.
32 * @created Jun 1, 2010
35 public class NameRelationshipWizardPage
extends AbstractEntityCollectionElementWizardPage
implements
36 IPropertyChangeListener
{
38 private EntitySelectionElement
<TaxonNameBase
> selection_relatedTo
;
40 private TermComboElement
<NameRelationshipType
> combo_relationshipType
;
42 private final TaxonNameBase entity
;
44 private NameRelationshipType type
;
46 private TaxonNameBase toName
;
50 * Constructor for NameRelationshipWizardPage.
53 * @param callingSection
55 * {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
58 protected NameRelationshipWizardPage(
59 NameRelationshipDetailSection callingSection
) {
60 super("NameRelationshipWizardPage");
61 setTitle("New Name Relationship");
62 setDescription(callingSection
.getEntity().getTitleCache());
63 this.entity
= callingSection
.getEntity();
64 this.formFactory
= callingSection
.getFormFactory();
66 formFactory
.addPropertyChangeListener(this);
73 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
78 public void createControl(Composite parent
) {
79 super.createControl(parent
);
81 combo_relationshipType
= formFactory
.createDefinedTermComboElement(TermType
.NameRelationshipType
,
82 rootElement
, "Name Relationship Type", null, SWT
.NULL
);
84 selection_relatedTo
= formFactory
85 .createSelectionElement(TaxonNameBase
.class,
86 ((NameRelationshipWizard
) getWizard())
87 .getConversationHolder(), rootElement
,
88 "Related to", null, EntitySelectionElement
.ALL
,
98 * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
100 public NameRelationship
getNameRelationship() {
101 return entity
.addRelationshipToName(toName
, type
, null, null, null);
106 public void propertyChange(PropertyChangeEvent event
) {
110 Object eventSource
= event
.getSource();
111 if (eventSource
== combo_relationshipType
) {
112 type
= combo_relationshipType
.getSelection();
113 } else if (eventSource
== selection_relatedTo
) {
114 toName
= selection_relatedTo
.getEntity();
117 boolean complete
= type
!= null && toName
!= null;
118 setPageComplete(complete
);