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
.PropertyChangeEvent
;
13 import org
.eclipse
.swt
.SWT
;
14 import org
.eclipse
.swt
.widgets
.Composite
;
16 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
17 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationshipType
;
18 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
19 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
20 import eu
.etaxonomy
.taxeditor
.ui
.AbstractEntityCollectionElementWizardPage
;
21 import eu
.etaxonomy
.taxeditor
.ui
.combo
.NameRelationshipTypeCombo
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
23 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
27 * NameRelationshipWizardPage class.
31 * @created Jun 1, 2010
34 public class NameRelationshipWizardPage
extends AbstractEntityCollectionElementWizardPage
{
36 private EntitySelectionElement
<TaxonName
> selection_relatedTo
;
38 private NameRelationshipTypeCombo combo_relationshipType
;
40 private final TaxonName entity
;
42 private NameRelationshipType type
;
44 private TaxonName relatedName
;
49 * Constructor for NameRelationshipWizardPage.
52 * @param callingSection
54 * {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
57 protected NameRelationshipWizardPage(
58 NameRelationshipDetailSection callingSection
, CdmFormFactory formFactory
) {
59 super("NameRelationshipWizardPage", formFactory
); //$NON-NLS-1$
60 setTitle("New Name Relationship"); //$NON-NLS-1$
61 //setDescription(callingSection.getEntity().getTitleCache());
62 setDescription(Messages
.NameRelationshipWizardPage_description
);
63 this.entity
= callingSection
.getEntity();
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
.createNameRelationshipTypeCombo(rootElement
,
81 entity
.getNameCache(), SWT
.NULL
, false,null);
84 selection_relatedTo
= formFactory
85 .createSelectionElement(TaxonName
.class, rootElement
,
86 "",this.entity
, EntitySelectionElement
.ALL
,
96 * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
98 public NameRelationship
getNameRelationship() {
101 rel
= entity
.addRelationshipFromName(relatedName
, type
, null, null, null, null);
103 rel
= entity
.addRelationshipToName(relatedName
, type
, null, null, null, null);
110 public void propertyChange(PropertyChangeEvent event
) {
114 Object eventSource
= event
.getSource();
115 if (eventSource
== combo_relationshipType
&& combo_relationshipType
.getSelection() != null) {
116 type
= combo_relationshipType
.getSelection().getTerm();
117 this.inverse
= combo_relationshipType
.getSelection().isInverse();
118 } else if (eventSource
== selection_relatedTo
) {
119 relatedName
= selection_relatedTo
.getEntity();
123 boolean complete
= type
!= null && relatedName
!= null;
124 setPageComplete(complete
);