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.EnumSet;
|
16
|
import java.util.HashMap;
|
17
|
import java.util.List;
|
18
|
import java.util.Map;
|
19
|
|
20
|
import org.apache.commons.lang.StringUtils;
|
21
|
import org.eclipse.jface.layout.GridLayoutFactory;
|
22
|
import org.eclipse.jface.viewers.ArrayContentProvider;
|
23
|
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
24
|
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
25
|
import org.eclipse.jface.viewers.ICheckStateListener;
|
26
|
import org.eclipse.jface.viewers.LabelProvider;
|
27
|
import org.eclipse.jface.wizard.WizardDialog;
|
28
|
import org.eclipse.jface.wizard.WizardPage;
|
29
|
import org.eclipse.swt.SWT;
|
30
|
import org.eclipse.swt.events.SelectionAdapter;
|
31
|
import org.eclipse.swt.events.SelectionEvent;
|
32
|
import org.eclipse.swt.events.SelectionListener;
|
33
|
import org.eclipse.swt.layout.GridData;
|
34
|
import org.eclipse.swt.layout.GridLayout;
|
35
|
import org.eclipse.swt.widgets.Button;
|
36
|
import org.eclipse.swt.widgets.Combo;
|
37
|
import org.eclipse.swt.widgets.Composite;
|
38
|
import org.eclipse.swt.widgets.Event;
|
39
|
import org.eclipse.swt.widgets.Label;
|
40
|
import org.eclipse.swt.widgets.Listener;
|
41
|
|
42
|
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
|
43
|
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
44
|
import eu.etaxonomy.cdm.api.service.ITermTreeService;
|
45
|
import eu.etaxonomy.cdm.api.service.description.AggregationMode;
|
46
|
import eu.etaxonomy.cdm.api.service.description.AggregationSourceMode;
|
47
|
import eu.etaxonomy.cdm.api.service.description.DistributionAggregationConfiguration;
|
48
|
import eu.etaxonomy.cdm.filter.LogicFilter;
|
49
|
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
|
50
|
import eu.etaxonomy.cdm.model.name.Rank;
|
51
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
52
|
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
|
53
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
54
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
55
|
import eu.etaxonomy.cdm.model.term.TermTree;
|
56
|
import eu.etaxonomy.cdm.model.term.TermType;
|
57
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
58
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
59
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
60
|
import eu.etaxonomy.taxeditor.ui.combo.OriginalSourceTypeComparator;
|
61
|
import eu.etaxonomy.taxeditor.ui.dialog.SuperAreaSelectionWizard;
|
62
|
|
63
|
/**
|
64
|
* @author k.luther
|
65
|
* @since 15.11.2019
|
66
|
*/
|
67
|
public class DistributionAggregationWizardPage extends WizardPage implements Listener, SelectionListener{
|
68
|
|
69
|
private DistributionAggregationConfiguration configurator;
|
70
|
|
71
|
private Combo comboHigherRank;
|
72
|
private Combo comboLowerRank;
|
73
|
|
74
|
private Combo comboSourceModeChildParent;
|
75
|
private Combo comboSourceModeSubAreaSuperArea;
|
76
|
|
77
|
private CheckboxTableViewer aggregationModeViewer;
|
78
|
|
79
|
private Button btnSelectSuperAreas;
|
80
|
private Button buttonSuperArea;
|
81
|
private Combo comboAreaLevel;
|
82
|
private Combo comboStatusOrder;
|
83
|
|
84
|
|
85
|
private Combo comboClassificationSelection;
|
86
|
private List<Classification> classifications;
|
87
|
private Classification selectedClassification;
|
88
|
|
89
|
|
90
|
|
91
|
private Button checkUseSelectedTaxonNode;
|
92
|
private Button checkUseSelectedClassification;
|
93
|
private Button checkUseSelectedSubtree;
|
94
|
|
95
|
|
96
|
private Button checkExportUnpublished;
|
97
|
|
98
|
private TaxonNode subTreeNode;
|
99
|
private CheckboxTableViewer sourceTypeViewer;
|
100
|
Object[] checkedElements;
|
101
|
Map<String, OriginalSourceType> typeMap = new HashMap();
|
102
|
|
103
|
Comparator comparator = new Comparator<Rank>(){
|
104
|
|
105
|
@Override
|
106
|
public int compare(Rank o1, Rank o2) {
|
107
|
return o2.compareTo(o1);
|
108
|
}
|
109
|
|
110
|
};
|
111
|
|
112
|
|
113
|
/**
|
114
|
* @param pageName
|
115
|
*/
|
116
|
public DistributionAggregationWizardPage(DistributionAggregationConfiguration configurator) {
|
117
|
super("Distribution aggregation configuration");
|
118
|
this.configurator = configurator;
|
119
|
|
120
|
this.setDescription("Configure the aggregation");
|
121
|
|
122
|
}
|
123
|
|
124
|
|
125
|
@Override
|
126
|
public void createControl(Composite parent) {
|
127
|
final Composite composite = new Composite(parent, SWT.NULL);
|
128
|
|
129
|
String taxonStr = "";
|
130
|
int count = configurator.getTaxonNodeFilter().getSubtreeFilter().size();
|
131
|
|
132
|
for (LogicFilter<TaxonNode> filter: configurator.getTaxonNodeFilter().getSubtreeFilter()){
|
133
|
subTreeNode = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(filter.getUuid());
|
134
|
count--;
|
135
|
if (subTreeNode.hasTaxon()){
|
136
|
taxonStr += subTreeNode.getTaxon().getName().getTitleCache();
|
137
|
if (count>0){
|
138
|
taxonStr += ", ";
|
139
|
}
|
140
|
}
|
141
|
}
|
142
|
if (StringUtils.isNotBlank(taxonStr)){
|
143
|
checkUseSelectedSubtree= new Button(composite, SWT.RADIO);
|
144
|
checkUseSelectedSubtree.setText("Aggregation for selected subtree(s) "+ taxonStr);
|
145
|
checkUseSelectedSubtree.addListener(SWT.Selection, new Listener() {
|
146
|
@Override
|
147
|
public void handleEvent(Event e) {
|
148
|
Button b = (Button) e.widget;
|
149
|
GridData data = (GridData) comboClassificationSelection.getLayoutData();
|
150
|
data.exclude = b.getSelection();
|
151
|
comboClassificationSelection.setEnabled(!data.exclude);
|
152
|
|
153
|
updateHigherRankCombo();
|
154
|
}
|
155
|
});
|
156
|
|
157
|
checkUseSelectedTaxonNode= new Button(composite, SWT.RADIO);
|
158
|
checkUseSelectedTaxonNode.setText("Aggregation only for "+ taxonStr);
|
159
|
checkUseSelectedTaxonNode.addListener(SWT.Selection, new Listener() {
|
160
|
@Override
|
161
|
public void handleEvent(Event e) {
|
162
|
Button b = (Button) e.widget;
|
163
|
GridData data = (GridData) comboClassificationSelection.getLayoutData();
|
164
|
data.exclude = b.getSelection();
|
165
|
comboClassificationSelection.setEnabled(!data.exclude);
|
166
|
updateHigherRankCombo();
|
167
|
}
|
168
|
|
169
|
|
170
|
});
|
171
|
}
|
172
|
checkUseSelectedClassification= new Button(composite, SWT.RADIO);
|
173
|
checkUseSelectedClassification.setText("Aggregate selected classification");
|
174
|
checkUseSelectedClassification.addListener(SWT.Selection, new Listener() {
|
175
|
@Override
|
176
|
public void handleEvent(Event e) {
|
177
|
Button b = (Button) e.widget;
|
178
|
GridData data = (GridData) comboClassificationSelection.getLayoutData();
|
179
|
data.exclude = b.getSelection();
|
180
|
comboClassificationSelection.setEnabled(data.exclude);
|
181
|
updateHigherRankCombo();
|
182
|
}
|
183
|
});
|
184
|
|
185
|
GridLayoutFactory.fillDefaults();
|
186
|
|
187
|
if (subTreeNode!= null){
|
188
|
selectedClassification = subTreeNode.getClassification();
|
189
|
}
|
190
|
GridData gridDataClassificationCombo = new GridData();
|
191
|
gridDataClassificationCombo = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
|
192
|
gridDataClassificationCombo.horizontalIndent = 5;
|
193
|
|
194
|
comboClassificationSelection = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
|
195
|
comboClassificationSelection.setLayoutData(gridDataClassificationCombo);
|
196
|
classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
|
197
|
Collections.sort(classifications, new Comparator<Classification>() {
|
198
|
|
199
|
@Override
|
200
|
public int compare(Classification o1, Classification o2) {
|
201
|
if (o1.equals(o2)){
|
202
|
return 0;
|
203
|
}
|
204
|
int result = o1.getTitleCache().compareTo(o2.getTitleCache());
|
205
|
if (result == 0){
|
206
|
return o1.getUuid().compareTo(o2.getUuid());
|
207
|
}
|
208
|
return result;
|
209
|
}
|
210
|
});
|
211
|
for(Classification tree : classifications){
|
212
|
comboClassificationSelection.add(tree.getName().getText(), classifications.indexOf(tree));
|
213
|
|
214
|
}
|
215
|
|
216
|
comboClassificationSelection.select(classifications.indexOf(selectedClassification));
|
217
|
comboClassificationSelection.addSelectionListener(this);
|
218
|
|
219
|
if (StringUtils.isNotBlank(taxonStr)){
|
220
|
checkUseSelectedSubtree.setSelection(true);
|
221
|
comboClassificationSelection.setEnabled(false);
|
222
|
}else{
|
223
|
checkUseSelectedClassification.setSelection(true);
|
224
|
}
|
225
|
Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
|
226
|
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
|
227
|
gridData.horizontalSpan = 2;
|
228
|
gridData.verticalIndent = 5;
|
229
|
separator.setLayoutData(gridData);
|
230
|
|
231
|
GridLayout gridLayout = new GridLayout();
|
232
|
gridLayout.numColumns = 1;
|
233
|
|
234
|
composite.setLayout(gridLayout);
|
235
|
final Composite control = new Composite(composite, SWT.NULL);
|
236
|
GridLayout gridLayoutControl = new GridLayout();
|
237
|
gridLayoutControl.numColumns = 2;
|
238
|
control.setLayout(gridLayoutControl);
|
239
|
control.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
|
240
|
|
241
|
Label higherRankLabel = new Label(control, SWT.NULL);
|
242
|
higherRankLabel.setText("Highest rank");
|
243
|
|
244
|
comboHigherRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
|
245
|
updateHigherRankCombo();
|
246
|
comboHigherRank.addListener(SWT.Selection, this);
|
247
|
|
248
|
|
249
|
Label lowerRankLabel = new Label(control, SWT.NULL);
|
250
|
lowerRankLabel.setText("Lowest rank");
|
251
|
comboLowerRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
|
252
|
updateLowerRankCombo();
|
253
|
comboLowerRank.addListener(SWT.Selection, this);
|
254
|
|
255
|
separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
|
256
|
gridData = new GridData(GridData.FILL_HORIZONTAL);
|
257
|
gridData.horizontalSpan = 2;
|
258
|
gridData.verticalIndent = 5;
|
259
|
separator.setLayoutData(gridData);
|
260
|
|
261
|
Label aggregationModeLabel = new Label(control, SWT.NULL);
|
262
|
aggregationModeLabel.setText("Aggregation mode");
|
263
|
aggregationModeLabel.setToolTipText("Selecting none would delete all existing aggregated distributions");
|
264
|
aggregationModeViewer = CheckboxTableViewer.newCheckList(control, SWT.BORDER | SWT.SINGLE);
|
265
|
aggregationModeViewer.setContentProvider(new ArrayContentProvider());
|
266
|
aggregationModeViewer.setLabelProvider(new LabelProvider(){
|
267
|
@Override
|
268
|
public String getText(Object element){
|
269
|
if (element instanceof AggregationMode){
|
270
|
if (((AggregationMode)element).equals(AggregationMode.ToParent)){
|
271
|
return "From child to parent taxon";
|
272
|
}
|
273
|
if (((AggregationMode)element).equals(AggregationMode.WithinTaxon)){
|
274
|
return "From sub area to super area";
|
275
|
}
|
276
|
}
|
277
|
return null;
|
278
|
}
|
279
|
|
280
|
});
|
281
|
List<AggregationMode> aggregationModeList = new ArrayList<>();
|
282
|
for (AggregationMode mode: AggregationMode.values()){
|
283
|
aggregationModeList.add(mode);
|
284
|
}
|
285
|
|
286
|
aggregationModeViewer.setInput(aggregationModeList);
|
287
|
|
288
|
aggregationModeViewer.addCheckStateListener(new ICheckStateListener(){
|
289
|
@Override
|
290
|
public void checkStateChanged( CheckStateChangedEvent event){
|
291
|
Object[] checked =aggregationModeViewer.getCheckedElements();
|
292
|
boolean areachecked = false;
|
293
|
boolean toParentChecked = false;
|
294
|
for (int i = 0; i<checked.length;i++){
|
295
|
if (checked[i] instanceof AggregationMode){
|
296
|
if (((AggregationMode)checked[i]).equals(AggregationMode.WithinTaxon)){
|
297
|
areachecked = true;
|
298
|
}
|
299
|
if (((AggregationMode)checked[i]).equals(AggregationMode.ToParent)){
|
300
|
toParentChecked = true;
|
301
|
}
|
302
|
}
|
303
|
}
|
304
|
comboAreaLevel.setEnabled(areachecked);
|
305
|
buttonSuperArea.setEnabled(areachecked);
|
306
|
comboSourceModeSubAreaSuperArea.setEnabled(areachecked);
|
307
|
comboSourceModeChildParent.setEnabled(toParentChecked);
|
308
|
getWizard().getContainer().updateButtons();
|
309
|
}
|
310
|
});
|
311
|
Label areaLevelLabel = new Label(control, SWT.NULL);
|
312
|
areaLevelLabel.setText("Area Level");
|
313
|
areaLevelLabel.setToolTipText("Selecting the area level to which the distribution should be aggregated");
|
314
|
comboAreaLevel = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
|
315
|
List<NamedAreaLevel> namedAreaLevels = CdmStore.getTermManager().getAllTerms(TermType.NamedAreaLevel, null);
|
316
|
for (NamedAreaLevel level: namedAreaLevels) {
|
317
|
comboAreaLevel.add(level.getLabel());
|
318
|
comboAreaLevel.setData(level.getLabel(), level);
|
319
|
}
|
320
|
comboAreaLevel.addSelectionListener(this);
|
321
|
comboAreaLevel.setEnabled(false);
|
322
|
GridData gridData2 = new GridData();
|
323
|
gridData2.horizontalSpan = 2;
|
324
|
gridData2.horizontalAlignment = SWT.LEFT;
|
325
|
|
326
|
buttonSuperArea = new Button(control, SWT.PUSH );
|
327
|
buttonSuperArea.setLayoutData(gridData2);
|
328
|
buttonSuperArea.setEnabled(false);
|
329
|
buttonSuperArea.setText("Select Super Areas");
|
330
|
buttonSuperArea.setToolTipText("If area aggregation is selected, the super areas can be selected. If none are selected the top level areas are used.");
|
331
|
buttonSuperArea.addSelectionListener(new SelectionAdapter() {
|
332
|
@Override
|
333
|
public void widgetSelected(SelectionEvent event) {
|
334
|
SuperAreaSelectionWizard availableDistributionWizard = new SuperAreaSelectionWizard(configurator, (NamedAreaLevel)comboAreaLevel.getData(comboAreaLevel.getText()));
|
335
|
WizardDialog dialog = new WizardDialog(StoreUtil.getShell(),
|
336
|
availableDistributionWizard);
|
337
|
int open = dialog.open();
|
338
|
}
|
339
|
});
|
340
|
|
341
|
|
342
|
|
343
|
|
344
|
Label sourceModeLabel = new Label(control, SWT.NULL);
|
345
|
|
346
|
sourceModeLabel.setText("Source mode child/parent");
|
347
|
sourceModeLabel.setToolTipText("Defines the source mode if aggregation from child to parent taxon is selected.");
|
348
|
comboSourceModeChildParent = new Combo(control, SWT.BORDER| SWT.READ_ONLY);
|
349
|
comboSourceModeChildParent.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
|
350
|
comboSourceModeChildParent.add("None");
|
351
|
comboSourceModeChildParent.setData(null);
|
352
|
for (AggregationSourceMode mode :AggregationSourceMode.values()){
|
353
|
comboSourceModeChildParent.add(mode.toString());
|
354
|
comboSourceModeChildParent.setData(mode.toString(), mode);
|
355
|
|
356
|
}
|
357
|
|
358
|
comboSourceModeChildParent.addSelectionListener(this);
|
359
|
comboSourceModeChildParent.setEnabled(false);
|
360
|
comboSourceModeChildParent.select(0);
|
361
|
|
362
|
Label sourceModeLabelSuperArea = new Label(control, SWT.NULL);
|
363
|
sourceModeLabelSuperArea.setText("Source mode sub area/super area");
|
364
|
sourceModeLabelSuperArea.setToolTipText("Defines the source mode if aggregation from sub area to super area is selected.");
|
365
|
comboSourceModeSubAreaSuperArea = new Combo(control, SWT.BORDER| SWT.READ_ONLY);
|
366
|
comboSourceModeSubAreaSuperArea.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
|
367
|
comboSourceModeSubAreaSuperArea.add("None");
|
368
|
comboSourceModeSubAreaSuperArea.setData(null);
|
369
|
for (AggregationSourceMode mode :AggregationSourceMode.values()){
|
370
|
comboSourceModeSubAreaSuperArea.add(mode.toString());
|
371
|
comboSourceModeSubAreaSuperArea.setData(mode.toString(), mode);
|
372
|
}
|
373
|
|
374
|
comboSourceModeSubAreaSuperArea.addSelectionListener(this);
|
375
|
comboSourceModeSubAreaSuperArea.setEnabled(false);
|
376
|
comboSourceModeSubAreaSuperArea.select(0);
|
377
|
Label sourceTypeLabel = new Label(control, SWT.NULL);
|
378
|
sourceTypeLabel.setText("Source type");
|
379
|
sourceTypeLabel.setToolTipText("Type of sources that should added to the aggregated distribution");
|
380
|
sourceTypeViewer = CheckboxTableViewer.newCheckList(control, SWT.BORDER | SWT.SINGLE);
|
381
|
sourceTypeViewer.setContentProvider(new ArrayContentProvider());
|
382
|
|
383
|
|
384
|
sourceTypeViewer.addCheckStateListener(new ICheckStateListener(){
|
385
|
@Override
|
386
|
public void checkStateChanged( CheckStateChangedEvent event){
|
387
|
checkedElements=sourceTypeViewer.getCheckedElements();
|
388
|
getWizard().getContainer().updateButtons();
|
389
|
}
|
390
|
});
|
391
|
|
392
|
List<String> typeStrings = new ArrayList<>();
|
393
|
OriginalSourceType[] typeArray = OriginalSourceType.values();
|
394
|
Arrays.sort(typeArray, new OriginalSourceTypeComparator(null));
|
395
|
Arrays.stream(typeArray).forEach(p ->typeMap.put(p.getMessage(), p));
|
396
|
Arrays.stream(typeArray).forEach(p ->typeStrings.add(p.getMessage()));
|
397
|
typeStrings.remove(OriginalSourceType.NomenclaturalReference.getMessage());
|
398
|
sourceTypeViewer.setInput(typeStrings);
|
399
|
sourceTypeViewer.setChecked(OriginalSourceType.PrimaryMediaSource.getMessage(), true);
|
400
|
sourceTypeViewer.setChecked(OriginalSourceType.PrimaryTaxonomicSource.getMessage(), true);
|
401
|
sourceTypeViewer.getTable().setEnabled(false);
|
402
|
|
403
|
//aggregation mode
|
404
|
|
405
|
|
406
|
|
407
|
Label selectStatusLabel = new Label(control, SWT.NULL);
|
408
|
selectStatusLabel.setText("Status order");
|
409
|
comboStatusOrder = new Combo(control, SWT.PUSH );
|
410
|
comboStatusOrder.add("Default - by Presence Absence Term vocabulary");
|
411
|
comboStatusOrder.setData("Default - by Presence Absence Term vocabulary", null);
|
412
|
for (TermTree tree: CdmStore.getService(ITermTreeService.class).list(TermType.PresenceAbsenceTerm, null, 0, null,null)){
|
413
|
comboStatusOrder.add(tree.getTitleCache());
|
414
|
comboStatusOrder.setData(tree.getTitleCache(), tree);
|
415
|
}
|
416
|
|
417
|
comboStatusOrder.addSelectionListener(this);
|
418
|
comboStatusOrder.select(0);
|
419
|
|
420
|
checkExportUnpublished = new Button(composite, SWT.CHECK);
|
421
|
checkExportUnpublished.setText("Export unpublished taxa");
|
422
|
|
423
|
GridLayoutFactory.fillDefaults();
|
424
|
|
425
|
|
426
|
|
427
|
setControl(composite);
|
428
|
|
429
|
}
|
430
|
|
431
|
|
432
|
|
433
|
|
434
|
|
435
|
|
436
|
@Override
|
437
|
public void widgetSelected(SelectionEvent e) {
|
438
|
|
439
|
if (e.getSource().equals(comboSourceModeChildParent) || e.getSource().equals(comboSourceModeSubAreaSuperArea)){
|
440
|
AggregationSourceMode modeChild = (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
|
441
|
AggregationSourceMode modeArea = (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
|
442
|
if ((modeChild != null && modeChild.equals(AggregationSourceMode.ALL) || modeChild.equals(AggregationSourceMode.ALL_SAMEVALUE)) ||(modeArea != null && modeArea.equals(AggregationSourceMode.ALL) || modeArea.equals(AggregationSourceMode.ALL_SAMEVALUE))){
|
443
|
sourceTypeViewer.getTable().setEnabled(true);
|
444
|
}else{
|
445
|
sourceTypeViewer.getTable().setEnabled(false);
|
446
|
}
|
447
|
|
448
|
}
|
449
|
|
450
|
if (e.getSource().equals(comboAreaLevel)){
|
451
|
buttonSuperArea.setEnabled(StringUtils.isNotBlank(comboAreaLevel.getText()));
|
452
|
}
|
453
|
|
454
|
|
455
|
}
|
456
|
|
457
|
|
458
|
@Override
|
459
|
public void widgetDefaultSelected(SelectionEvent e) {
|
460
|
// TODO Auto-generated method stub
|
461
|
|
462
|
}
|
463
|
|
464
|
|
465
|
@Override
|
466
|
public void handleEvent(Event event) {
|
467
|
if (event.widget.equals(comboHigherRank)){
|
468
|
updateLowerRankCombo();
|
469
|
}
|
470
|
if (event.widget.equals(selectedClassification)){
|
471
|
updateHigherRankCombo();
|
472
|
updateLowerRankCombo();
|
473
|
}
|
474
|
if (event.widget.equals(this.checkUseSelectedClassification)){
|
475
|
updateHigherRankCombo();
|
476
|
updateLowerRankCombo();
|
477
|
}
|
478
|
if (event.widget.equals(this.checkUseSelectedSubtree)){
|
479
|
updateHigherRankCombo();
|
480
|
updateLowerRankCombo();
|
481
|
}
|
482
|
if (event.widget.equals(this.checkUseSelectedTaxonNode)){
|
483
|
updateHigherRankCombo();
|
484
|
updateLowerRankCombo();
|
485
|
}
|
486
|
|
487
|
}
|
488
|
|
489
|
private void updateHigherRankCombo() {
|
490
|
comboHigherRank.removeAll();
|
491
|
List<Rank> rankList = new ArrayList<>();
|
492
|
TaxonName name = null;
|
493
|
if (subTreeNode != null){
|
494
|
if (subTreeNode.getTaxon() != null){
|
495
|
name = subTreeNode.getTaxon().getName();
|
496
|
}
|
497
|
}
|
498
|
comboHigherRank.add("");
|
499
|
if (name != null){
|
500
|
for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
|
501
|
if (useClassification() || (name != null && name.getRank().isHigher(rank))){
|
502
|
rankList.add(rank);
|
503
|
}
|
504
|
}
|
505
|
}else{
|
506
|
for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
|
507
|
rankList.add(rank);
|
508
|
}
|
509
|
}
|
510
|
|
511
|
rankList.sort(comparator);
|
512
|
for (Rank rank: rankList){
|
513
|
comboHigherRank.add(rank.getLabel());
|
514
|
comboHigherRank.setData(rank.getLabel(), rank);
|
515
|
}
|
516
|
|
517
|
|
518
|
}
|
519
|
|
520
|
|
521
|
private void updateLowerRankCombo() {
|
522
|
comboLowerRank.removeAll();
|
523
|
TaxonName name = null;
|
524
|
List<Rank> rankList = new ArrayList<>();
|
525
|
if (subTreeNode != null){
|
526
|
if (subTreeNode.getTaxon() != null){
|
527
|
name = subTreeNode.getTaxon().getName();
|
528
|
}
|
529
|
}
|
530
|
comboLowerRank.add("");
|
531
|
for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
|
532
|
if (subTreeNode == null && (comboHigherRank.getText() == null || (comboHigherRank.getData(comboHigherRank.getText()) != null && ((Rank)comboHigherRank.getData(comboHigherRank.getText())).isHigher(rank)))){
|
533
|
rankList.add(rank);
|
534
|
}else if (name == null || name.getRank().isHigher(rank)) {
|
535
|
if(StringUtils.isBlank(comboHigherRank.getText()) || comboHigherRank.getData(comboHigherRank.getText()) != null && ((Rank)comboHigherRank.getData(comboHigherRank.getText())).isHigher(rank)){
|
536
|
// the rank is lower than higher rank and lower than the rank of the subtree name
|
537
|
rankList.add(rank);
|
538
|
}
|
539
|
}
|
540
|
}
|
541
|
rankList.sort(comparator);
|
542
|
for (Rank rank: rankList){
|
543
|
comboLowerRank.add(rank.getLabel());
|
544
|
comboLowerRank.setData(rank.getLabel(), rank);
|
545
|
}
|
546
|
|
547
|
}
|
548
|
|
549
|
public Rank getHigherRank(){
|
550
|
if (StringUtils.isNotBlank(comboHigherRank.getText())){
|
551
|
return (Rank)comboHigherRank.getData(comboHigherRank.getText());
|
552
|
}
|
553
|
return null;
|
554
|
}
|
555
|
|
556
|
public Rank getLowerRank(){
|
557
|
if (StringUtils.isNotBlank(comboLowerRank.getText())){
|
558
|
return (Rank)comboLowerRank.getData(comboLowerRank.getText());
|
559
|
}
|
560
|
return null;
|
561
|
}
|
562
|
|
563
|
|
564
|
public AggregationSourceMode getSourceModeChildParent(){
|
565
|
if (StringUtils.isNotBlank(comboSourceModeChildParent.getText())){
|
566
|
return (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
|
567
|
}
|
568
|
return null;
|
569
|
}
|
570
|
|
571
|
public AggregationSourceMode getSourceModeSuperAreaSubArea(){
|
572
|
if (StringUtils.isNotBlank(comboSourceModeSubAreaSuperArea.getText())){
|
573
|
return (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
|
574
|
|
575
|
}
|
576
|
return null;
|
577
|
}
|
578
|
|
579
|
public TermTree getStatusOrder(){
|
580
|
if (StringUtils.isNotBlank(comboStatusOrder.getText())){
|
581
|
return (TermTree)comboStatusOrder.getData(comboStatusOrder.getText());
|
582
|
}
|
583
|
return null;
|
584
|
}
|
585
|
|
586
|
public boolean useClassification(){
|
587
|
return checkUseSelectedClassification.getSelection();
|
588
|
}
|
589
|
|
590
|
public boolean useSubtree(){
|
591
|
return checkUseSelectedSubtree.getSelection();
|
592
|
}
|
593
|
|
594
|
public boolean useTaxonNode(){
|
595
|
return checkUseSelectedTaxonNode.getSelection();
|
596
|
}
|
597
|
|
598
|
public boolean useUnpublishedData(){
|
599
|
return checkExportUnpublished.getSelection();
|
600
|
}
|
601
|
|
602
|
public EnumSet<OriginalSourceType> getSourceTypes(){
|
603
|
List<OriginalSourceType> list = new ArrayList<>();
|
604
|
for (Object o: sourceTypeViewer.getCheckedElements()){
|
605
|
String string = null;
|
606
|
if (o instanceof String){
|
607
|
string = (String)o;
|
608
|
}
|
609
|
if (string != null){
|
610
|
list.add(typeMap.get(string));
|
611
|
}
|
612
|
}
|
613
|
|
614
|
return EnumSet.copyOf(list);
|
615
|
}
|
616
|
|
617
|
public List<AggregationSourceMode> getAggregationMode(){
|
618
|
|
619
|
List<AggregationSourceMode> result = new ArrayList<>();
|
620
|
for (Object o: aggregationModeViewer.getCheckedElements()){
|
621
|
if (o instanceof AggregationSourceMode){
|
622
|
result.add((AggregationSourceMode)o);
|
623
|
}
|
624
|
}
|
625
|
return result;
|
626
|
}
|
627
|
|
628
|
|
629
|
public Classification getSelectedClassification() {
|
630
|
return selectedClassification;
|
631
|
}
|
632
|
|
633
|
|
634
|
public TaxonNode getSubTreeNode() {
|
635
|
return subTreeNode;
|
636
|
}
|
637
|
}
|