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
.UUID
;
15 import org
.apache
.commons
.collections
.CollectionUtils
;
16 import org
.eclipse
.jface
.wizard
.Wizard
;
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
;
29 public class SuperAreaSelectionWizard
extends Wizard
{
31 private final SuperAreaPage aPage
;
32 DistributionAggregationConfiguration configurator
;
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
;
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());
56 }else if(o
instanceof TermVocabularyDto
){
57 TermVocabularyDto termVocDto
= (TermVocabularyDto
) o
;
58 listUIIDGrayed
.add(termVocDto
.getUuid());
61 // for (Object o : grayedList) {
62 // if (o instanceof TermDto) {
63 // listUIIDChecked.add(((TermDto) o).getUuid());
65 // }else if(o instanceof TermVocabularyDto){
66 // TermVocabularyDto termVocDto = (TermVocabularyDto) o;
67 // listUIIDGrayed.add(termVocDto.getUuid());
71 configurator
.setSuperAreas(listUIIDChecked
);
81 public void addPages() {
85 private boolean checkNoneChecked() {
87 if (aPage
.getViewer().getCheckedElements().length
== 0) {
88 aPage
.setMessage(Messages
.AvailableDistributionWizard_CHECK_MESSAGE
, aPage
.WARNING
);
91 aPage
.setMessage(null);
97 // public ConversationHolder getConversationHolder() {
98 // if (conversation == null) {
99 // conversation = CdmStore.createConversation();
101 // return conversation;
105 // public void update(CdmDataChangeMap changeEvents) {