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
.section
.name
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
15 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
16 import org
.eclipse
.jface
.wizard
.WizardPage
;
17 import org
.eclipse
.swt
.SWT
;
18 import org
.eclipse
.swt
.widgets
.Composite
;
20 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
21 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationshipType
;
22 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
23 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
;
24 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
.SelectionType
;
25 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
.TermComboType
;
26 import eu
.etaxonomy
.taxeditor
.forms
.RootElement
;
27 import eu
.etaxonomy
.taxeditor
.forms
.selection
.NameSelectionElement
;
28 import eu
.etaxonomy
.taxeditor
.forms
.term
.NameRelationshipTypeComboElement
;
31 * <p>NameRelationshipWizardPage class.</p>
34 * @created Jun 1, 2010
37 public class NameRelationshipWizardPage
extends WizardPage
implements IPropertyChangeListener
{
40 private static final Logger logger
= Logger
41 .getLogger(NameRelationshipWizardPage
.class);
44 private CdmFormFactory formFactory
;
47 private NameSelectionElement selection_relatedTo
;
50 private NameRelationshipTypeComboElement combo_relationshipType
;
53 private NameRelationshipDetailSection callingSection
;
56 private TaxonNameBase entity
;
59 private NameRelationshipType type
;
62 private TaxonNameBase toName
;
65 private RootElement rootElement
;
69 * <p>Constructor for NameRelationshipWizardPage.</p>
71 * @param callingSection a {@link eu.etaxonomy.taxeditor.section.name.NameRelationshipDetailSection} object.
73 protected NameRelationshipWizardPage(NameRelationshipDetailSection callingSection
) {
74 super("NameRelationshipWizardPage");
75 setTitle("New Name Relationship");
76 setDescription(callingSection
.getEntity().getTitleCache());
77 this.callingSection
= callingSection
;
78 this.entity
= callingSection
.getEntity();
79 this.formFactory
= callingSection
.getFormFactory();
81 formFactory
.addPropertyChangeListener(this);
85 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
88 public void createControl(Composite parent
) {
89 this.setPageComplete(false);
91 Composite control
= formFactory
.createComposite(parent
);
93 control
.setLayout(CdmFormFactory
.LAYOUT(2, false));
95 rootElement
= new RootElement(formFactory
, control
);
97 combo_relationshipType
= (NameRelationshipTypeComboElement
) formFactory
.createTermComboElement(TermComboType
.NAMERELATIONSHIP
, rootElement
, "Name Relationship Type", null, SWT
.NULL
);
99 selection_relatedTo
= (NameSelectionElement
) formFactory
.createSelectionElement(SelectionType
.NAME
, ((NameRelationshipWizard
)getWizard()).getConversationHolder(), rootElement
, "Related to", null, SWT
.NULL
);
105 * <p>getNameRelationship</p>
107 * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
109 public NameRelationship
getNameRelationship(){
110 return entity
.addRelationshipToName(toName
, type
, null, null, null);
114 public void propertyChange(PropertyChangeEvent event
) {
118 Object eventSource
= event
.getSource();
119 if(eventSource
== combo_relationshipType
){
120 type
= combo_relationshipType
.getSelection();
122 else if(eventSource
== selection_relatedTo
){
123 toName
= selection_relatedTo
.getEntity();
126 setPageComplete(type
!= null && toName
!= null);
131 public void dispose() {
132 rootElement
.removeElements();
133 formFactory
.removePropertyChangeListener(this);