1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.ui.section.name;
|
11
|
|
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;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.common.TermType;
|
18
|
import eu.etaxonomy.cdm.model.name.NameRelationship;
|
19
|
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
|
20
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
21
|
import eu.etaxonomy.taxeditor.ui.AbstractEntityCollectionElementWizardPage;
|
22
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
24
|
|
25
|
/**
|
26
|
* <p>
|
27
|
* NameRelationshipWizardPage class.
|
28
|
* </p>
|
29
|
*
|
30
|
* @author n.hoffmann
|
31
|
* @created Jun 1, 2010
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
public class NameRelationshipWizardPage extends AbstractEntityCollectionElementWizardPage implements
|
35
|
IPropertyChangeListener {
|
36
|
|
37
|
private EntitySelectionElement<TaxonName> selection_relatedTo;
|
38
|
|
39
|
private TermComboElement<NameRelationshipType> combo_relationshipType;
|
40
|
|
41
|
private final TaxonName entity;
|
42
|
|
43
|
private NameRelationshipType type;
|
44
|
|
45
|
private TaxonName toName;
|
46
|
|
47
|
/**
|
48
|
* <p>
|
49
|
* Constructor for NameRelationshipWizardPage.
|
50
|
* </p>
|
51
|
*
|
52
|
* @param callingSection
|
53
|
* a
|
54
|
* {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection}
|
55
|
* object.
|
56
|
*/
|
57
|
protected NameRelationshipWizardPage(
|
58
|
NameRelationshipDetailSection callingSection) {
|
59
|
super("NameRelationshipWizardPage");
|
60
|
setTitle("New Name Relationship");
|
61
|
setDescription(callingSection.getEntity().getTitleCache());
|
62
|
this.entity = callingSection.getEntity();
|
63
|
this.formFactory = callingSection.getFormFactory();
|
64
|
|
65
|
formFactory.addPropertyChangeListener(this);
|
66
|
}
|
67
|
|
68
|
/*
|
69
|
* (non-Javadoc)
|
70
|
*
|
71
|
* @see
|
72
|
* org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
|
73
|
* .Composite)
|
74
|
*/
|
75
|
/** {@inheritDoc} */
|
76
|
@Override
|
77
|
public void createControl(Composite parent) {
|
78
|
super.createControl(parent);
|
79
|
|
80
|
combo_relationshipType = formFactory.createDefinedTermComboElement(TermType.NameRelationshipType,
|
81
|
rootElement, "Name Relationship Type", null, SWT.NULL);
|
82
|
|
83
|
selection_relatedTo = formFactory
|
84
|
.createSelectionElement(TaxonName.class,
|
85
|
((NameRelationshipWizard) getWizard())
|
86
|
.getConversationHolder(), rootElement,
|
87
|
"Related to",this.entity, EntitySelectionElement.ALL,
|
88
|
SWT.NULL, true);
|
89
|
|
90
|
}
|
91
|
|
92
|
/**
|
93
|
* <p>
|
94
|
* getNameRelationship
|
95
|
* </p>
|
96
|
*
|
97
|
* @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
|
98
|
*/
|
99
|
public NameRelationship getNameRelationship() {
|
100
|
return entity.addRelationshipToName(toName, type, null, null, null);
|
101
|
}
|
102
|
|
103
|
/** {@inheritDoc} */
|
104
|
@Override
|
105
|
public void propertyChange(PropertyChangeEvent event) {
|
106
|
if (event == null) {
|
107
|
return;
|
108
|
}
|
109
|
Object eventSource = event.getSource();
|
110
|
if (eventSource == combo_relationshipType) {
|
111
|
type = combo_relationshipType.getSelection();
|
112
|
} else if (eventSource == selection_relatedTo) {
|
113
|
toName = selection_relatedTo.getEntity();
|
114
|
}
|
115
|
|
116
|
boolean complete = type != null && toName != null;
|
117
|
setPageComplete(complete);
|
118
|
}
|
119
|
|
120
|
}
|