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
.LayoutConstants
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.RootElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
30 * NameRelationshipWizardPage class.
34 * @created Jun 1, 2010
37 public class NameRelationshipWizardPage
extends WizardPage
implements
38 IPropertyChangeListener
{
40 private final CdmFormFactory formFactory
;
42 private EntitySelectionElement
<TaxonNameBase
> selection_relatedTo
;
44 private TermComboElement
<NameRelationshipType
> combo_relationshipType
;
46 private final TaxonNameBase entity
;
48 private NameRelationshipType type
;
50 private TaxonNameBase toName
;
52 private RootElement rootElement
;
56 * Constructor for NameRelationshipWizardPage.
59 * @param callingSection
61 * {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
64 protected NameRelationshipWizardPage(
65 NameRelationshipDetailSection callingSection
) {
66 super("NameRelationshipWizardPage");
67 setTitle("New Name Relationship");
68 setDescription(callingSection
.getEntity().getTitleCache());
69 this.entity
= callingSection
.getEntity();
70 this.formFactory
= callingSection
.getFormFactory();
72 formFactory
.addPropertyChangeListener(this);
79 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
84 public void createControl(Composite parent
) {
85 this.setPageComplete(false);
87 Composite control
= formFactory
.createComposite(parent
);
89 control
.setLayout(LayoutConstants
.LAYOUT(2, false));
91 rootElement
= new RootElement(formFactory
, control
);
93 combo_relationshipType
= formFactory
.createTermComboElement(NameRelationshipType
.class,
94 rootElement
, "Name Relationship Type", null, SWT
.NULL
);
96 selection_relatedTo
= formFactory
97 .createSelectionElement(TaxonNameBase
.class,
98 ((NameRelationshipWizard
) getWizard())
99 .getConversationHolder(), rootElement
,
100 "Related to", null, EntitySelectionElement
.ALL
,
108 * getNameRelationship
111 * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
113 public NameRelationship
getNameRelationship() {
114 return entity
.addRelationshipToName(toName
, type
, null, null, null);
119 public void propertyChange(PropertyChangeEvent event
) {
123 Object eventSource
= event
.getSource();
124 if (eventSource
== combo_relationshipType
) {
125 type
= combo_relationshipType
.getSelection();
126 } else if (eventSource
== selection_relatedTo
) {
127 toName
= selection_relatedTo
.getEntity();
130 boolean complete
= type
!= null && toName
!= null;
131 setPageComplete(complete
);
136 public void dispose() {
137 rootElement
.removeElements();
138 formFactory
.removePropertyChangeListener(this);