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;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.Arrays;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import org.apache.commons.collections.CollectionUtils;
|
16
|
import org.eclipse.jface.wizard.Wizard;
|
17
|
|
18
|
import eu.etaxonomy.cdm.api.service.description.DistributionAggregationConfiguration;
|
19
|
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
|
20
|
import eu.etaxonomy.cdm.persistence.dto.TermDto;
|
21
|
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
|
22
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
23
|
import eu.etaxonomy.taxeditor.ui.dialog.configurator.wizard.SuperAreaPage;
|
24
|
|
25
|
/**
|
26
|
* @author k.luther
|
27
|
* @since 25.11.2019
|
28
|
*/
|
29
|
public class SuperAreaSelectionWizard extends Wizard {
|
30
|
|
31
|
private final SuperAreaPage aPage;
|
32
|
DistributionAggregationConfiguration configurator;
|
33
|
|
34
|
public SuperAreaSelectionWizard(DistributionAggregationConfiguration configurator, NamedAreaLevel level) {
|
35
|
setWindowTitle(Messages.AvailableDistributionWizard_WINDOW_TITLE);
|
36
|
// TODO if preferenceStore has elements checked load elements in wizard
|
37
|
aPage = new SuperAreaPage(Messages.AvailableDistributionWizard_PAGE_TITLE, level);
|
38
|
this.configurator = configurator;
|
39
|
}
|
40
|
|
41
|
@Override
|
42
|
public boolean performFinish() {
|
43
|
// TODO: get Selection and save in EditorPreferences
|
44
|
if (!checkNoneChecked()) {
|
45
|
Object[] checkedElements = aPage.getViewer().getCheckedElements();
|
46
|
Object[] grayedElements = aPage.getViewer().getGrayedElements();
|
47
|
ArrayList checkedList = new ArrayList(Arrays.asList(checkedElements));
|
48
|
ArrayList grayedList = new ArrayList(Arrays.asList(grayedElements));
|
49
|
checkedList = (ArrayList) CollectionUtils.subtract(checkedList, grayedList);
|
50
|
ArrayList<UUID> listUIIDChecked = new ArrayList<>();
|
51
|
ArrayList<UUID> listUIIDGrayed = new ArrayList<UUID>();
|
52
|
for (Object o : checkedList) {
|
53
|
if (o instanceof TermDto) {
|
54
|
listUIIDChecked.add(((TermDto) o).getUuid());
|
55
|
|
56
|
}else if(o instanceof TermVocabularyDto){
|
57
|
TermVocabularyDto termVocDto = (TermVocabularyDto) o;
|
58
|
listUIIDGrayed.add(termVocDto.getUuid());
|
59
|
}
|
60
|
}
|
61
|
// for (Object o : grayedList) {
|
62
|
// if (o instanceof TermDto) {
|
63
|
// listUIIDChecked.add(((TermDto) o).getUuid());
|
64
|
//
|
65
|
// }else if(o instanceof TermVocabularyDto){
|
66
|
// TermVocabularyDto termVocDto = (TermVocabularyDto) o;
|
67
|
// listUIIDGrayed.add(termVocDto.getUuid());
|
68
|
// }
|
69
|
// }
|
70
|
|
71
|
configurator.setSuperAreas(listUIIDChecked);
|
72
|
|
73
|
|
74
|
return true;
|
75
|
} else {
|
76
|
return false;
|
77
|
}
|
78
|
}
|
79
|
|
80
|
@Override
|
81
|
public void addPages() {
|
82
|
addPage(aPage);
|
83
|
}
|
84
|
|
85
|
private boolean checkNoneChecked() {
|
86
|
|
87
|
if (aPage.getViewer().getCheckedElements().length == 0) {
|
88
|
aPage.setMessage(Messages.AvailableDistributionWizard_CHECK_MESSAGE, aPage.WARNING);
|
89
|
return true;
|
90
|
} else {
|
91
|
aPage.setMessage(null);
|
92
|
return false;
|
93
|
}
|
94
|
}
|
95
|
//
|
96
|
// @Override
|
97
|
// public ConversationHolder getConversationHolder() {
|
98
|
// if (conversation == null) {
|
99
|
// conversation = CdmStore.createConversation();
|
100
|
// }
|
101
|
// return conversation;
|
102
|
// }
|
103
|
//
|
104
|
// @Override
|
105
|
// public void update(CdmDataChangeMap changeEvents) {
|
106
|
// }
|
107
|
}
|
108
|
|