Revision f561b00c
Added by Niels Hoffmann about 13 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameRelationshipWizardPage.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
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. |
|
9 |
*/ |
|
3 |
* Copyright (C) 2007 EDIT
|
|
4 |
* European Distributed Institute of Taxonomy
|
|
5 |
* http://www.e-taxonomy.eu
|
|
6 |
*
|
|
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.
|
|
9 |
*/
|
|
10 | 10 |
|
11 | 11 |
package eu.etaxonomy.taxeditor.ui.section.name; |
12 | 12 |
|
13 |
import org.apache.log4j.Logger; |
|
14 | 13 |
import org.eclipse.jface.util.IPropertyChangeListener; |
15 | 14 |
import org.eclipse.jface.util.PropertyChangeEvent; |
16 | 15 |
import org.eclipse.jface.wizard.WizardPage; |
... | ... | |
21 | 20 |
import eu.etaxonomy.cdm.model.name.NameRelationshipType; |
22 | 21 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
23 | 22 |
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory; |
24 |
import eu.etaxonomy.taxeditor.ui.forms.RootElement; |
|
25 | 23 |
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType; |
26 | 24 |
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.TermComboType; |
25 |
import eu.etaxonomy.taxeditor.ui.forms.RootElement; |
|
27 | 26 |
import eu.etaxonomy.taxeditor.ui.selection.NameSelectionElement; |
28 | 27 |
import eu.etaxonomy.taxeditor.ui.term.NameRelationshipTypeComboElement; |
29 | 28 |
|
30 | 29 |
/** |
31 |
* <p>NameRelationshipWizardPage class.</p> |
|
32 |
* |
|
30 |
* <p> |
|
31 |
* NameRelationshipWizardPage class. |
|
32 |
* </p> |
|
33 |
* |
|
33 | 34 |
* @author n.hoffmann |
34 | 35 |
* @created Jun 1, 2010 |
35 | 36 |
* @version 1.0 |
36 | 37 |
*/ |
37 |
public class NameRelationshipWizardPage extends WizardPage implements IPropertyChangeListener { |
|
38 |
|
|
39 |
|
|
40 |
private static final Logger logger = Logger |
|
41 |
.getLogger(NameRelationshipWizardPage.class); |
|
42 |
|
|
43 |
|
|
44 |
private CdmFormFactory formFactory; |
|
38 |
public class NameRelationshipWizardPage extends WizardPage implements |
|
39 |
IPropertyChangeListener { |
|
45 | 40 |
|
41 |
private final CdmFormFactory formFactory; |
|
46 | 42 |
|
47 | 43 |
private NameSelectionElement selection_relatedTo; |
48 | 44 |
|
49 |
|
|
50 | 45 |
private NameRelationshipTypeComboElement combo_relationshipType; |
51 | 46 |
|
47 |
private final NameRelationshipDetailSection callingSection; |
|
52 | 48 |
|
53 |
private NameRelationshipDetailSection callingSection; |
|
54 |
|
|
55 |
|
|
56 |
private TaxonNameBase entity; |
|
57 |
|
|
49 |
private final TaxonNameBase entity; |
|
58 | 50 |
|
59 | 51 |
private NameRelationshipType type; |
60 | 52 |
|
61 |
|
|
62 | 53 |
private TaxonNameBase toName; |
63 | 54 |
|
64 |
|
|
65 | 55 |
private RootElement rootElement; |
66 | 56 |
|
67 |
|
|
68 | 57 |
/** |
69 |
* <p>Constructor for NameRelationshipWizardPage.</p> |
|
70 |
* |
|
71 |
* @param callingSection a {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection} object. |
|
58 |
* <p> |
|
59 |
* Constructor for NameRelationshipWizardPage. |
|
60 |
* </p> |
|
61 |
* |
|
62 |
* @param callingSection |
|
63 |
* a |
|
64 |
* {@link eu.etaxonomy.taxeditor.ui.section.name.NameRelationshipDetailSection} |
|
65 |
* object. |
|
72 | 66 |
*/ |
73 |
protected NameRelationshipWizardPage(NameRelationshipDetailSection callingSection) { |
|
67 |
protected NameRelationshipWizardPage( |
|
68 |
NameRelationshipDetailSection callingSection) { |
|
74 | 69 |
super("NameRelationshipWizardPage"); |
75 | 70 |
setTitle("New Name Relationship"); |
76 | 71 |
setDescription(callingSection.getEntity().getTitleCache()); |
77 | 72 |
this.callingSection = callingSection; |
78 | 73 |
this.entity = callingSection.getEntity(); |
79 | 74 |
this.formFactory = callingSection.getFormFactory(); |
80 |
|
|
75 |
|
|
81 | 76 |
formFactory.addPropertyChangeListener(this); |
82 | 77 |
} |
83 |
|
|
84 |
/* (non-Javadoc) |
|
85 |
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) |
|
78 |
|
|
79 |
/* |
|
80 |
* (non-Javadoc) |
|
81 |
* |
|
82 |
* @see |
|
83 |
* org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets |
|
84 |
* .Composite) |
|
86 | 85 |
*/ |
87 | 86 |
/** {@inheritDoc} */ |
87 |
@Override |
|
88 | 88 |
public void createControl(Composite parent) { |
89 | 89 |
this.setPageComplete(false); |
90 |
|
|
91 |
Composite control = formFactory.createComposite(parent);
|
|
92 |
|
|
90 |
|
|
91 |
Composite control = formFactory.createComposite(parent); |
|
92 |
|
|
93 | 93 |
control.setLayout(CdmFormFactory.LAYOUT(2, false)); |
94 |
|
|
94 |
|
|
95 | 95 |
rootElement = new RootElement(formFactory, control); |
96 |
|
|
97 |
combo_relationshipType = (NameRelationshipTypeComboElement) formFactory.createTermComboElement(TermComboType.NAMERELATIONSHIP, rootElement, "Name Relationship Type", null, SWT.NULL); |
|
98 |
|
|
99 |
selection_relatedTo = (NameSelectionElement) formFactory.createSelectionElement(SelectionType.NAME, ((NameRelationshipWizard)getWizard()).getConversationHolder(), rootElement, "Related to", null, SWT.NULL); |
|
100 |
|
|
101 |
setControl(control); |
|
96 |
|
|
97 |
combo_relationshipType = (NameRelationshipTypeComboElement) formFactory |
|
98 |
.createTermComboElement(TermComboType.NAMERELATIONSHIP, |
|
99 |
rootElement, "Name Relationship Type", null, SWT.NULL); |
|
100 |
|
|
101 |
selection_relatedTo = (NameSelectionElement) formFactory |
|
102 |
.createSelectionElement(SelectionType.NAME, |
|
103 |
((NameRelationshipWizard) getWizard()) |
|
104 |
.getConversationHolder(), rootElement, |
|
105 |
"Related to", null, NameSelectionElement.DEFAULT, |
|
106 |
SWT.NULL); |
|
107 |
|
|
108 |
setControl(control); |
|
102 | 109 |
} |
103 |
|
|
110 |
|
|
104 | 111 |
/** |
105 |
* <p>getNameRelationship</p> |
|
106 |
* |
|
112 |
* <p> |
|
113 |
* getNameRelationship |
|
114 |
* </p> |
|
115 |
* |
|
107 | 116 |
* @return a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object. |
108 | 117 |
*/ |
109 |
public NameRelationship getNameRelationship(){ |
|
118 |
public NameRelationship getNameRelationship() {
|
|
110 | 119 |
return entity.addRelationshipToName(toName, type, null, null, null); |
111 | 120 |
} |
112 |
|
|
121 |
|
|
113 | 122 |
/** {@inheritDoc} */ |
123 |
@Override |
|
114 | 124 |
public void propertyChange(PropertyChangeEvent event) { |
115 |
if(event == null){
|
|
125 |
if (event == null) {
|
|
116 | 126 |
return; |
117 | 127 |
} |
118 | 128 |
Object eventSource = event.getSource(); |
119 |
if(eventSource == combo_relationshipType){
|
|
129 |
if (eventSource == combo_relationshipType) {
|
|
120 | 130 |
type = combo_relationshipType.getSelection(); |
121 |
} |
|
122 |
else if(eventSource == selection_relatedTo){ |
|
131 |
} else if (eventSource == selection_relatedTo) { |
|
123 | 132 |
toName = selection_relatedTo.getEntity(); |
124 | 133 |
} |
125 |
|
|
134 |
|
|
126 | 135 |
setPageComplete(type != null && toName != null); |
127 | 136 |
} |
128 |
|
|
137 |
|
|
129 | 138 |
/** {@inheritDoc} */ |
130 | 139 |
@Override |
131 | 140 |
public void dispose() { |
Also available in: Unified diff
Refactoring selection elements so they can be configured