2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.ui
.dialog
;
11 import java
.util
.ArrayList
;
12 import java
.util
.Arrays
;
13 import java
.util
.List
;
14 import java
.util
.UUID
;
16 import org
.apache
.commons
.collections4
.CollectionUtils
;
17 import org
.eclipse
.jface
.wizard
.Wizard
;
19 import eu
.etaxonomy
.cdm
.api
.service
.description
.DistributionAggregationConfiguration
;
20 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaLevel
;
21 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermDto
;
22 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermVocabularyDto
;
23 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
24 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.configurator
.wizard
.SuperAreaPage
;
30 public class SuperAreaSelectionWizard
extends Wizard
{
32 private final SuperAreaPage aPage
;
33 DistributionAggregationConfiguration configurator
;
35 public SuperAreaSelectionWizard(DistributionAggregationConfiguration configurator
, NamedAreaLevel level
) {
36 setWindowTitle(Messages
.AvailableDistributionWizard_WINDOW_TITLE
);
37 // TODO if preferenceStore has elements checked load elements in wizard
38 aPage
= new SuperAreaPage(Messages
.AvailableDistributionWizard_PAGE_TITLE
, level
);
39 this.configurator
= configurator
;
43 public boolean performFinish() {
44 // TODO: get Selection and save in EditorPreferences
45 if (!checkNoneChecked()) {
46 Object
[] checkedElements
= aPage
.getViewer().getCheckedElements();
47 Object
[] grayedElements
= aPage
.getViewer().getGrayedElements();
48 List
<Object
> checkedList
= new ArrayList
<>(Arrays
.asList(checkedElements
));
49 List
<Object
> grayedList
= new ArrayList
<>(Arrays
.asList(grayedElements
));
50 checkedList
= (ArrayList
) CollectionUtils
.subtract(checkedList
, grayedList
);
51 ArrayList
<UUID
> listUIIDChecked
= new ArrayList
<>();
52 ArrayList
<UUID
> listUIIDGrayed
= new ArrayList
<>();
53 for (Object o
: checkedList
) {
54 if (o
instanceof TermDto
) {
55 listUIIDChecked
.add(((TermDto
) o
).getUuid());
57 }else if(o
instanceof TermVocabularyDto
){
58 TermVocabularyDto termVocDto
= (TermVocabularyDto
) o
;
59 listUIIDGrayed
.add(termVocDto
.getUuid());
62 // for (Object o : grayedList) {
63 // if (o instanceof TermDto) {
64 // listUIIDChecked.add(((TermDto) o).getUuid());
66 // }else if(o instanceof TermVocabularyDto){
67 // TermVocabularyDto termVocDto = (TermVocabularyDto) o;
68 // listUIIDGrayed.add(termVocDto.getUuid());
72 configurator
.setSuperAreas(listUIIDChecked
);
82 public void addPages() {
86 private boolean checkNoneChecked() {
88 if (aPage
.getViewer().getCheckedElements().length
== 0) {
89 aPage
.setMessage(Messages
.AvailableDistributionWizard_CHECK_MESSAGE
, aPage
.WARNING
);
92 aPage
.setMessage(null);