3 * Copyright (C) 2014 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.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.name
;
12 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
13 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
14 import org
.eclipse
.jface
.wizard
.WizardPage
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationship
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CheckboxElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
26 import eu
.etaxonomy
.taxeditor
.ui
.element
.RootElement
;
27 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
34 public class SynonymRelationshipWizardPage
extends WizardPage
implements IPropertyChangeListener
{
36 private final CdmFormFactory formFactory
;
38 private EntitySelectionElement
<Taxon
> selection_relatedTo
;
40 private TermComboElement
<SynonymRelationshipType
> combo_relationshipType
;
42 private CheckboxElement checkboxProParte
;
44 private boolean isProParte
;
46 private CheckboxElement checkboxPartial
;
48 private boolean isPartial
;
50 private final Synonym entity
;
52 private SynonymRelationshipType type
;
56 private RootElement rootElement
;
60 * Constructor for NameRelationshipWizardPage.
63 * @param callingSection
65 * {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
68 protected SynonymRelationshipWizardPage(
69 SynonymRelationshipDetailSection callingSection
) {
70 super("SynonymRelationshipWizardPage");
71 setTitle("New Synonym Relationship");
72 setDescription(callingSection
.getEntity().getTitleCache());
73 this.entity
= callingSection
.getEntity();
74 this.formFactory
= callingSection
.getFormFactory();
76 formFactory
.addPropertyChangeListener(this);
83 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
88 public void createControl(Composite parent
) {
89 this.setPageComplete(false);
91 Composite control
= formFactory
.createComposite(parent
);
93 control
.setLayout(LayoutConstants
.LAYOUT(2, false));
95 rootElement
= new RootElement(formFactory
, control
);
97 combo_relationshipType
= formFactory
.createTermComboElement(SynonymRelationshipType
.class,
98 rootElement
, "Synonym Relationship Type", null, SWT
.NULL
);
100 selection_relatedTo
= formFactory
101 .createSelectionElement(Taxon
.class,
102 ((SynonymRelationshipWizard
) getWizard())
103 .getConversationHolder(), rootElement
,
104 "Related to", null, EntitySelectionElement
.ALL
,
107 checkboxProParte
= formFactory
.createCheckbox(rootElement
, "Pro Parte Synonym", null, SWT
.NULL
);
109 checkboxPartial
= formFactory
.createCheckbox(rootElement
, "Partial Synonym", null, SWT
.NULL
);
116 * getNameRelationship
119 * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
121 public SynonymRelationship
getSynonymRelationship() {
122 SynonymRelationship synonymRelationship
= taxon
.addSynonym(entity
, combo_relationshipType
.getSelection());
123 synonymRelationship
.setPartial(isPartial
);
124 synonymRelationship
.setProParte(isProParte
);
125 return synonymRelationship
;
130 public void propertyChange(PropertyChangeEvent event
) {
134 Object eventSource
= event
.getSource();
135 if (eventSource
== combo_relationshipType
) {
136 type
= combo_relationshipType
.getSelection();
137 } else if (eventSource
== selection_relatedTo
) {
138 taxon
= selection_relatedTo
.getEntity();
139 } else if (eventSource
== checkboxProParte
) {
140 isProParte
= checkboxProParte
.getSelection();
141 } else if (eventSource
== checkboxPartial
) {
142 isPartial
= checkboxPartial
.getSelection();
145 boolean complete
= type
!= null && taxon
!= null;
146 setPageComplete(complete
);
151 public void dispose() {
152 rootElement
.removeElements();
153 formFactory
.removePropertyChangeListener(this);