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
.common
.TermType
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationship
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.CheckboxElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
27 import eu
.etaxonomy
.taxeditor
.ui
.element
.RootElement
;
28 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
35 public class SynonymRelationshipWizardPage
extends WizardPage
implements IPropertyChangeListener
{
37 private final CdmFormFactory formFactory
;
39 private EntitySelectionElement
<Taxon
> selection_relatedTo
;
41 private TermComboElement
<SynonymRelationshipType
> combo_relationshipType
;
43 private CheckboxElement checkboxProParte
;
45 private boolean isProParte
;
47 private CheckboxElement checkboxPartial
;
49 private boolean isPartial
;
51 private final Synonym entity
;
53 private SynonymRelationshipType type
;
57 private RootElement rootElement
;
61 * Constructor for NameRelationshipWizardPage.
64 * @param callingSection
66 * {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
69 protected SynonymRelationshipWizardPage(
70 SynonymRelationshipDetailSection callingSection
) {
71 super("SynonymRelationshipWizardPage");
72 setTitle("New Synonym Relationship");
73 setDescription(callingSection
.getEntity().getTitleCache());
74 this.entity
= callingSection
.getEntity();
75 this.formFactory
= callingSection
.getFormFactory();
77 formFactory
.addPropertyChangeListener(this);
84 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
89 public void createControl(Composite parent
) {
90 this.setPageComplete(false);
92 Composite control
= formFactory
.createComposite(parent
);
94 control
.setLayout(LayoutConstants
.LAYOUT(2, false));
96 rootElement
= new RootElement(formFactory
, control
);
98 combo_relationshipType
= formFactory
.createDefinedTermComboElement(TermType
.SynonymRelationshipType
,
99 rootElement
, "Synonym Relationship Type", null, SWT
.NULL
);
101 selection_relatedTo
= formFactory
102 .createSelectionElement(Taxon
.class,
103 ((SynonymRelationshipWizard
) getWizard())
104 .getConversationHolder(), rootElement
,
105 "Related to", null, EntitySelectionElement
.ALL
,
108 checkboxProParte
= formFactory
.createCheckbox(rootElement
, "Pro Parte Synonym", null, SWT
.NULL
);
110 checkboxPartial
= formFactory
.createCheckbox(rootElement
, "Partial Synonym", null, SWT
.NULL
);
117 * getNameRelationship
120 * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
122 public SynonymRelationship
getSynonymRelationship() {
123 SynonymRelationship synonymRelationship
= taxon
.addSynonym(entity
, combo_relationshipType
.getSelection());
124 synonymRelationship
.setPartial(isPartial
);
125 synonymRelationship
.setProParte(isProParte
);
126 return synonymRelationship
;
131 public void propertyChange(PropertyChangeEvent event
) {
135 Object eventSource
= event
.getSource();
136 if (eventSource
== combo_relationshipType
) {
137 type
= combo_relationshipType
.getSelection();
138 } else if (eventSource
== selection_relatedTo
) {
139 taxon
= selection_relatedTo
.getEntity();
140 } else if (eventSource
== checkboxProParte
) {
141 isProParte
= checkboxProParte
.getSelection();
142 } else if (eventSource
== checkboxPartial
) {
143 isPartial
= checkboxPartial
.getSelection();
146 boolean complete
= type
!= null && taxon
!= null;
147 setPageComplete(complete
);
152 public void dispose() {
153 rootElement
.removeElements();
154 formFactory
.removePropertyChangeListener(this);