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
.swt
.SWT
;
15 import org
.eclipse
.swt
.widgets
.Composite
;
17 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
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
.AbstractEntityCollectionElementWizardPage
;
23 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CheckboxElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.selection
.EntitySelectionElement
;
32 public class SynonymRelationshipWizardPage
extends AbstractEntityCollectionElementWizardPage
implements IPropertyChangeListener
{
35 private EntitySelectionElement
<Taxon
> selection_relatedTo
;
37 private TermComboElement
<SynonymRelationshipType
> combo_relationshipType
;
39 private CheckboxElement checkboxProParte
;
41 private boolean isProParte
;
43 private CheckboxElement checkboxPartial
;
45 private boolean isPartial
;
47 private final Synonym entity
;
49 private SynonymRelationshipType type
;
56 * Constructor for NameRelationshipWizardPage.
59 * @param callingSection
61 * {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
64 protected SynonymRelationshipWizardPage(
65 SynonymRelationshipDetailSection callingSection
) {
66 super("SynonymRelationshipWizardPage");
67 setTitle("New Synonym 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 super.createControl(parent
);
87 combo_relationshipType
= formFactory
.createDefinedTermComboElement(TermType
.SynonymRelationshipType
,
88 rootElement
, "Synonym Relationship Type", null, SWT
.NULL
);
90 selection_relatedTo
= formFactory
91 .createSelectionElement(Taxon
.class,
92 ((SynonymRelationshipWizard
) getWizard())
93 .getConversationHolder(), rootElement
,
94 "Related to", null, EntitySelectionElement
.ALL
,
97 checkboxProParte
= formFactory
.createCheckbox(rootElement
, "Pro Parte Synonym", null, SWT
.NULL
);
99 checkboxPartial
= formFactory
.createCheckbox(rootElement
, "Partial Synonym", null, SWT
.NULL
);
105 * getNameRelationship
108 * @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
110 public SynonymRelationship
getSynonymRelationship() {
111 SynonymRelationship synonymRelationship
= taxon
.addSynonym(entity
, combo_relationshipType
.getSelection());
112 synonymRelationship
.setPartial(isPartial
);
113 synonymRelationship
.setProParte(isProParte
);
114 return synonymRelationship
;
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 taxon
= selection_relatedTo
.getEntity();
128 } else if (eventSource
== checkboxProParte
) {
129 isProParte
= checkboxProParte
.getSelection();
130 } else if (eventSource
== checkboxPartial
) {
131 isPartial
= checkboxPartial
.getSelection();
134 boolean complete
= type
!= null && taxon
!= null;
135 setPageComplete(complete
);