1
|
// $Id$
|
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
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.newWizard;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
15
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
16
|
import org.eclipse.jface.wizard.WizardPage;
|
17
|
import org.eclipse.swt.SWT;
|
18
|
import org.eclipse.swt.graphics.Color;
|
19
|
import org.eclipse.swt.widgets.Composite;
|
20
|
import org.eclipse.swt.widgets.Display;
|
21
|
|
22
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
23
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
24
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
25
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
26
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
27
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
28
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
29
|
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
|
30
|
import eu.etaxonomy.taxeditor.ui.forms.RootElement;
|
31
|
import eu.etaxonomy.taxeditor.ui.forms.TextWithLabelElement;
|
32
|
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.SelectionType;
|
33
|
import eu.etaxonomy.taxeditor.ui.selection.ReferenceSelectionElement;
|
34
|
|
35
|
/**
|
36
|
* <p>ClassificationWizardPage class.</p>
|
37
|
*
|
38
|
* @author n.hoffmann
|
39
|
* @created Sep 29, 2010
|
40
|
* @version 1.0
|
41
|
*/
|
42
|
@Deprecated // remove this file when refactoring is complete
|
43
|
public class ClassificationWizardPage extends WizardPage implements IPropertyChangeListener, IConversationEnabled {
|
44
|
private static final Logger logger = Logger
|
45
|
.getLogger(ClassificationWizardPage.class);
|
46
|
private Classification classification;
|
47
|
|
48
|
private ConversationHolder conversation;
|
49
|
private CdmFormFactory formFactory;
|
50
|
private Composite control;
|
51
|
private TextWithLabelElement text_classificationLabel;
|
52
|
private ReferenceSelectionElement selection_reference;
|
53
|
private TextWithLabelElement text_referenceDetail;
|
54
|
|
55
|
/**
|
56
|
* <p>Constructor for ClassificationWizardPage.</p>
|
57
|
*
|
58
|
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
59
|
* @param classification a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
|
60
|
*/
|
61
|
protected ClassificationWizardPage(ConversationHolder conversation, Classification classification){
|
62
|
super("Classification");
|
63
|
this.setTitle("Classification");
|
64
|
this.setDescription(classification == null ? "Create a new Classification." : "Edit Classification.");
|
65
|
|
66
|
this.classification = classification;
|
67
|
this.conversation = conversation;
|
68
|
|
69
|
this.formFactory = new CdmFormFactory(Display.getCurrent());
|
70
|
|
71
|
formFactory.addPropertyChangeListener(this);
|
72
|
|
73
|
initialize();
|
74
|
}
|
75
|
|
76
|
|
77
|
/* (non-Javadoc)
|
78
|
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
79
|
*/
|
80
|
/** {@inheritDoc} */
|
81
|
public void createControl(Composite parent) {
|
82
|
control = formFactory.createComposite(parent);
|
83
|
|
84
|
control.setLayout(CdmFormFactory.LAYOUT(2, false));
|
85
|
RootElement rootElement = new RootElement(formFactory, control);
|
86
|
|
87
|
text_classificationLabel = formFactory.createTextWithLabelElement(rootElement, "Label", classification.getName().getText(), SWT.NULL);
|
88
|
selection_reference = (ReferenceSelectionElement) formFactory.createSelectionElement(SelectionType.REFERENCE, getConversationHolder(), rootElement, "Reference", classification.getReference(), SWT.NULL);
|
89
|
text_referenceDetail = formFactory.createTextWithLabelElement(rootElement, "Reference Detail", classification.getMicroReference(), SWT.NULL);
|
90
|
|
91
|
Color bgColor = getShell().getBackground();
|
92
|
|
93
|
rootElement.setBackground(bgColor);
|
94
|
control.setBackground(bgColor);
|
95
|
|
96
|
setControl(control);
|
97
|
}
|
98
|
|
99
|
private void initialize() {
|
100
|
if(classification == null){
|
101
|
classification = Classification.NewInstance(null, null, CdmStore.getDefaultLanguage());
|
102
|
}
|
103
|
}
|
104
|
|
105
|
/* (non-Javadoc)
|
106
|
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
|
107
|
*/
|
108
|
/** {@inheritDoc} */
|
109
|
@Override
|
110
|
public void propertyChange(PropertyChangeEvent event) {
|
111
|
Object eventSource = event.getSource();
|
112
|
|
113
|
if(eventSource == text_classificationLabel){
|
114
|
classification.setName(LanguageString.NewInstance(text_classificationLabel.getText(), CdmStore.getDefaultLanguage()));
|
115
|
}
|
116
|
else if(eventSource == selection_reference){
|
117
|
classification.setReference(selection_reference.getEntity());
|
118
|
}
|
119
|
else if(eventSource == text_referenceDetail){
|
120
|
classification.setMicroReference(text_referenceDetail.getText());
|
121
|
}
|
122
|
|
123
|
checkComplete();
|
124
|
}
|
125
|
|
126
|
|
127
|
/**
|
128
|
*
|
129
|
*/
|
130
|
private void checkComplete() {
|
131
|
if(CdmUtils.isEmpty(text_classificationLabel.getText())){
|
132
|
setMessage("A Classifications label may not be empty");
|
133
|
setPageComplete(false);
|
134
|
}else{
|
135
|
setMessage(null);
|
136
|
setPageComplete(true);
|
137
|
}
|
138
|
}
|
139
|
|
140
|
/**
|
141
|
* <p>Getter for the field <code>classification</code>.</p>
|
142
|
*
|
143
|
* @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
|
144
|
*/
|
145
|
public Classification getClassification() {
|
146
|
return classification;
|
147
|
}
|
148
|
|
149
|
|
150
|
/* (non-Javadoc)
|
151
|
* @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
|
152
|
*/
|
153
|
/** {@inheritDoc} */
|
154
|
@Override
|
155
|
public void update(CdmDataChangeMap changeEvents) {}
|
156
|
|
157
|
|
158
|
/* (non-Javadoc)
|
159
|
* @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
|
160
|
*/
|
161
|
/** {@inheritDoc} */
|
162
|
@Override
|
163
|
public ConversationHolder getConversationHolder() {
|
164
|
return conversation;
|
165
|
}
|
166
|
|
167
|
/* (non-Javadoc)
|
168
|
* @see org.eclipse.jface.dialogs.DialogPage#dispose()
|
169
|
*/
|
170
|
/** {@inheritDoc} */
|
171
|
@Override
|
172
|
public void dispose() {
|
173
|
formFactory.removePropertyChangeListener(this);
|
174
|
super.dispose();
|
175
|
}
|
176
|
}
|