1
|
/**
|
2
|
* Copyright (C) 2019 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 java.util.ArrayList;
|
12
|
import java.util.Arrays;
|
13
|
import java.util.Collections;
|
14
|
import java.util.Comparator;
|
15
|
import java.util.List;
|
16
|
|
17
|
import org.apache.commons.lang3.StringUtils;
|
18
|
import org.eclipse.jface.layout.GridLayoutFactory;
|
19
|
import org.eclipse.jface.viewers.ArrayContentProvider;
|
20
|
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
21
|
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
22
|
import org.eclipse.jface.viewers.ICheckStateListener;
|
23
|
import org.eclipse.jface.viewers.LabelProvider;
|
24
|
import org.eclipse.jface.wizard.WizardDialog;
|
25
|
import org.eclipse.swt.SWT;
|
26
|
import org.eclipse.swt.events.SelectionAdapter;
|
27
|
import org.eclipse.swt.events.SelectionEvent;
|
28
|
import org.eclipse.swt.events.SelectionListener;
|
29
|
import org.eclipse.swt.layout.GridData;
|
30
|
import org.eclipse.swt.layout.GridLayout;
|
31
|
import org.eclipse.swt.widgets.Button;
|
32
|
import org.eclipse.swt.widgets.Combo;
|
33
|
import org.eclipse.swt.widgets.Composite;
|
34
|
import org.eclipse.swt.widgets.Event;
|
35
|
import org.eclipse.swt.widgets.Label;
|
36
|
import org.eclipse.swt.widgets.Listener;
|
37
|
import org.osgi.service.component.annotations.ConfigurationPolicy;
|
38
|
|
39
|
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
|
40
|
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
41
|
import eu.etaxonomy.cdm.api.service.ITermTreeService;
|
42
|
import eu.etaxonomy.cdm.api.service.description.AggregationMode;
|
43
|
import eu.etaxonomy.cdm.api.service.description.AggregationSourceMode;
|
44
|
import eu.etaxonomy.cdm.api.service.description.DistributionAggregation;
|
45
|
import eu.etaxonomy.cdm.api.service.description.DistributionAggregationConfiguration;
|
46
|
import eu.etaxonomy.cdm.filter.LogicFilter;
|
47
|
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
|
48
|
import eu.etaxonomy.cdm.model.name.Rank;
|
49
|
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
|
50
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
51
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
52
|
import eu.etaxonomy.cdm.model.term.TermTree;
|
53
|
import eu.etaxonomy.cdm.model.term.TermType;
|
54
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
55
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
56
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
57
|
import eu.etaxonomy.taxeditor.ui.combo.OriginalSourceTypeComparator;
|
58
|
import eu.etaxonomy.taxeditor.ui.dialog.SuperAreaSelectionWizard;
|
59
|
|
60
|
/**
|
61
|
* @author k.luther
|
62
|
* @since 15.11.2019
|
63
|
*/
|
64
|
public class DistributionAggregationWizardPage
|
65
|
extends AggregationConfigurationWizardPage<DistributionAggregation,DistributionAggregationConfiguration>
|
66
|
implements Listener, SelectionListener{
|
67
|
|
68
|
private Button buttonSuperArea;
|
69
|
private Combo comboAreaLevel;
|
70
|
private Combo comboStatusOrder;
|
71
|
|
72
|
private Combo comboClassificationSelection;
|
73
|
private List<Classification> classifications;
|
74
|
private Classification selectedClassification;
|
75
|
|
76
|
|
77
|
|
78
|
private Object[] checkedElements;
|
79
|
|
80
|
public DistributionAggregationWizardPage(DistributionAggregationConfiguration configurator) {
|
81
|
super(Messages.DistributionAggregationWizardPage_TITLE);
|
82
|
this.configurator = configurator;
|
83
|
|
84
|
this.setDescription(Messages.DistributionAggregationWizardPage_DESCRIPTION);
|
85
|
}
|
86
|
|
87
|
@Override
|
88
|
public void createControl(Composite parent) {
|
89
|
final Composite composite = new Composite(parent, SWT.NULL);
|
90
|
|
91
|
String taxonStr = ""; //$NON-NLS-1$
|
92
|
int count = configurator.getTaxonNodeFilter().getSubtreeFilter().size();
|
93
|
boolean areaChecked = configurator.getAggregationModes().contains(AggregationMode.WithinTaxon);
|
94
|
boolean toParentChecked = configurator.getAggregationModes().contains(AggregationMode.ToParent);
|
95
|
for (LogicFilter<TaxonNode> filter: configurator.getTaxonNodeFilter().getSubtreeFilter()){
|
96
|
subTreeNode = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(filter.getUuid());
|
97
|
count--;
|
98
|
if (subTreeNode.hasTaxon()){
|
99
|
taxonStr += subTreeNode.getTaxon().getName().getTitleCache();
|
100
|
if (count>0){
|
101
|
taxonStr += ", "; //$NON-NLS-1$
|
102
|
}
|
103
|
}
|
104
|
}
|
105
|
if (StringUtils.isNotBlank(taxonStr)){
|
106
|
checkUseSelectedSubtree= new Button(composite, SWT.RADIO);
|
107
|
checkUseSelectedSubtree.setText(Messages.AggregationWizardPage_SUBTREE + " "+ taxonStr);
|
108
|
checkUseSelectedSubtree.addListener(SWT.Selection, new Listener() {
|
109
|
@Override
|
110
|
public void handleEvent(Event e) {
|
111
|
Button b = (Button) e.widget;
|
112
|
GridData data = (GridData) comboClassificationSelection.getLayoutData();
|
113
|
data.exclude = b.getSelection();
|
114
|
comboClassificationSelection.setEnabled(!data.exclude);
|
115
|
|
116
|
updateHigherRankCombo();
|
117
|
}
|
118
|
});
|
119
|
|
120
|
checkUseSelectedTaxonNode= new Button(composite, SWT.RADIO);
|
121
|
checkUseSelectedTaxonNode.setText(Messages.AggregationWizardPage_SINGLE_TAXON + " " + taxonStr + " "+Messages.AggregationWizardPage_WITHOUT_CHILDREN);
|
122
|
checkUseSelectedTaxonNode.addListener(SWT.Selection, new Listener() {
|
123
|
@Override
|
124
|
public void handleEvent(Event e) {
|
125
|
Button b = (Button) e.widget;
|
126
|
GridData data = (GridData) comboClassificationSelection.getLayoutData();
|
127
|
data.exclude = b.getSelection();
|
128
|
comboClassificationSelection.setEnabled(!data.exclude);
|
129
|
updateHigherRankCombo();
|
130
|
}
|
131
|
});
|
132
|
}
|
133
|
checkUseHigherLevel= new Button(composite, SWT.RADIO);
|
134
|
checkUseHigherLevel.setText(Messages.DistributionAggregationWizardPage_CLASSIFICATION);
|
135
|
checkUseHigherLevel.addListener(SWT.Selection, new Listener() {
|
136
|
@Override
|
137
|
public void handleEvent(Event e) {
|
138
|
Button b = (Button) e.widget;
|
139
|
GridData data = (GridData) comboClassificationSelection.getLayoutData();
|
140
|
data.exclude = b.getSelection();
|
141
|
comboClassificationSelection.setEnabled(data.exclude);
|
142
|
updateHigherRankCombo();
|
143
|
}
|
144
|
});
|
145
|
|
146
|
GridLayoutFactory.fillDefaults();
|
147
|
|
148
|
if (subTreeNode!= null){
|
149
|
selectedClassification = subTreeNode.getClassification();
|
150
|
}
|
151
|
GridData gridDataClassificationCombo = new GridData();
|
152
|
gridDataClassificationCombo = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
|
153
|
gridDataClassificationCombo.horizontalIndent = 5;
|
154
|
|
155
|
comboClassificationSelection = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
|
156
|
comboClassificationSelection.setLayoutData(gridDataClassificationCombo);
|
157
|
classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
|
158
|
Collections.sort(classifications, new Comparator<Classification>() {
|
159
|
|
160
|
@Override
|
161
|
public int compare(Classification o1, Classification o2) {
|
162
|
if (o1.equals(o2)){
|
163
|
return 0;
|
164
|
}
|
165
|
int result = o1.getTitleCache().compareTo(o2.getTitleCache());
|
166
|
if (result == 0){
|
167
|
return o1.getUuid().compareTo(o2.getUuid());
|
168
|
}
|
169
|
return result;
|
170
|
}
|
171
|
});
|
172
|
for(Classification tree : classifications){
|
173
|
comboClassificationSelection.add(tree.getName().getText(), classifications.indexOf(tree));
|
174
|
}
|
175
|
|
176
|
comboClassificationSelection.select(classifications.indexOf(selectedClassification));
|
177
|
comboClassificationSelection.addSelectionListener(this);
|
178
|
|
179
|
if (StringUtils.isNotBlank(taxonStr)){
|
180
|
checkUseSelectedSubtree.setSelection(true);
|
181
|
comboClassificationSelection.setEnabled(false);
|
182
|
}else{
|
183
|
checkUseHigherLevel.setSelection(true);
|
184
|
}
|
185
|
Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
|
186
|
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
|
187
|
gridData.horizontalSpan = 2;
|
188
|
gridData.verticalIndent = 5;
|
189
|
separator.setLayoutData(gridData);
|
190
|
|
191
|
GridLayout gridLayout = new GridLayout();
|
192
|
gridLayout.numColumns = 1;
|
193
|
|
194
|
composite.setLayout(gridLayout);
|
195
|
final Composite control = new Composite(composite, SWT.NULL);
|
196
|
GridLayout gridLayoutControl = new GridLayout();
|
197
|
gridLayoutControl.numColumns = 2;
|
198
|
control.setLayout(gridLayoutControl);
|
199
|
control.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
|
200
|
|
201
|
Label higherRankLabel = new Label(control, SWT.NULL);
|
202
|
higherRankLabel.setText(Messages.DistributionAggregationWizardPage_HIGHEST_RANK);
|
203
|
|
204
|
comboHigherRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
|
205
|
updateHigherRankCombo();
|
206
|
setConfigValueToRankCombo(comboHigherRank);
|
207
|
comboHigherRank.addListener(SWT.Selection, this);
|
208
|
|
209
|
Label lowerRankLabel = new Label(control, SWT.NULL);
|
210
|
lowerRankLabel.setText(Messages.DistributionAggregationWizardPage_LOWEST_RANK);
|
211
|
comboLowerRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
|
212
|
updateLowerRankCombo();
|
213
|
|
214
|
setConfigValueToRankCombo(comboLowerRank);
|
215
|
comboLowerRank.addListener(SWT.Selection, this);
|
216
|
|
217
|
separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
|
218
|
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
219
|
gridData.horizontalSpan = 2;
|
220
|
gridData.verticalIndent = 5;
|
221
|
separator.setLayoutData(gridData);
|
222
|
|
223
|
Label aggregationModeLabel = new Label(control, SWT.NULL);
|
224
|
aggregationModeLabel.setText(Messages.DistributionAggregationWizardPage_AGGREGATION_MODE);
|
225
|
aggregationModeLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_AGGR_MODE);
|
226
|
aggregationModeViewer = CheckboxTableViewer.newCheckList(control, SWT.BORDER | SWT.SINGLE);
|
227
|
aggregationModeViewer.setContentProvider(new ArrayContentProvider());
|
228
|
aggregationModeViewer.setLabelProvider(new LabelProvider(){
|
229
|
@Override
|
230
|
public String getText(Object element){
|
231
|
if (element instanceof AggregationMode){
|
232
|
if (((AggregationMode)element).equals(AggregationMode.ToParent)){
|
233
|
return Messages.DistributionAggregationWizardPage_CHILD_PARENT;
|
234
|
}
|
235
|
if (((AggregationMode)element).equals(AggregationMode.WithinTaxon)){
|
236
|
return Messages.DistributionAggregationWizardPage_AREA;
|
237
|
}
|
238
|
}
|
239
|
return null;
|
240
|
}
|
241
|
|
242
|
});
|
243
|
List<AggregationMode> aggregationModeList = new ArrayList<>();
|
244
|
for (AggregationMode mode: AggregationMode.values()){
|
245
|
aggregationModeList.add(mode);
|
246
|
}
|
247
|
|
248
|
aggregationModeViewer.setInput(aggregationModeList);
|
249
|
|
250
|
for (AggregationMode mode: configurator.getAggregationModes()){
|
251
|
if (mode instanceof AggregationMode){
|
252
|
aggregationModeViewer.setChecked(mode, true);
|
253
|
}
|
254
|
}
|
255
|
|
256
|
|
257
|
aggregationModeViewer.addCheckStateListener(new ICheckStateListener(){
|
258
|
@Override
|
259
|
public void checkStateChanged( CheckStateChangedEvent event){
|
260
|
Object[] checked =aggregationModeViewer.getCheckedElements();
|
261
|
boolean areachecked = false;
|
262
|
boolean toParentChecked = false;
|
263
|
for (int i = 0; i<checked.length;i++){
|
264
|
if (checked[i] instanceof AggregationMode){
|
265
|
if (((AggregationMode)checked[i]).equals(AggregationMode.WithinTaxon)){
|
266
|
areachecked = true;
|
267
|
}
|
268
|
if (((AggregationMode)checked[i]).equals(AggregationMode.ToParent)){
|
269
|
toParentChecked = true;
|
270
|
}
|
271
|
}
|
272
|
}
|
273
|
comboAreaLevel.setEnabled(areachecked);
|
274
|
buttonSuperArea.setEnabled(areachecked);
|
275
|
comboSourceModeWithinTaxon.setEnabled(areachecked);
|
276
|
comboSourceModeChildParent.setEnabled(toParentChecked);
|
277
|
AggregationSourceMode areaMode = (AggregationSourceMode)comboSourceModeWithinTaxon.getData(comboSourceModeWithinTaxon.getText());
|
278
|
AggregationSourceMode taxonMode = (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
|
279
|
sourceTypeViewer.getTable().setEnabled(((areachecked && (areaMode.equals(AggregationSourceMode.ALL) || areaMode.equals(AggregationSourceMode.ALL_SAMEVALUE) ) )|| toParentChecked && (taxonMode.equals(AggregationSourceMode.ALL) || taxonMode.equals(AggregationSourceMode.ALL_SAMEVALUE) )) );
|
280
|
getWizard().getContainer().updateButtons();
|
281
|
}
|
282
|
});
|
283
|
Label areaLevelLabel = new Label(control, SWT.NULL);
|
284
|
areaLevelLabel.setText(Messages.DistributionAggregationWizardPage_AREA_LEVEL);
|
285
|
areaLevelLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_AREA_LEVEL);
|
286
|
comboAreaLevel = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
|
287
|
List<NamedAreaLevel> namedAreaLevels = CdmStore.getTermManager().getAllTerms(TermType.NamedAreaLevel, null);
|
288
|
for (NamedAreaLevel level: namedAreaLevels) {
|
289
|
comboAreaLevel.add(level.getLabel());
|
290
|
comboAreaLevel.setData(level.getLabel(), level);
|
291
|
}
|
292
|
comboAreaLevel.addSelectionListener(this);
|
293
|
comboAreaLevel.setEnabled(areaChecked);
|
294
|
|
295
|
|
296
|
GridData gridData2 = new GridData();
|
297
|
gridData2.horizontalSpan = 2;
|
298
|
gridData2.horizontalAlignment = SWT.LEFT;
|
299
|
|
300
|
buttonSuperArea = new Button(control, SWT.PUSH );
|
301
|
buttonSuperArea.setLayoutData(gridData2);
|
302
|
buttonSuperArea.setEnabled(configurator.getAggregationModes().contains(AggregationMode.WithinTaxon));
|
303
|
buttonSuperArea.setText(Messages.DistributionAggregationWizardPage_SELECT_AREA);
|
304
|
buttonSuperArea.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_AREA_SELECTION);
|
305
|
buttonSuperArea.addSelectionListener(new SelectionAdapter() {
|
306
|
@Override
|
307
|
public void widgetSelected(SelectionEvent event) {
|
308
|
SuperAreaSelectionWizard availableDistributionWizard = new SuperAreaSelectionWizard(configurator, (NamedAreaLevel)comboAreaLevel.getData(comboAreaLevel.getText()));
|
309
|
WizardDialog dialog = new WizardDialog(AbstractUtility.getShell(),
|
310
|
availableDistributionWizard);
|
311
|
int open = dialog.open();
|
312
|
}
|
313
|
});
|
314
|
|
315
|
Label sourceModeLabel = new Label(control, SWT.NULL);
|
316
|
|
317
|
sourceModeLabel.setText(Messages.DistributionAggregationWizardPage_SOURCEMODE_CHILD_PARENT);
|
318
|
sourceModeLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_CHILD_PARENT);
|
319
|
comboSourceModeChildParent = new Combo(control, SWT.BORDER| SWT.READ_ONLY);
|
320
|
comboSourceModeChildParent.setText(Messages.DistributionAggregationWizardPage_AGGREGATION_MODE);
|
321
|
|
322
|
for (AggregationSourceMode mode :AggregationSourceMode.values()){
|
323
|
comboSourceModeChildParent.add(mode.getLabel());
|
324
|
comboSourceModeChildParent.setData(mode.getLabel(), mode);
|
325
|
}
|
326
|
|
327
|
comboSourceModeChildParent.addSelectionListener(this);
|
328
|
comboSourceModeChildParent.setEnabled(toParentChecked);
|
329
|
int index = 0;
|
330
|
if (configurator.getToParentSourceMode() == null ){
|
331
|
comboSourceModeChildParent.select(index);
|
332
|
}else{
|
333
|
for (String text:comboSourceModeChildParent.getItems()){
|
334
|
if (comboSourceModeChildParent.getData(text).equals(configurator.getToParentSourceMode())){
|
335
|
comboSourceModeChildParent.select(index);
|
336
|
}
|
337
|
index++;
|
338
|
}
|
339
|
}
|
340
|
|
341
|
Label sourceModeLabelSuperArea = new Label(control, SWT.NULL);
|
342
|
sourceModeLabelSuperArea.setText(Messages.DistributionAggregationWizardPage_SOURCE_MODE_AREA);
|
343
|
sourceModeLabelSuperArea.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_AREA);
|
344
|
comboSourceModeWithinTaxon = new Combo(control, SWT.BORDER| SWT.READ_ONLY);
|
345
|
comboSourceModeWithinTaxon.setText(Messages.DistributionAggregationWizardPage_AGGREGATION_MODE);
|
346
|
|
347
|
for (AggregationSourceMode mode :AggregationSourceMode.values()){
|
348
|
comboSourceModeWithinTaxon.add(mode.getLabel());
|
349
|
comboSourceModeWithinTaxon.setData(mode.getLabel(), mode);
|
350
|
}
|
351
|
|
352
|
comboSourceModeWithinTaxon.addSelectionListener(this);
|
353
|
comboSourceModeWithinTaxon.setEnabled(configurator.getAggregationModes().contains(AggregationMode.WithinTaxon));
|
354
|
|
355
|
index = 0;
|
356
|
if (configurator.getWithinTaxonSourceMode() == null ){
|
357
|
comboSourceModeWithinTaxon.select(index);
|
358
|
}else{
|
359
|
for (String text:comboSourceModeWithinTaxon.getItems()){
|
360
|
if (comboSourceModeWithinTaxon.getData(text).equals(configurator.getWithinTaxonSourceMode())){
|
361
|
comboSourceModeWithinTaxon.select(index);
|
362
|
}
|
363
|
index++;
|
364
|
}
|
365
|
}
|
366
|
|
367
|
|
368
|
|
369
|
Label sourceTypeLabel = new Label(control, SWT.NULL);
|
370
|
sourceTypeLabel.setText(Messages.DistributionAggregationWizardPage_SOURCE_TYPE);
|
371
|
sourceTypeLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_SOURCE_TYPE);
|
372
|
sourceTypeViewer = CheckboxTableViewer.newCheckList(control, SWT.BORDER | SWT.SINGLE);
|
373
|
sourceTypeViewer.setContentProvider(new ArrayContentProvider());
|
374
|
|
375
|
sourceTypeViewer.addCheckStateListener(new ICheckStateListener(){
|
376
|
@Override
|
377
|
public void checkStateChanged( CheckStateChangedEvent event){
|
378
|
checkedElements=sourceTypeViewer.getCheckedElements();
|
379
|
getWizard().getContainer().updateButtons();
|
380
|
}
|
381
|
});
|
382
|
|
383
|
List<String> typeStrings = new ArrayList<>();
|
384
|
OriginalSourceType[] typeArray = OriginalSourceType.values();
|
385
|
Arrays.sort(typeArray, new OriginalSourceTypeComparator(null));
|
386
|
Arrays.stream(typeArray).forEach(p ->typeMap.put(p.getLabel(), p));
|
387
|
Arrays.stream(typeArray).forEach(p ->typeStrings.add(p.getLabel()));
|
388
|
sourceTypeViewer.setInput(typeStrings);
|
389
|
for (OriginalSourceType sourceType: configurator.getAggregatingSourceTypes()){
|
390
|
sourceTypeViewer.setChecked(sourceType.getLabel(), true);
|
391
|
}
|
392
|
// sourceTypeViewer.setChecked(OriginalSourceType.PrimaryTaxonomicSource.getLabel(), true);
|
393
|
// sourceTypeViewer.getTable().setEnabled(false);
|
394
|
AggregationSourceMode taxonMode = configurator.getToParentSourceMode();
|
395
|
AggregationSourceMode areaMode = configurator.getWithinTaxonSourceMode();
|
396
|
sourceTypeViewer.getTable().setEnabled(((areaChecked && (areaMode.equals(AggregationSourceMode.ALL) || areaMode.equals(AggregationSourceMode.ALL_SAMEVALUE) ) )|| toParentChecked && (taxonMode.equals(AggregationSourceMode.ALL) || taxonMode.equals(AggregationSourceMode.ALL_SAMEVALUE) )) );
|
397
|
|
398
|
//aggregation mode
|
399
|
|
400
|
Label selectStatusLabel = new Label(control, SWT.NULL);
|
401
|
selectStatusLabel.setText(Messages.DistributionAggregationWizardPage_STATUS_ORDER);
|
402
|
comboStatusOrder = new Combo(control, SWT.PUSH );
|
403
|
comboStatusOrder.add(Messages.DistributionAggregationWizardPage_DEFAULT);
|
404
|
comboStatusOrder.setData(Messages.DistributionAggregationWizardPage_DEFAULT, null);
|
405
|
for (TermTree<?> tree: CdmStore.getService(ITermTreeService.class).list(TermType.PresenceAbsenceTerm, null, 0, null,null)){
|
406
|
comboStatusOrder.add(tree.getTitleCache());
|
407
|
comboStatusOrder.setData(tree.getTitleCache(), tree);
|
408
|
}
|
409
|
|
410
|
comboStatusOrder.addSelectionListener(this);
|
411
|
index = 0;
|
412
|
if (configurator.getStatusOrder() == null ){
|
413
|
comboStatusOrder.select(index);
|
414
|
}else{
|
415
|
for (String text:comboStatusOrder.getItems()){
|
416
|
if (text.equals(configurator.getStatusOrder().getTitleCache())){
|
417
|
comboStatusOrder.select(index);
|
418
|
}
|
419
|
index++;
|
420
|
}
|
421
|
}
|
422
|
|
423
|
checkIncludeUnpublishedTaxa = new Button(composite, SWT.CHECK);
|
424
|
checkIncludeUnpublishedTaxa.setText(Messages.DistributionAggregationWizardPage_EXPORT_UNPUBLISHED);
|
425
|
checkIncludeUnpublishedTaxa.setSelection(true);
|
426
|
|
427
|
GridLayoutFactory.fillDefaults();
|
428
|
|
429
|
setControl(composite);
|
430
|
}
|
431
|
|
432
|
|
433
|
@Override
|
434
|
public void widgetSelected(SelectionEvent e) {
|
435
|
|
436
|
if (e.getSource().equals(comboSourceModeChildParent) || e.getSource().equals(comboSourceModeWithinTaxon)){
|
437
|
AggregationSourceMode modeChild = (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
|
438
|
AggregationSourceMode modeArea = (AggregationSourceMode)comboSourceModeWithinTaxon.getData(comboSourceModeWithinTaxon.getText());
|
439
|
if ((comboSourceModeChildParent.isEnabled() && (modeChild != null && modeChild.equals(AggregationSourceMode.ALL) || modeChild.equals(AggregationSourceMode.ALL_SAMEVALUE))) ||(comboSourceModeWithinTaxon.isEnabled() && (modeArea != null && modeArea.equals(AggregationSourceMode.ALL) || modeArea.equals(AggregationSourceMode.ALL_SAMEVALUE)))){
|
440
|
sourceTypeViewer.getTable().setEnabled(true);
|
441
|
}else{
|
442
|
sourceTypeViewer.getTable().setEnabled(false);
|
443
|
}
|
444
|
}
|
445
|
|
446
|
if (e.getSource().equals(comboAreaLevel)){
|
447
|
buttonSuperArea.setEnabled(StringUtils.isNotBlank(comboAreaLevel.getText()));
|
448
|
}
|
449
|
}
|
450
|
|
451
|
@Override
|
452
|
public void widgetDefaultSelected(SelectionEvent e) {
|
453
|
// TODO Auto-generated method stub
|
454
|
}
|
455
|
|
456
|
@Override
|
457
|
public void handleEvent(Event event) {
|
458
|
if (event.widget.equals(comboHigherRank)){
|
459
|
updateLowerRankCombo();
|
460
|
}
|
461
|
if (event.widget.equals(comboClassificationSelection)){
|
462
|
updateHigherRankCombo();
|
463
|
updateLowerRankCombo();
|
464
|
}
|
465
|
if (event.widget.equals(this.checkUseHigherLevel)){
|
466
|
updateHigherRankCombo();
|
467
|
updateLowerRankCombo();
|
468
|
}
|
469
|
if (event.widget.equals(this.checkUseSelectedSubtree)){
|
470
|
updateHigherRankCombo();
|
471
|
updateLowerRankCombo();
|
472
|
}
|
473
|
if (event.widget.equals(this.checkUseSelectedTaxonNode)){
|
474
|
updateHigherRankCombo();
|
475
|
updateLowerRankCombo();
|
476
|
}
|
477
|
}
|
478
|
|
479
|
public TermTree getStatusOrder(){
|
480
|
if (StringUtils.isNotBlank(comboStatusOrder.getText())){
|
481
|
return (TermTree<?>)comboStatusOrder.getData(comboStatusOrder.getText());
|
482
|
}
|
483
|
return null;
|
484
|
}
|
485
|
|
486
|
public boolean useUnpublishedData(){
|
487
|
return checkIncludeUnpublishedTaxa.getSelection();
|
488
|
}
|
489
|
|
490
|
public Classification getSelectedClassification() {
|
491
|
return selectedClassification;
|
492
|
}
|
493
|
|
494
|
public TaxonNode getSubTreeNode() {
|
495
|
return subTreeNode;
|
496
|
}
|
497
|
}
|