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
.jface
.wizard
.WizardPage
;
16 import org
.eclipse
.swt
.SWT
;
17 import org
.eclipse
.swt
.widgets
.Composite
;
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
.combo
.TermComboElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.RootElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
.SelectionType
;
26 import eu
.etaxonomy
.taxeditor
.ui
.selection
.NameSelectionElement
;
30 * NameRelationshipWizardPage class.
34 * @created Jun 1, 2010
37 public class NameRelationshipWizardPage
extends WizardPage
implements
38 IPropertyChangeListener
{
40 private final CdmFormFactory formFactory
;
42 private NameSelectionElement selection_relatedTo
;
44 private TermComboElement
<NameRelationshipType
> combo_relationshipType
;
46 private final NameRelationshipDetailSection callingSection
;
48 private final TaxonNameBase entity
;
50 private NameRelationshipType type
;
52 private TaxonNameBase toName
;
54 private RootElement rootElement
;
58 * Constructor for NameRelationshipWizardPage.
61 * @param callingSection
63 * {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
66 protected NameRelationshipWizardPage(
67 NameRelationshipDetailSection callingSection
) {
68 super("NameRelationshipWizardPage");
69 setTitle("New Name Relationship");
70 setDescription(callingSection
.getEntity().getTitleCache());
71 this.callingSection
= callingSection
;
72 this.entity
= callingSection
.getEntity();
73 this.formFactory
= callingSection
.getFormFactory();
75 formFactory
.addPropertyChangeListener(this);
82 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
87 public void createControl(Composite parent
) {
88 this.setPageComplete(false);
90 Composite control
= formFactory
.createComposite(parent
);
92 control
.setLayout(CdmFormFactory
.LAYOUT(2, false));
94 rootElement
= new RootElement(formFactory
, control
);
96 combo_relationshipType
= formFactory
.createTermComboElement(NameRelationshipType
.class,
97 rootElement
, "Name Relationship Type", null, SWT
.NULL
);
99 selection_relatedTo
= (NameSelectionElement
) formFactory
100 .createSelectionElement(SelectionType
.NAME
,
101 ((NameRelationshipWizard
) getWizard())
102 .getConversationHolder(), rootElement
,
103 "Related to", null, NameSelectionElement
.DEFAULT
,
111 * getNameRelationship
114 * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
116 public NameRelationship
getNameRelationship() {
117 return entity
.addRelationshipToName(toName
, type
, null, null, null);
122 public void propertyChange(PropertyChangeEvent event
) {
126 Object eventSource
= event
.getSource();
127 if (eventSource
== combo_relationshipType
) {
128 type
= combo_relationshipType
.getSelection();
129 } else if (eventSource
== selection_relatedTo
) {
130 toName
= selection_relatedTo
.getEntity();
133 boolean complete
= type
!= null && toName
!= null;
134 setPageComplete(complete
);
139 public void dispose() {
140 rootElement
.removeElements();
141 formFactory
.removePropertyChangeListener(this);