1
|
/**
|
2
|
* Copyright (C) 2017 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
|
package eu.etaxonomy.taxeditor.ui.dialog.configurator;
|
10
|
|
11
|
import org.eclipse.core.databinding.DataBindingContext;
|
12
|
import org.eclipse.core.databinding.beans.PojoProperties;
|
13
|
import org.eclipse.core.databinding.observable.value.IObservableValue;
|
14
|
import org.eclipse.jface.databinding.swt.WidgetProperties;
|
15
|
import org.eclipse.jface.wizard.WizardPage;
|
16
|
import org.eclipse.swt.SWT;
|
17
|
import org.eclipse.swt.layout.GridData;
|
18
|
import org.eclipse.swt.layout.GridLayout;
|
19
|
import org.eclipse.swt.widgets.Button;
|
20
|
import org.eclipse.swt.widgets.Composite;
|
21
|
import org.eclipse.swt.widgets.Event;
|
22
|
import org.eclipse.swt.widgets.Label;
|
23
|
import org.eclipse.swt.widgets.Listener;
|
24
|
import org.eclipse.swt.widgets.Text;
|
25
|
import org.eclipse.wb.swt.ResourceManager;
|
26
|
|
27
|
import eu.etaxonomy.cdm.api.service.config.SecundumForSubtreeConfigurator;
|
28
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
29
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
30
|
import eu.etaxonomy.taxeditor.preference.Resources;
|
31
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
32
|
import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
|
33
|
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
|
34
|
|
35
|
/**
|
36
|
* @author k.luther
|
37
|
* @date 10.02.2017
|
38
|
*
|
39
|
*/
|
40
|
public class SetSecundumConfiguratorWizardPage extends WizardPage implements Listener {
|
41
|
private DataBindingContext m_bindingContext;
|
42
|
|
43
|
private final SecundumForSubtreeConfigurator configurator;
|
44
|
|
45
|
private Button btnBrowseReference = null;
|
46
|
|
47
|
private Text textReference = null;
|
48
|
private Button btnClear = null;
|
49
|
private EntitySelectionElement<Reference> selectReference;
|
50
|
private Button btnIncludeAcceptedTaxa;
|
51
|
private Button btnIncludeSynonyms;
|
52
|
private Button btnOverwriteExistingAccepted;
|
53
|
private Button btnOverwriteExistingSynonyms;
|
54
|
private Button btnEmptySecundumDetail;
|
55
|
private Button btnIncludeSharedTaxa;
|
56
|
|
57
|
|
58
|
/**
|
59
|
* Create the composite.
|
60
|
* @param parent
|
61
|
* @param style
|
62
|
*/
|
63
|
public SetSecundumConfiguratorWizardPage(SecundumForSubtreeConfigurator configurator) {
|
64
|
super("Set Secundum Reference Configuration");
|
65
|
this.configurator = configurator;
|
66
|
this.setDescription(Messages.SetSecundumConfiguration_Description_Configurator);
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* @return
|
71
|
*/
|
72
|
private DataBindingContext initDataBindings() {
|
73
|
DataBindingContext bindingContext = new DataBindingContext();
|
74
|
|
75
|
IObservableValue observeSelectionBtnIncludeAcceptedTaxa = WidgetProperties.selection().observe(btnIncludeAcceptedTaxa);
|
76
|
IObservableValue includeAcceptedTaxaConfiguratorObserveValue = PojoProperties.value("includeAcceptedTaxa").observe(configurator);
|
77
|
bindingContext.bindValue(observeSelectionBtnIncludeAcceptedTaxa, includeAcceptedTaxaConfiguratorObserveValue, null, null);
|
78
|
|
79
|
IObservableValue observeSelectionBtnIncludeSynonyms = WidgetProperties.selection().observe(btnIncludeSynonyms);
|
80
|
IObservableValue includeSynonymsConfiguratorObserveValue = PojoProperties.value("includeSynonyms").observe(configurator);
|
81
|
bindingContext.bindValue(observeSelectionBtnIncludeSynonyms, includeSynonymsConfiguratorObserveValue, null, null);
|
82
|
|
83
|
IObservableValue observeSelectionBtnOverwriteExistingAccepted = WidgetProperties.selection().observe(btnOverwriteExistingAccepted);
|
84
|
IObservableValue overwriteExistingAcceptedConfiguratorObserveValue = PojoProperties.value("overwriteExistingAccepted").observe(configurator);
|
85
|
bindingContext.bindValue(observeSelectionBtnOverwriteExistingAccepted, overwriteExistingAcceptedConfiguratorObserveValue, null, null);
|
86
|
|
87
|
IObservableValue observeSelectionBtnOverwriteExistingSynonyms = WidgetProperties.selection().observe(btnOverwriteExistingSynonyms);
|
88
|
IObservableValue overwriteExistingSynonymsConfiguratorObserveValue = PojoProperties.value("overwriteExistingSynonyms").observe(configurator);
|
89
|
bindingContext.bindValue(observeSelectionBtnOverwriteExistingSynonyms, overwriteExistingSynonymsConfiguratorObserveValue, null, null);
|
90
|
|
91
|
IObservableValue observeSelectionBtnEmptySecundumDetail = WidgetProperties.selection().observe(btnEmptySecundumDetail);
|
92
|
IObservableValue emptySecundumDetailConfiguratorObserveValue = PojoProperties.value("emptySecundumDetail").observe(configurator);
|
93
|
bindingContext.bindValue(observeSelectionBtnEmptySecundumDetail, emptySecundumDetailConfiguratorObserveValue, null, null);
|
94
|
|
95
|
IObservableValue observeSelectionBtnIncludeSharedTaxal = WidgetProperties.selection().observe(btnIncludeSharedTaxa);
|
96
|
IObservableValue includeSharedTaxaConfiguratorObserveValue = PojoProperties.value("includeSharedTaxa").observe(configurator);
|
97
|
bindingContext.bindValue(observeSelectionBtnIncludeSharedTaxal, includeSharedTaxaConfiguratorObserveValue, null, null);
|
98
|
return bindingContext;
|
99
|
}
|
100
|
|
101
|
@Override
|
102
|
public void createControl(Composite parent) {
|
103
|
|
104
|
final Composite composite = new Composite(parent, SWT.NULL);
|
105
|
|
106
|
GridLayout gridLayout = new GridLayout();
|
107
|
gridLayout.numColumns = 1;
|
108
|
|
109
|
composite.setLayout(gridLayout);
|
110
|
final Composite compositeRef = new Composite(composite, SWT.NULL);
|
111
|
|
112
|
GridLayout gridLayoutRef = new GridLayout();
|
113
|
gridLayoutRef.numColumns = 4;
|
114
|
|
115
|
compositeRef.setLayout(gridLayoutRef);
|
116
|
compositeRef.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true));
|
117
|
Label label = new Label(compositeRef, SWT.WRAP);
|
118
|
label.setText(Messages.SetSecundumConfiguration_NewSecundum_Label);
|
119
|
label.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
|
120
|
|
121
|
textReference = new Text(compositeRef, SWT.BORDER);
|
122
|
textReference.setEditable(false);
|
123
|
textReference.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
|
124
|
// textReference.setTextLimit(Text.LIMIT);
|
125
|
textReference.setBackground(StoreUtil
|
126
|
.getColor(Resources.COLOR_TEXT_DISABLED_BACKGROUND));
|
127
|
|
128
|
|
129
|
btnBrowseReference = new Button(compositeRef, SWT.NONE);
|
130
|
btnBrowseReference.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/prj_obj.gif"));
|
131
|
btnBrowseReference.addListener(SWT.Selection, this);
|
132
|
btnBrowseReference.setFocus();
|
133
|
|
134
|
btnClear = new Button(compositeRef, SWT.NONE);
|
135
|
btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
|
136
|
btnClear.addListener(SWT.Selection, this);
|
137
|
Label labelDescription = new Label(compositeRef, SWT.WRAP);
|
138
|
labelDescription.setText(Messages.SetSecundumConfiguration_Description);
|
139
|
GridData gd_labelDescription = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
|
140
|
gd_labelDescription.horizontalSpan = 4;
|
141
|
labelDescription.setLayoutData(gd_labelDescription);
|
142
|
new Label(compositeRef, SWT.NONE);
|
143
|
new Label(compositeRef, SWT.NONE);
|
144
|
new Label(compositeRef, SWT.NONE);
|
145
|
|
146
|
// selectReference = toolkit.createSelectionElement(Rights.class, getConversationHolder(), composite, "Rights", null, EntitySelectionElement.SELECTABLE);
|
147
|
final Composite control = new Composite(composite, SWT.WRAP);
|
148
|
GridLayout gridLayoutControl = new GridLayout();
|
149
|
|
150
|
control.setLayout(gridLayoutControl);
|
151
|
control.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
|
152
|
// Composite control = toolkit.createComposite(composite);
|
153
|
btnIncludeAcceptedTaxa = new Button(control, SWT.CHECK);
|
154
|
btnIncludeAcceptedTaxa.setText(Messages.SetSecundumConfiguration_IncludeAcceptedTaxa);
|
155
|
btnIncludeAcceptedTaxa.setSelection(configurator.isIncludeAcceptedTaxa());
|
156
|
btnIncludeAcceptedTaxa.addListener(SWT.Selection, new Listener() {
|
157
|
@Override
|
158
|
public void handleEvent(Event e) {
|
159
|
Button b = (Button) e.widget;
|
160
|
GridData data = (GridData) btnIncludeAcceptedTaxa.getLayoutData();
|
161
|
data.exclude = b.getSelection();
|
162
|
btnOverwriteExistingAccepted.setVisible(data.exclude);
|
163
|
btnIncludeSharedTaxa.setVisible(data.exclude);
|
164
|
if (!btnIncludeSynonyms.getSelection() && !data.exclude){
|
165
|
btnEmptySecundumDetail.setVisible(false);
|
166
|
setPageComplete(false);
|
167
|
}else{
|
168
|
btnEmptySecundumDetail.setVisible(true);
|
169
|
setPageComplete(true);
|
170
|
}
|
171
|
}
|
172
|
});
|
173
|
|
174
|
btnOverwriteExistingAccepted = new Button(control, SWT.CHECK);
|
175
|
GridData gd_btnOverwriteExistingAccepted = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
176
|
gd_btnOverwriteExistingAccepted.horizontalIndent = 10;
|
177
|
btnOverwriteExistingAccepted.setLayoutData(gd_btnOverwriteExistingAccepted);
|
178
|
btnOverwriteExistingAccepted.setText(Messages.SetSecundumConfiguration_OverwriteExistingAccepted);
|
179
|
|
180
|
btnIncludeSharedTaxa = new Button(control, SWT.CHECK);
|
181
|
GridData gd_btnIncludeSharedTaxa = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
182
|
gd_btnIncludeSharedTaxa.horizontalIndent = 10;
|
183
|
btnIncludeSharedTaxa.setLayoutData(gd_btnIncludeSharedTaxa);
|
184
|
btnIncludeSharedTaxa.setText(Messages.SetSecundumConfiguration_IncludeSharedtaxa);
|
185
|
btnIncludeSharedTaxa.setSelection(configurator.isIncludeSharedTaxa());
|
186
|
|
187
|
btnIncludeSynonyms = new Button(control, SWT.CHECK);
|
188
|
btnIncludeSynonyms.setText(Messages.SetSecundumConfiguration_IncludeSynonyms);
|
189
|
btnIncludeSynonyms.setSelection(configurator.isIncludeSynonyms());
|
190
|
btnIncludeSynonyms.addListener(SWT.Selection, new Listener() {
|
191
|
@Override
|
192
|
public void handleEvent(Event e) {
|
193
|
Button b = (Button) e.widget;
|
194
|
GridData data = (GridData) btnIncludeSynonyms.getLayoutData();
|
195
|
data.exclude = b.getSelection();
|
196
|
btnOverwriteExistingSynonyms.setVisible(data.exclude);
|
197
|
if (!btnIncludeAcceptedTaxa.getSelection() && !data.exclude){
|
198
|
btnEmptySecundumDetail.setVisible(false);
|
199
|
setPageComplete(false);
|
200
|
}else{
|
201
|
btnEmptySecundumDetail.setVisible(true);
|
202
|
setPageComplete(true);
|
203
|
}
|
204
|
|
205
|
}
|
206
|
});
|
207
|
|
208
|
btnOverwriteExistingAccepted.setSelection(configurator.isOverwriteExistingAccepted());
|
209
|
btnOverwriteExistingSynonyms = new Button(control, SWT.CHECK);
|
210
|
GridData gd_btnOverwriteExistingSynonyms = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
211
|
gd_btnOverwriteExistingSynonyms.horizontalIndent = 10;
|
212
|
btnOverwriteExistingSynonyms.setLayoutData(gd_btnOverwriteExistingSynonyms);
|
213
|
btnOverwriteExistingSynonyms.setText(Messages.SetSecundumConfiguration_OverwriteExistingSynonyms);
|
214
|
btnOverwriteExistingSynonyms.setSelection(configurator.isOverwriteExistingSynonyms());
|
215
|
btnEmptySecundumDetail = new Button(control, SWT.CHECK);
|
216
|
btnEmptySecundumDetail.setText(Messages.SetSecundumConfiguration_EmptySecundumDetail);
|
217
|
btnEmptySecundumDetail.setSelection(configurator.isEmptySecundumDetail());
|
218
|
|
219
|
m_bindingContext = initDataBindings();
|
220
|
setControl(composite);
|
221
|
}
|
222
|
|
223
|
|
224
|
|
225
|
@Override
|
226
|
public void handleEvent(Event event) {
|
227
|
Reference reference;
|
228
|
if(event.widget==btnBrowseReference){
|
229
|
reference = SelectionDialogFactory.getSelectionFromDialog(Reference.class, this.getShell(), null, null);
|
230
|
if(reference!=null){
|
231
|
this.configurator.setNewSecundum(reference);
|
232
|
textReference.setText(reference.getTitleCache());
|
233
|
|
234
|
}
|
235
|
|
236
|
} else if(event.widget==btnClear){
|
237
|
reference = null;
|
238
|
textReference.setText("");
|
239
|
this.configurator.setNewSecundum(null);
|
240
|
} else{
|
241
|
reference = null;
|
242
|
textReference.setText("");
|
243
|
this.configurator.setNewSecundum(null);
|
244
|
}
|
245
|
|
246
|
}
|
247
|
|
248
|
|
249
|
|
250
|
|
251
|
|
252
|
|
253
|
}
|