Project

General

Profile

« Previous | Next » 

Revision d29f2403

Added by Katja Luther over 4 years ago

aggregation configuration wizard page super class

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
698 698
    public static String FactualData_showModifier_FreeText;
699 699
    public static String FactualData_description;
700 700

  
701

  
702
    public static String DistributionAggregationConfiguration_aggregateToHigherRanks;
703
    public static String DistributionAggregationConfiguration_aggregateToHigherRanks_tooltip;
704
    public static String DistributionAggregationConfiguration_ClearExistingDistributions;
705
    public static String DistributionAggregationConfiguration_AggregationMode;
706
    public static String DistributionAggregationConfiguration_SuperArea;
707
    public static String DistributionAggregationConfiguration_StatusOrder;
708

  
701
    public static String DistributionAggregationWizardPage_AGGREGATION_MODE;
702
    public static String DistributionAggregationWizardPage_AREA;
703
    public static String DistributionAggregationWizardPage_AREA_LEVEL;
704
    public static String DistributionAggregationWizardPage_CHILD_PARENT;
705
    public static String DistributionAggregationWizardPage_CLASSIFICATION;
706
    public static String DistributionAggregationWizardPage_DEFAULT;
707
    public static String DistributionAggregationWizardPage_DESCRIPTION;
708
    public static String DistributionAggregationWizardPage_EXPORT_UNPUBLISHED;
709
    public static String DistributionAggregationWizardPage_HIGHEST_RANK;
710
    public static String DistributionAggregationWizardPage_LOWEST_RANK;
711
    public static String DistributionAggregationWizardPage_SELECT_AREA;
712
    public static String DistributionAggregationWizardPage_SOURCE_MODE_AREA;
713
    public static String DistributionAggregationWizardPage_SOURCE_TYPE;
714
    public static String DistributionAggregationWizardPage_SOURCEMODE_CHILD_PARENT;
715
    public static String DistributionAggregationWizardPage_SOURCEMODE_WITHIN_TAXON;
716
    public static String DistributionAggregationWizardPage_STATUS_ORDER;
717
    public static String DistributionAggregationWizardPage_TITLE;
718
    public static String DistributionAggregationWizardPage_TOOLTIP_AGGR_MODE;
719
    public static String DistributionAggregationWizardPage_TOOLTIP_AREA_LEVEL;
720
    public static String DistributionAggregationWizardPage_TOOLTIP_AREA_SELECTION;
721
    public static String DistributionAggregationWizardPage_TOOLTIP_SOURCE_TYPE;
722
    public static String DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_AREA;
723
    public static String DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_CHILD_PARENT;
724
    public static String DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_WITHIN_TAXON;
725
    public static String AggregationWizardPage_SUBTREE;
726
    public static String AggregationWizardPage_SINGLE_TAXON;
709 727
    public static String SetAggregationConfiguration_Title;
710 728

  
711 729

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
531 531
FactualData_showModifier_FreeText=Show modifier freetext
532 532
FactualData_description=If a preference is not selectable, there is a serverside preference not allowed to override.
533 533

  
534
DistributionAggregationConfiguration_aggregateToHigherRanks=Aggregate to higher ranks
535
DistributionAggregationConfiguration_aggregateToHigherRanks_tooltip=Aggregate to higher ranks
536
DistributionAggregationConfiguration_ClearExistingDistributions=Clear existing distributions
537
DistributionAggregationConfiguration_AggregationMode=Aggregation mode
538
DistributionAggregationConfiguration_SuperArea=Choose super areas
539
DistributionAggregationConfiguration_StatusOrder=Choose status order
540

  
534
DistributionAggregationWizardPage_AGGREGATION_MODE=Aggregation mode
535
DistributionAggregationWizardPage_AREA=From sub area to super area
536
DistributionAggregationWizardPage_AREA_LEVEL=Area Level
537
DistributionAggregationWizardPage_CHILD_PARENT=From child to parent taxon
538
DistributionAggregationWizardPage_CLASSIFICATION=Aggregate selected classification
539
DistributionAggregationWizardPage_DEFAULT=Default - by Presence Absence Term vocabulary
540
DistributionAggregationWizardPage_DESCRIPTION=Configure the aggregation
541
DistributionAggregationWizardPage_EXPORT_UNPUBLISHED=Export unpublished taxa
542
DistributionAggregationWizardPage_HIGHEST_RANK=Highest rank
543
DistributionAggregationWizardPage_LOWEST_RANK=Lowest rank
544
DistributionAggregationWizardPage_SELECT_AREA=Select Super Areas
545
DistributionAggregationWizardPage_SOURCE_MODE_AREA=Source mode sub area/super area
546
DistributionAggregationWizardPage_SOURCE_TYPE=Source type
547
DistributionAggregationWizardPage_SOURCEMODE_CHILD_PARENT=Source mode child/parent
548
DistributionAggregationWizardPage_SOURCEMODE_WITHIN_TAXON=Source mode within taxon
549
DistributionAggregationWizardPage_STATUS_ORDER=Status order
550
DistributionAggregationWizardPage_TITLE=Distribution aggregation configuration
551
DistributionAggregationWizardPage_TOOLTIP_AGGR_MODE=Selecting none deletes all existing aggregated distributions
552
DistributionAggregationWizardPage_TOOLTIP_AREA_LEVEL=Selecting the area level to which the distribution should be aggregated
553
DistributionAggregationWizardPage_TOOLTIP_AREA_SELECTION=If area aggregation is selected, the super areas can be selected. If none are selected the top level areas are used.
554
DistributionAggregationWizardPage_TOOLTIP_SOURCE_TYPE=Type of sources that should be aggregated
555
DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_AREA=Defines the source mode if aggregation from sub area to super area is selected.
556
DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_CHILD_PARENT=Defines the source mode if aggregation from child to parent taxon is selected.
557
DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_WITHIN_TAXON=Defines the source mode if aggragation within taxon is selected.
558
AggregationWizardPage_SUBTREE=Aggregation for selected subtree(s) 
559
AggregationWizardPage_SINGLE_TAXON=Aggregation only for
541 560
SetAggregationConfiguration_Title=Aggregation configuration;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
531 531
FactualData_showModifier_FreeText=Zeige Freitext-Modifier
532 532
FactualData_description=Wenn die Pr?ferenz nicht ausgew?hlt werden kann, dann gibt es eine serverseitige Pr?ferenz, die das ?berschreiben nicht erlaubt.
533 533

  
534
DistributionAggregationConfiguration_aggregateToHigherRanks=Aggregiere zu h?heren R?ngen
535
DistributionAggregationConfiguration_aggregateToHigherRanks_tooltip=Aggregiere zu h?heren R?ngen
536
DistributionAggregationConfiguration_ClearExistingDistributions=L?sche existierende Verbreitungen
537
DistributionAggregationConfiguration_AggregationMode=Aggregationsmodus
538
DistributionAggregationConfiguration_SuperArea=W?hle Super Areale
539
DistributionAggregationConfiguration_StatusOrder=W?hle die Status Sortierung
540

  
541
SetAggregationConfiguration_Title=Aggregations Konfiguration;
534
DistributionAggregationWizardPage_AGGREGATION_MODE=Aggregation mode
535
DistributionAggregationWizardPage_AREA=From sub area to super area
536
DistributionAggregationWizardPage_AREA_LEVEL=Area Level
537
DistributionAggregationWizardPage_CHILD_PARENT=From child to parent taxon
538
DistributionAggregationWizardPage_CLASSIFICATION=Aggregate selected classification
539
DistributionAggregationWizardPage_DEFAULT=Default - by Presence Absence Term vocabulary
540
DistributionAggregationWizardPage_DESCRIPTION=Configure the aggregation
541
DistributionAggregationWizardPage_EXPORT_UNPUBLISHED=Export unpublished taxa
542
DistributionAggregationWizardPage_HIGHEST_RANK=Highest rank
543
DistributionAggregationWizardPage_LOWEST_RANK=Lowest rank
544
DistributionAggregationWizardPage_SELECT_AREA=Select Super Areas
545
DistributionAggregationWizardPage_SOURCE_MODE_AREA=Source mode sub area/super area
546
DistributionAggregationWizardPage_SOURCE_TYPE=Source type
547
DistributionAggregationWizardPage_SOURCEMODE_CHILD_PARENT=Source mode child/parent
548
DistributionAggregationWizardPage_SOURCEMODE_WITHIN_TAXON=Source mode within taxon
549
DistributionAggregationWizardPage_STATUS_ORDER=Status order
550
DistributionAggregationWizardPage_TITLE=Distribution aggregation configuration
551
DistributionAggregationWizardPage_TOOLTIP_AGGR_MODE=Selecting none deletes all existing aggregated distributions
552
DistributionAggregationWizardPage_TOOLTIP_AREA_LEVEL=Selecting the area level to which the distribution should be aggregated
553
DistributionAggregationWizardPage_TOOLTIP_AREA_SELECTION=If area aggregation is selected, the super areas can be selected. If none are selected the top level areas are used.
554
DistributionAggregationWizardPage_TOOLTIP_SOURCE_TYPE=Type of sources that should be aggregated
555
DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_AREA=Defines the source mode if aggregation from sub area to super area is selected.
556
DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_CHILD_PARENT=Defines the source mode if aggregation from child to parent taxon is selected.
557
DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_WITHIN_TAXON=Defines the source mode if aggragation within taxon is selected.
558
AggregationWizardPage_SUBTREE=Aggregation for selected subtree(s) 
559
AggregationWizardPage_SINGLE_TAXON=Aggregation only for 
560
SetAggregationConfiguration_Title=Aggregationskonfiguration
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/AggregationConfigurationWizardPage.java
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.Comparator;
13
import java.util.EnumSet;
14
import java.util.HashMap;
15
import java.util.List;
16
import java.util.Map;
17

  
18
import org.apache.commons.lang.StringUtils;
19
import org.eclipse.jface.viewers.CheckboxTableViewer;
20
import org.eclipse.jface.wizard.WizardPage;
21
import org.eclipse.swt.widgets.Button;
22
import org.eclipse.swt.widgets.Combo;
23

  
24
import eu.etaxonomy.cdm.api.service.description.AggregationMode;
25
import eu.etaxonomy.cdm.api.service.description.AggregationSourceMode;
26
import eu.etaxonomy.cdm.api.service.description.DescriptionAggregationBase;
27
import eu.etaxonomy.cdm.api.service.description.DescriptionAggregationConfigurationBase;
28
import eu.etaxonomy.cdm.model.name.Rank;
29
import eu.etaxonomy.cdm.model.name.TaxonName;
30
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
31
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
32
import eu.etaxonomy.taxeditor.store.CdmStore;
33

  
34
/**
35
 * @author k.luther
36
 * @since 13.12.2019
37
 */
38
public abstract class AggregationConfigurationWizardPage<T extends DescriptionAggregationBase> extends WizardPage {
39

  
40
    protected DescriptionAggregationConfigurationBase<T> configurator;
41

  
42
    protected Button checkUseSelectedTaxonNode;
43
    protected Button checkUseHigherLevel;
44
    protected Button checkUseSelectedSubtree;
45

  
46

  
47
    protected Combo comboHigherRank;
48
    protected Combo comboLowerRank;
49

  
50
    protected Combo comboSourceModeChildParent;
51
    protected Combo comboSourceModeWithinTaxon;
52

  
53
    protected CheckboxTableViewer aggregationModeViewer;
54
    protected TaxonNode subTreeNode;
55

  
56
    protected CheckboxTableViewer sourceTypeViewer;
57
    Map<String, OriginalSourceType> typeMap = new HashMap();
58

  
59

  
60
    Comparator comparator = new Comparator<Rank>(){
61

  
62
        @Override
63
        public int compare(Rank o1, Rank o2) {
64
            return o2.compareTo(o1);
65
        }
66

  
67
    };
68

  
69
    /**
70
     * @param pageName
71
     */
72
    protected AggregationConfigurationWizardPage(String pageName) {
73
        super(pageName);
74
        // TODO Auto-generated constructor stub
75
    }
76

  
77

  
78

  
79
    protected void updateHigherRankCombo() {
80
        comboHigherRank.removeAll();
81
        List<Rank> rankList = new ArrayList<>();
82
        TaxonName name = null;
83
        if (subTreeNode != null){
84
            if (subTreeNode.getTaxon() != null){
85
                name = subTreeNode.getTaxon().getName();
86
            }
87
        }
88
        comboHigherRank.add(""); //$NON-NLS-1$
89
        if (name != null){
90
            for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
91
                if (useClassification() || (name != null && name.getRank().isHigher(rank) || name.getRank().equals(rank))){
92
                    rankList.add(rank);
93
                }
94
            }
95
        }else{
96
            for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
97
                rankList.add(rank);
98
            }
99
        }
100

  
101
        rankList.sort(comparator);
102
        for (Rank rank: rankList){
103
            comboHigherRank.add(rank.getLabel());
104
            comboHigherRank.setData(rank.getLabel(), rank);
105
        }
106

  
107

  
108
    }
109

  
110

  
111
   protected void updateLowerRankCombo() {
112
       comboLowerRank.removeAll();
113
       TaxonName name = null;
114
       List<Rank> rankList = new ArrayList<>();
115
       if (subTreeNode != null){
116
           if (subTreeNode.getTaxon() != null){
117
               name = subTreeNode.getTaxon().getName();
118
           }
119
       }
120
       comboLowerRank.add(""); //$NON-NLS-1$
121
       Rank higherRank = null;
122
       if (comboHigherRank.getText() != null && comboHigherRank.getData(comboHigherRank.getText()) != null){
123
           higherRank = (Rank)comboHigherRank.getData(comboHigherRank.getText());
124
       }
125
       for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
126
           if (higherRank != null){
127
               if (higherRank.isHigher(rank) || higherRank.equals(rank)){
128
                   rankList.add(rank);
129
               }
130
           } else if (name == null || (name.getRank().isHigher(rank) || name.getRank().equals(rank))) {
131
               rankList.add(rank);
132
           }
133
       }
134
       rankList.sort(comparator);
135
       for (Rank rank: rankList){
136
           comboLowerRank.add(rank.getLabel());
137
           comboLowerRank.setData(rank.getLabel(), rank);
138
       }
139

  
140
   }
141

  
142
   public Rank getHigherRank(){
143
       if (StringUtils.isNotBlank(comboHigherRank.getText())){
144
           return (Rank)comboHigherRank.getData(comboHigherRank.getText());
145
       }
146
       return null;
147
   }
148

  
149
   public Rank getLowerRank(){
150
       if (StringUtils.isNotBlank(comboLowerRank.getText())){
151
           return (Rank)comboLowerRank.getData(comboLowerRank.getText());
152
       }
153
       return null;
154
   }
155

  
156
   public boolean useClassification(){
157
       return checkUseHigherLevel.getSelection();
158
   }
159

  
160
   public boolean useSubtree(){
161
       return checkUseSelectedSubtree.getSelection();
162
   }
163

  
164
   public boolean useTaxonNode(){
165
       return checkUseSelectedTaxonNode.getSelection();
166
   }
167

  
168
   public AggregationSourceMode getSourceModeChildParent(){
169
       if (StringUtils.isNotBlank(comboSourceModeChildParent.getText())){
170
           return (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
171
       }
172
       return null;
173
   }
174

  
175
   public AggregationSourceMode getSourceModeWithinTaxon(){
176
       if (StringUtils.isNotBlank(comboSourceModeWithinTaxon.getText())){
177
           return (AggregationSourceMode)comboSourceModeWithinTaxon.getData(comboSourceModeWithinTaxon.getText());
178

  
179
       }
180
       return null;
181
   }
182

  
183
   public EnumSet<OriginalSourceType> getSourceTypes(){
184
       List<OriginalSourceType> list = new ArrayList<>();
185
       for (Object o: sourceTypeViewer.getCheckedElements()){
186
           String string = null;
187
           if (o instanceof String){
188
               string = (String)o;
189
           }
190
           if (string != null){
191
               list.add(typeMap.get(string));
192
           }
193
       }
194

  
195
       return EnumSet.copyOf(list);
196
   }
197

  
198

  
199
   public List<AggregationMode> getAggregationMode(){
200

  
201
       List<AggregationMode> result = new ArrayList<>();
202
       for (Object o: aggregationModeViewer.getCheckedElements()){
203
           if (o instanceof AggregationMode){
204
               result.add((AggregationMode)o);
205
           }
206
       }
207
       return result;
208
   }
209

  
210
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/DistributionAggregationConfiguratorWizard.java
57 57
        configurator.getTaxonNodeFilter().setRankMin(page.getLowerRank());
58 58
        configurator.setAggregationMode(page.getAggregationMode());
59 59
        configurator.setToParentSourceMode(page.getSourceModeChildParent());
60
        configurator.setWithinTaxonSourceMode(page.getSourceModeSuperAreaSubArea());
60
        configurator.setWithinTaxonSourceMode(page.getSourceModeWithinTaxon());
61 61

  
62 62
        UUID uuid = longRunningTaskService.invoke(configurator);
63 63

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/DistributionAggregationWizardPage.java
12 12
import java.util.Arrays;
13 13
import java.util.Collections;
14 14
import java.util.Comparator;
15
import java.util.EnumSet;
16
import java.util.HashMap;
17 15
import java.util.List;
18
import java.util.Map;
19 16

  
20 17
import org.apache.commons.lang.StringUtils;
21 18
import org.eclipse.jface.layout.GridLayoutFactory;
......
25 22
import org.eclipse.jface.viewers.ICheckStateListener;
26 23
import org.eclipse.jface.viewers.LabelProvider;
27 24
import org.eclipse.jface.wizard.WizardDialog;
28
import org.eclipse.jface.wizard.WizardPage;
29 25
import org.eclipse.swt.SWT;
30 26
import org.eclipse.swt.events.SelectionAdapter;
31 27
import org.eclipse.swt.events.SelectionEvent;
......
44 40
import eu.etaxonomy.cdm.api.service.ITermTreeService;
45 41
import eu.etaxonomy.cdm.api.service.description.AggregationMode;
46 42
import eu.etaxonomy.cdm.api.service.description.AggregationSourceMode;
43
import eu.etaxonomy.cdm.api.service.description.DistributionAggregation;
47 44
import eu.etaxonomy.cdm.api.service.description.DistributionAggregationConfiguration;
48 45
import eu.etaxonomy.cdm.filter.LogicFilter;
49 46
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
50
import eu.etaxonomy.cdm.model.name.Rank;
51
import eu.etaxonomy.cdm.model.name.TaxonName;
52 47
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
53 48
import eu.etaxonomy.cdm.model.taxon.Classification;
54 49
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
......
64 59
 * @author k.luther
65 60
 * @since 15.11.2019
66 61
 */
67
public class DistributionAggregationWizardPage extends WizardPage implements Listener, SelectionListener{
62
public class DistributionAggregationWizardPage extends AggregationConfigurationWizardPage<DistributionAggregation> implements Listener, SelectionListener{
68 63

  
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 64
    private Button buttonSuperArea;
81 65
    private Combo comboAreaLevel;
82 66
    private Combo comboStatusOrder;
83 67

  
84

  
85 68
    private Combo comboClassificationSelection;
86 69
    private List<Classification> classifications;
87 70
    private Classification selectedClassification;
88 71

  
72
    private Button checkExportUnpublished;
89 73

  
90 74

  
91
    private Button checkUseSelectedTaxonNode;
92
    private Button checkUseSelectedClassification;
93
    private Button checkUseSelectedSubtree;
94

  
95 75

  
96
    private Button checkExportUnpublished;
97

  
98
    private TaxonNode subTreeNode;
99
    private CheckboxTableViewer sourceTypeViewer;
100 76
    Object[] checkedElements;
101
    Map<String, OriginalSourceType> typeMap = new HashMap();
102

  
103
    Comparator comparator = new Comparator<Rank>(){
104 77

  
105
        @Override
106
        public int compare(Rank o1, Rank o2) {
107
            return o2.compareTo(o1);
108
        }
109 78

  
110
    };
111 79

  
112 80

  
113 81
    /**
114 82
     * @param pageName
115 83
     */
116 84
    public DistributionAggregationWizardPage(DistributionAggregationConfiguration configurator) {
117
        super("Distribution aggregation configuration");
85
        super(Messages.DistributionAggregationWizardPage_TITLE);
118 86
        this.configurator = configurator;
119 87

  
120
        this.setDescription("Configure the aggregation");
88
        this.setDescription(Messages.DistributionAggregationWizardPage_DESCRIPTION);
121 89

  
122 90
    }
123 91

  
......
126 94
    public void createControl(Composite parent) {
127 95
        final Composite composite = new Composite(parent, SWT.NULL);
128 96

  
129
        String taxonStr = "";
97
        String taxonStr = ""; //$NON-NLS-1$
130 98
        int count = configurator.getTaxonNodeFilter().getSubtreeFilter().size();
131 99

  
132 100
        for (LogicFilter<TaxonNode> filter: configurator.getTaxonNodeFilter().getSubtreeFilter()){
......
135 103
            if (subTreeNode.hasTaxon()){
136 104
                taxonStr += subTreeNode.getTaxon().getName().getTitleCache();
137 105
                if (count>0){
138
                    taxonStr += ", ";
106
                    taxonStr += ", "; //$NON-NLS-1$
139 107
                }
140 108
            }
141 109
        }
142 110
        if (StringUtils.isNotBlank(taxonStr)){
143 111
            checkUseSelectedSubtree= new Button(composite,  SWT.RADIO);
144
            checkUseSelectedSubtree.setText("Aggregation for selected subtree(s) "+  taxonStr);
112
            checkUseSelectedSubtree.setText(Messages.AggregationWizardPage_SUBTREE+  taxonStr);
145 113
            checkUseSelectedSubtree.addListener(SWT.Selection, new Listener() {
146 114
                @Override
147 115
                public void handleEvent(Event e) {
......
155 123
            });
156 124

  
157 125
            checkUseSelectedTaxonNode= new Button(composite,  SWT.RADIO);
158
            checkUseSelectedTaxonNode.setText("Aggregation only for "+  taxonStr);
126
            checkUseSelectedTaxonNode.setText(Messages.AggregationWizardPage_SINGLE_TAXON+  taxonStr);
159 127
            checkUseSelectedTaxonNode.addListener(SWT.Selection, new Listener() {
160 128
                @Override
161 129
                public void handleEvent(Event e) {
......
169 137

  
170 138
            });
171 139
        }
172
        checkUseSelectedClassification= new Button(composite,  SWT.RADIO);
173
        checkUseSelectedClassification.setText("Aggregate selected classification");
174
        checkUseSelectedClassification.addListener(SWT.Selection, new Listener() {
140
        checkUseHigherLevel= new Button(composite,  SWT.RADIO);
141
        checkUseHigherLevel.setText(Messages.DistributionAggregationWizardPage_CLASSIFICATION);
142
        checkUseHigherLevel.addListener(SWT.Selection, new Listener() {
175 143
           @Override
176 144
           public void handleEvent(Event e) {
177 145
               Button b = (Button) e.widget;
......
220 188
            checkUseSelectedSubtree.setSelection(true);
221 189
            comboClassificationSelection.setEnabled(false);
222 190
        }else{
223
            checkUseSelectedClassification.setSelection(true);
191
            checkUseHigherLevel.setSelection(true);
224 192
        }
225 193
        Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
226 194
        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
......
239 207
        control.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
240 208

  
241 209
        Label higherRankLabel = new Label(control, SWT.NULL);
242
        higherRankLabel.setText("Highest rank");
210
        higherRankLabel.setText(Messages.DistributionAggregationWizardPage_HIGHEST_RANK);
243 211

  
244 212
        comboHigherRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
245 213
        updateHigherRankCombo();
......
247 215

  
248 216

  
249 217
        Label lowerRankLabel = new Label(control, SWT.NULL);
250
        lowerRankLabel.setText("Lowest rank");
218
        lowerRankLabel.setText(Messages.DistributionAggregationWizardPage_LOWEST_RANK);
251 219
        comboLowerRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
252 220
        updateLowerRankCombo();
253 221
        comboLowerRank.addListener(SWT.Selection, this);
......
259 227
        separator.setLayoutData(gridData);
260 228

  
261 229
        Label aggregationModeLabel = new Label(control, SWT.NULL);
262
        aggregationModeLabel.setText("Aggregation mode");
263
        aggregationModeLabel.setToolTipText("Selecting none deletes all existing aggregated distributions");
230
        aggregationModeLabel.setText(Messages.DistributionAggregationWizardPage_AGGREGATION_MODE);
231
        aggregationModeLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_AGGR_MODE);
264 232
        aggregationModeViewer =  CheckboxTableViewer.newCheckList(control, SWT.BORDER | SWT.SINGLE);
265 233
        aggregationModeViewer.setContentProvider(new ArrayContentProvider());
266 234
        aggregationModeViewer.setLabelProvider(new LabelProvider(){
......
268 236
            public String getText(Object element){
269 237
                if (element instanceof AggregationMode){
270 238
                    if (((AggregationMode)element).equals(AggregationMode.ToParent)){
271
                        return "From child to parent taxon";
239
                        return Messages.DistributionAggregationWizardPage_CHILD_PARENT;
272 240
                    }
273 241
                    if (((AggregationMode)element).equals(AggregationMode.WithinTaxon)){
274
                        return "From sub area to super area";
242
                        return Messages.DistributionAggregationWizardPage_AREA;
275 243
                    }
276 244
                }
277 245
                return null;
......
303 271
                }
304 272
                comboAreaLevel.setEnabled(areachecked);
305 273
                buttonSuperArea.setEnabled(areachecked);
306
                comboSourceModeSubAreaSuperArea.setEnabled(areachecked);
274
                comboSourceModeWithinTaxon.setEnabled(areachecked);
307 275
                comboSourceModeChildParent.setEnabled(toParentChecked);
308
                AggregationSourceMode areaMode = (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
276
                AggregationSourceMode areaMode = (AggregationSourceMode)comboSourceModeWithinTaxon.getData(comboSourceModeWithinTaxon.getText());
309 277
                AggregationSourceMode taxonMode = (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
310 278
                sourceTypeViewer.getTable().setEnabled(((areachecked && (areaMode.equals(AggregationSourceMode.ALL) || areaMode.equals(AggregationSourceMode.ALL_SAMEVALUE) ) )|| toParentChecked && (taxonMode.equals(AggregationSourceMode.ALL) || taxonMode.equals(AggregationSourceMode.ALL_SAMEVALUE) )) );
311 279
                getWizard().getContainer().updateButtons();
312 280
              }
313 281
        });
314 282
        Label areaLevelLabel = new Label(control, SWT.NULL);
315
        areaLevelLabel.setText("Area Level");
316
        areaLevelLabel.setToolTipText("Selecting the area level to which the distribution should be aggregated");
283
        areaLevelLabel.setText(Messages.DistributionAggregationWizardPage_AREA_LEVEL);
284
        areaLevelLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_AREA_LEVEL);
317 285
        comboAreaLevel = new Combo(control,  SWT.BORDER | SWT.READ_ONLY);
318 286
        List<NamedAreaLevel> namedAreaLevels = CdmStore.getTermManager().getAllTerms(TermType.NamedAreaLevel, null);
319 287
        for (NamedAreaLevel level: namedAreaLevels) {
......
329 297
        buttonSuperArea = new Button(control, SWT.PUSH );
330 298
        buttonSuperArea.setLayoutData(gridData2);
331 299
        buttonSuperArea.setEnabled(false);
332
        buttonSuperArea.setText("Select Super Areas");
333
        buttonSuperArea.setToolTipText("If area aggregation is selected, the super areas can be selected. If none are selected the top level areas are used.");
300
        buttonSuperArea.setText(Messages.DistributionAggregationWizardPage_SELECT_AREA);
301
        buttonSuperArea.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_AREA_SELECTION);
334 302
        buttonSuperArea.addSelectionListener(new SelectionAdapter() {
335 303
            @Override
336 304
            public void widgetSelected(SelectionEvent event) {
337
                SuperAreaSelectionWizard availableDistributionWizard = new SuperAreaSelectionWizard(configurator, (NamedAreaLevel)comboAreaLevel.getData(comboAreaLevel.getText()));
305
                SuperAreaSelectionWizard availableDistributionWizard = new SuperAreaSelectionWizard((DistributionAggregationConfiguration) configurator, (NamedAreaLevel)comboAreaLevel.getData(comboAreaLevel.getText()));
338 306
                WizardDialog dialog = new WizardDialog(StoreUtil.getShell(),
339 307
                        availableDistributionWizard);
340 308
                int open = dialog.open();
......
346 314

  
347 315
        Label sourceModeLabel = new Label(control, SWT.NULL);
348 316

  
349
        sourceModeLabel.setText("Source mode child/parent");
350
        sourceModeLabel.setToolTipText("Defines the source mode if aggregation from child to parent taxon is selected.");
317
        sourceModeLabel.setText(Messages.DistributionAggregationWizardPage_SOURCEMODE_CHILD_PARENT);
318
        sourceModeLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_CHILD_PARENT);
351 319
        comboSourceModeChildParent = new Combo(control,  SWT.BORDER| SWT.READ_ONLY);
352
        comboSourceModeChildParent.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
320
        comboSourceModeChildParent.setText(Messages.DistributionAggregationWizardPage_AGGREGATION_MODE);
353 321

  
354 322
        for (AggregationSourceMode mode :AggregationSourceMode.values()){
355 323
            comboSourceModeChildParent.add(mode.getMessage());
......
362 330
        comboSourceModeChildParent.select(0);
363 331

  
364 332
        Label sourceModeLabelSuperArea = new Label(control, SWT.NULL);
365
        sourceModeLabelSuperArea.setText("Source mode sub area/super area");
366
        sourceModeLabelSuperArea.setToolTipText("Defines the source mode if aggregation from sub area to super area is selected.");
367
        comboSourceModeSubAreaSuperArea = new Combo(control,  SWT.BORDER| SWT.READ_ONLY);
368
        comboSourceModeSubAreaSuperArea.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
333
        sourceModeLabelSuperArea.setText(Messages.DistributionAggregationWizardPage_SOURCE_MODE_AREA);
334
        sourceModeLabelSuperArea.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_AREA);
335
        comboSourceModeWithinTaxon = new Combo(control,  SWT.BORDER| SWT.READ_ONLY);
336
        comboSourceModeWithinTaxon.setText(Messages.DistributionAggregationWizardPage_AGGREGATION_MODE);
369 337

  
370 338
        for (AggregationSourceMode mode :AggregationSourceMode.values()){
371
            comboSourceModeSubAreaSuperArea.add(mode.getMessage());
372
            comboSourceModeSubAreaSuperArea.setData(mode.getMessage(), mode);
339
            comboSourceModeWithinTaxon.add(mode.getMessage());
340
            comboSourceModeWithinTaxon.setData(mode.getMessage(), mode);
373 341
        }
374 342

  
375
        comboSourceModeSubAreaSuperArea.addSelectionListener(this);
376
        comboSourceModeSubAreaSuperArea.setEnabled(false);
377
        comboSourceModeSubAreaSuperArea.select(0);
343
        comboSourceModeWithinTaxon.addSelectionListener(this);
344
        comboSourceModeWithinTaxon.setEnabled(false);
345
        comboSourceModeWithinTaxon.select(0);
378 346

  
379 347
        Label sourceTypeLabel = new Label(control, SWT.NULL);
380
        sourceTypeLabel.setText("Source type");
381
        sourceTypeLabel.setToolTipText("Type of sources that should be aggregated");
348
        sourceTypeLabel.setText(Messages.DistributionAggregationWizardPage_SOURCE_TYPE);
349
        sourceTypeLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_SOURCE_TYPE);
382 350
        sourceTypeViewer = CheckboxTableViewer.newCheckList(control, SWT.BORDER | SWT.SINGLE);
383 351
        sourceTypeViewer.setContentProvider(new ArrayContentProvider());
384 352

  
......
407 375

  
408 376

  
409 377
        Label selectStatusLabel = new Label(control, SWT.NULL);
410
        selectStatusLabel.setText("Status order");
378
        selectStatusLabel.setText(Messages.DistributionAggregationWizardPage_STATUS_ORDER);
411 379
        comboStatusOrder = new Combo(control, SWT.PUSH );
412
        comboStatusOrder.add("Default - by Presence Absence Term vocabulary");
413
        comboStatusOrder.setData("Default - by Presence Absence Term vocabulary", null);
380
        comboStatusOrder.add(Messages.DistributionAggregationWizardPage_DEFAULT);
381
        comboStatusOrder.setData(Messages.DistributionAggregationWizardPage_DEFAULT, null);
414 382
        for (TermTree tree: CdmStore.getService(ITermTreeService.class).list(TermType.PresenceAbsenceTerm, null, 0, null,null)){
415 383
            comboStatusOrder.add(tree.getTitleCache());
416 384
            comboStatusOrder.setData(tree.getTitleCache(), tree);
......
420 388
        comboStatusOrder.select(0);
421 389

  
422 390
        checkExportUnpublished = new Button(composite,  SWT.CHECK);
423
        checkExportUnpublished.setText("Export unpublished taxa");
391
        checkExportUnpublished.setText(Messages.DistributionAggregationWizardPage_EXPORT_UNPUBLISHED);
424 392

  
425 393
        GridLayoutFactory.fillDefaults();
426 394

  
......
438 406
    @Override
439 407
    public void widgetSelected(SelectionEvent e) {
440 408

  
441
        if (e.getSource().equals(comboSourceModeChildParent) || e.getSource().equals(comboSourceModeSubAreaSuperArea)){
409
        if (e.getSource().equals(comboSourceModeChildParent) || e.getSource().equals(comboSourceModeWithinTaxon)){
442 410
            AggregationSourceMode modeChild = (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
443
            AggregationSourceMode modeArea = (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
444
            if ((comboSourceModeChildParent.isEnabled() && (modeChild != null && modeChild.equals(AggregationSourceMode.ALL) || modeChild.equals(AggregationSourceMode.ALL_SAMEVALUE))) ||(comboSourceModeSubAreaSuperArea.isEnabled() && (modeArea != null && modeArea.equals(AggregationSourceMode.ALL) || modeArea.equals(AggregationSourceMode.ALL_SAMEVALUE)))){
411
            AggregationSourceMode modeArea = (AggregationSourceMode)comboSourceModeWithinTaxon.getData(comboSourceModeWithinTaxon.getText());
412
            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)))){
445 413
                sourceTypeViewer.getTable().setEnabled(true);
446 414
            }else{
447 415
                sourceTypeViewer.getTable().setEnabled(false);
......
473 441
            updateHigherRankCombo();
474 442
            updateLowerRankCombo();
475 443
        }
476
        if (event.widget.equals(this.checkUseSelectedClassification)){
444
        if (event.widget.equals(this.checkUseHigherLevel)){
477 445
            updateHigherRankCombo();
478 446
            updateLowerRankCombo();
479 447
        }
......
488 456

  
489 457
    }
490 458

  
491
    private void updateHigherRankCombo() {
492
        comboHigherRank.removeAll();
493
        List<Rank> rankList = new ArrayList<>();
494
        TaxonName name = null;
495
        if (subTreeNode != null){
496
            if (subTreeNode.getTaxon() != null){
497
                name = subTreeNode.getTaxon().getName();
498
            }
499
        }
500
        comboHigherRank.add("");
501
        if (name != null){
502
            for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
503
                if (useClassification() || (name != null && name.getRank().isHigher(rank) || name.getRank().equals(rank))){
504
                    rankList.add(rank);
505
                }
506
            }
507
        }else{
508
            for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
509
                rankList.add(rank);
510
            }
511
        }
512

  
513
        rankList.sort(comparator);
514
        for (Rank rank: rankList){
515
            comboHigherRank.add(rank.getLabel());
516
            comboHigherRank.setData(rank.getLabel(), rank);
517
        }
518

  
519

  
520
    }
521

  
522

  
523
   private void updateLowerRankCombo() {
524
       comboLowerRank.removeAll();
525
       TaxonName name = null;
526
       List<Rank> rankList = new ArrayList<>();
527
       if (subTreeNode != null){
528
           if (subTreeNode.getTaxon() != null){
529
               name = subTreeNode.getTaxon().getName();
530
           }
531
       }
532
       comboLowerRank.add("");
533
       for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
534
           if (subTreeNode == null && (comboHigherRank.getText() == null || (comboHigherRank.getData(comboHigherRank.getText()) != null && (((Rank)comboHigherRank.getData(comboHigherRank.getText())).isHigher(rank) || ((Rank)comboHigherRank.getData(comboHigherRank.getText())).equals(rank))))){
535
               rankList.add(rank);
536
           }else if (name == null || (name.getRank().isHigher(rank) || name.getRank().equals(rank))) {
537
               if(StringUtils.isBlank(comboHigherRank.getText()) || comboHigherRank.getData(comboHigherRank.getText()) != null && (((Rank)comboHigherRank.getData(comboHigherRank.getText())).isHigher(rank) || ((Rank)comboHigherRank.getData(comboHigherRank.getText())).equals(rank))){
538
               // the rank is lower than higher rank and lower than the rank of the subtree name
539
                   rankList.add(rank);
540
               }
541
           }
542
       }
543
       rankList.sort(comparator);
544
       for (Rank rank: rankList){
545
           comboLowerRank.add(rank.getLabel());
546
           comboLowerRank.setData(rank.getLabel(), rank);
547
       }
548

  
549
   }
550

  
551
   public Rank getHigherRank(){
552
       if (StringUtils.isNotBlank(comboHigherRank.getText())){
553
           return (Rank)comboHigherRank.getData(comboHigherRank.getText());
554
       }
555
       return null;
556
   }
557 459

  
558
   public Rank getLowerRank(){
559
       if (StringUtils.isNotBlank(comboLowerRank.getText())){
560
           return (Rank)comboLowerRank.getData(comboLowerRank.getText());
561
       }
562
       return null;
563
   }
564

  
565

  
566
   public AggregationSourceMode getSourceModeChildParent(){
567
       if (StringUtils.isNotBlank(comboSourceModeChildParent.getText())){
568
           return (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
569
       }
570
       return null;
571
   }
572 460

  
573
   public AggregationSourceMode getSourceModeSuperAreaSubArea(){
574
       if (StringUtils.isNotBlank(comboSourceModeSubAreaSuperArea.getText())){
575
           return (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
576 461

  
577
       }
578
       return null;
579
   }
580 462

  
581 463
   public TermTree getStatusOrder(){
582 464
       if (StringUtils.isNotBlank(comboStatusOrder.getText())){
......
585 467
       return null;
586 468
   }
587 469

  
588
   public boolean useClassification(){
589
       return checkUseSelectedClassification.getSelection();
590
   }
591

  
592
   public boolean useSubtree(){
593
       return checkUseSelectedSubtree.getSelection();
594
   }
595 470

  
596
   public boolean useTaxonNode(){
597
       return checkUseSelectedTaxonNode.getSelection();
598
   }
599 471

  
600 472
   public boolean useUnpublishedData(){
601 473
       return checkExportUnpublished.getSelection();
602 474
   }
603 475

  
604
   public EnumSet<OriginalSourceType> getSourceTypes(){
605
       List<OriginalSourceType> list = new ArrayList<>();
606
       for (Object o: sourceTypeViewer.getCheckedElements()){
607
           String string = null;
608
           if (o instanceof String){
609
               string = (String)o;
610
           }
611
           if (string != null){
612
               list.add(typeMap.get(string));
613
           }
614
       }
615

  
616
       return EnumSet.copyOf(list);
617
   }
618 476

  
619
   public List<AggregationMode> getAggregationMode(){
620 477

  
621
       List<AggregationMode> result = new ArrayList<>();
622
       for (Object o: aggregationModeViewer.getCheckedElements()){
623
           if (o instanceof AggregationMode){
624
               result.add((AggregationMode)o);
625
           }
626
       }
627
       return result;
628
   }
629 478

  
630 479

  
631 480
    public Classification getSelectedClassification() {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/StructuredAggregationConfigurationWizard.java
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.UUID;
12

  
13
import org.eclipse.jface.wizard.Wizard;
14
import org.eclipse.swt.widgets.Display;
15

  
16
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
17
import eu.etaxonomy.cdm.api.service.description.StructuredDescriptionAggregationConfiguration;
18
import eu.etaxonomy.cdm.api.service.longrunningService.ILongRunningTasksService;
19
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
20
import eu.etaxonomy.taxeditor.l10n.Messages;
21
import eu.etaxonomy.taxeditor.model.AbstractUtility;
22
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
23

  
24
/**
25
 * @author k.luther
26
 * @since 11.12.2019
27
 */
28
public class StructuredAggregationConfigurationWizard extends Wizard implements IPostMoniteredOperationEnabled {
29

  
30
    private final StructuredDescriptionAggregationConfiguration configurator;
31
    private StructuredDescriptionAggregationConfigurationWizardPage page;
32
    private ILongRunningTasksService longRunningTaskService;
33

  
34
    public StructuredAggregationConfigurationWizard(StructuredDescriptionAggregationConfiguration config) {
35
        super();
36
        this.configurator = config;
37
        setNeedsProgressMonitor(true);
38
        this.setWindowTitle(Messages.SetAggregationConfiguration_Title);
39
        longRunningTaskService = CdmApplicationState.getLongRunningTasksService();
40
    }
41

  
42

  
43

  
44
    @Override
45
    public void postOperation(IRemotingProgressMonitor monitor) {
46
        // TODO Auto-generated method stub
47

  
48
    }
49

  
50
    @Override
51
    public boolean performFinish() {
52
        configurator.setAggregatingSourceTypes(page.getSourceTypes());
53
        configurator.setAggregationMode(page.getAggregationMode());
54
        configurator.setToParentSourceMode(page.getSourceModeChildParent());
55

  
56
        UUID uuid = longRunningTaskService.invoke(configurator);
57

  
58
        Display.getDefault().asyncExec(new Runnable() {
59
            @Override
60
            public void run() {
61
                AbstractUtility.executeMoniteredOperation("Aggregate Descriptions",
62
                        uuid,
63
                        1000,
64
                        false,
65
                        StructuredAggregationConfigurationWizard.this,
66
                        null,
67
                        true);
68

  
69
            }
70

  
71
        });
72

  
73
        return true;
74
    }
75

  
76
    @Override
77
    public void addPages() {
78
        page = new StructuredDescriptionAggregationConfigurationWizardPage(configurator);
79
        addPage(page);
80

  
81
    }
82
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/StructuredDescriptionAggregationConfigurationWizardPage.java
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.List;
13

  
14
import org.apache.commons.lang.StringUtils;
15
import org.eclipse.jface.viewers.ArrayContentProvider;
16
import org.eclipse.jface.viewers.CheckStateChangedEvent;
17
import org.eclipse.jface.viewers.CheckboxTableViewer;
18
import org.eclipse.jface.viewers.ICheckStateListener;
19
import org.eclipse.jface.viewers.LabelProvider;
20
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.layout.GridData;
22
import org.eclipse.swt.layout.GridLayout;
23
import org.eclipse.swt.widgets.Button;
24
import org.eclipse.swt.widgets.Combo;
25
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Event;
27
import org.eclipse.swt.widgets.Label;
28
import org.eclipse.swt.widgets.Listener;
29

  
30
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
31
import eu.etaxonomy.cdm.api.service.description.AggregationMode;
32
import eu.etaxonomy.cdm.api.service.description.AggregationSourceMode;
33
import eu.etaxonomy.cdm.api.service.description.StructuredDescriptionAggregation;
34
import eu.etaxonomy.cdm.api.service.description.StructuredDescriptionAggregationConfiguration;
35
import eu.etaxonomy.cdm.filter.LogicFilter;
36
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
37
import eu.etaxonomy.taxeditor.l10n.Messages;
38

  
39
/**
40
 * @author k.luther
41
 * @since 11.12.2019
42
 */
43
public class StructuredDescriptionAggregationConfigurationWizardPage extends AggregationConfigurationWizardPage<StructuredDescriptionAggregation> {
44

  
45

  
46
    /**
47
     * @param pageName
48
     */
49
    protected StructuredDescriptionAggregationConfigurationWizardPage(StructuredDescriptionAggregationConfiguration configurator) {
50
        super(Messages.DistributionAggregationWizardPage_TITLE);
51
        this.configurator = configurator;
52

  
53
        this.setDescription(Messages.DistributionAggregationWizardPage_DESCRIPTION);
54
    }
55

  
56

  
57

  
58

  
59
    @Override
60
    public void createControl(Composite parent) {
61
        final Composite composite = new Composite(parent, SWT.NULL);
62

  
63
        //select between taxonnode filter for the whole descriptive dataset or the selected taxonnode/subtree
64
        TaxonNode subTreeNode;
65
        int count = configurator.getTaxonNodeFilter().getSubtreeFilter().size();
66
        String taxonStr = "";
67
        for (LogicFilter<TaxonNode> filter: configurator.getTaxonNodeFilter().getSubtreeFilter()){
68
            subTreeNode = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(filter.getUuid());
69
            count--;
70
            if (subTreeNode.hasTaxon()){
71
                taxonStr += subTreeNode.getTaxon().getName().getTitleCache();
72
                if (count>0){
73
                    taxonStr += ", "; //$NON-NLS-1$
74
                }
75
            }
76
        }
77
        if (StringUtils.isNotBlank(taxonStr)){
78
            checkUseSelectedSubtree= new Button(composite,  SWT.RADIO);
79
            checkUseSelectedSubtree.setText(Messages.AggregationWizardPage_SUBTREE +  taxonStr);
80
            checkUseSelectedSubtree.addListener(SWT.Selection, new Listener() {
81
                @Override
82
                public void handleEvent(Event e) {
83
                    updateHigherRankCombo();
84
               }
85
            });
86

  
87
            checkUseSelectedTaxonNode= new Button(composite,  SWT.RADIO);
88
            checkUseSelectedTaxonNode.setText(Messages.AggregationWizardPage_SINGLE_TAXON +  taxonStr);
89
            checkUseSelectedTaxonNode.addListener(SWT.Selection, new Listener() {
90
                @Override
91
                public void handleEvent(Event e) {
92
                    updateHigherRankCombo();
93
                }
94

  
95

  
96
            });
97
        }
98

  
99
        //use taxonnode filter of the descriptive data set
100
        checkUseHigherLevel = new Button(composite,  SWT.RADIO);
101
        checkUseHigherLevel.setText(Messages.DistributionAggregationWizardPage_CLASSIFICATION);
102
        checkUseHigherLevel.addListener(SWT.Selection, new Listener() {
103
           @Override
104
           public void handleEvent(Event e) {
105
               updateHigherRankCombo();
106
           }
107
        });
108

  
109

  
110
        final Composite control = new Composite(composite, SWT.NULL);
111
        GridLayout gridLayoutControl = new GridLayout();
112
        gridLayoutControl.numColumns = 2;
113
        control.setLayout(gridLayoutControl);
114
        control.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
115

  
116
        Label aggregationModeLabel = new Label(control, SWT.NULL);
117
        aggregationModeLabel.setText(Messages.DistributionAggregationWizardPage_AGGREGATION_MODE);
118
        aggregationModeLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_AGGR_MODE);
119
        aggregationModeViewer = CheckboxTableViewer.newCheckList(control, SWT.BORDER | SWT.SINGLE);
120
        aggregationModeViewer.setContentProvider(new ArrayContentProvider());
121
        aggregationModeViewer.setLabelProvider(new LabelProvider(){
122
            @Override
123
            public String getText(Object element){
124
                if (element instanceof AggregationMode){
125
                   return ((AggregationMode)element).getMessage();
126
                }
127
                return null;
128
            }
129

  
130
        });
131
        List<AggregationMode> aggregationModeList = new ArrayList<>();
132
        for (AggregationMode mode: AggregationMode.values()){
133
            aggregationModeList.add(mode);
134
        }
135

  
136
        aggregationModeViewer.setInput(aggregationModeList);
137

  
138
        aggregationModeViewer.addCheckStateListener(new ICheckStateListener(){
139
            @Override
140
            public void checkStateChanged(    CheckStateChangedEvent event){
141
                Object[] checked =aggregationModeViewer.getCheckedElements();
142
                boolean withinChecked = false;
143
                boolean toParentChecked = false;
144
                for (int i = 0; i<checked.length;i++){
145
                    if (checked[i] instanceof AggregationMode){
146
                        if (((AggregationMode)checked[i]).equals(AggregationMode.WithinTaxon)){
147
                            withinChecked = true;
148
                        }
149
                        if (((AggregationMode)checked[i]).equals(AggregationMode.ToParent)){
150
                            toParentChecked = true;
151
                        }
152
                    }
153
                }
154

  
155
                comboSourceModeChildParent.setEnabled(toParentChecked);
156
                comboSourceModeWithinTaxon.setEnabled(withinChecked);
157
//                AggregationSourceMode areaMode = (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
158
                AggregationSourceMode taxonMode = (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
159
//                getSourceTypeViewer().getTable().setEnabled(((areachecked && (areaMode.equals(AggregationSourceMode.ALL) || areaMode.equals(AggregationSourceMode.ALL_SAMEVALUE) ) )|| toParentChecked && (taxonMode.equals(AggregationSourceMode.ALL) || taxonMode.equals(AggregationSourceMode.ALL_SAMEVALUE) )) );
160
                getWizard().getContainer().updateButtons();
161
              }
162
        });
163

  
164
        Label sourceModeLabelWithin = new Label(control, SWT.NULL);
165

  
166
        sourceModeLabelWithin.setText(Messages.DistributionAggregationWizardPage_SOURCEMODE_WITHIN_TAXON);
167
        sourceModeLabelWithin.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_WITHIN_TAXON);
168
        comboSourceModeWithinTaxon = new Combo(control,  SWT.BORDER| SWT.READ_ONLY);
169
        comboSourceModeWithinTaxon.setText(Messages.DistributionAggregationWizardPage_AGGREGATION_MODE);
170

  
171
        for (AggregationSourceMode mode :AggregationSourceMode.values()){
172
            comboSourceModeWithinTaxon.add(mode.getMessage());
173
            comboSourceModeWithinTaxon.setData(mode.getMessage(), mode);
174

  
175
        }
176

  
177

  
178
        comboSourceModeWithinTaxon.setEnabled(false);
179
        comboSourceModeWithinTaxon.select(0);
180

  
181
        Label sourceModeLabel = new Label(control, SWT.NULL);
182

  
183
        sourceModeLabel.setText(Messages.DistributionAggregationWizardPage_SOURCEMODE_CHILD_PARENT);
184
        sourceModeLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_CHILD_PARENT);
185
        comboSourceModeChildParent = new Combo(control,  SWT.BORDER| SWT.READ_ONLY);
186
        comboSourceModeChildParent.setText(Messages.DistributionAggregationWizardPage_AGGREGATION_MODE);
187

  
188
        for (AggregationSourceMode mode :AggregationSourceMode.values()){
189
            comboSourceModeChildParent.add(mode.getMessage());
190
            comboSourceModeChildParent.setData(mode.getMessage(), mode);
191

  
192
        }
193

  
194

  
195
        comboSourceModeChildParent.setEnabled(false);
196
        comboSourceModeChildParent.select(0);
197

  
198

  
199
        setControl(composite);
200
    }
201

  
202

  
203

  
204

  
205

  
206

  
207
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/wizard/SuperAreaPage.java
10 10

  
11 11
import java.util.ArrayList;
12 12
import java.util.Collection;
13
import java.util.Collections;
13 14
import java.util.List;
14 15
import java.util.UUID;
15 16

  
......
65 66
    private void setLevelChecked() {
66 67
        initialiseVocabularies();
67 68
        List<TermDto> areasChecked= new ArrayList();
68
        List<TermDto> areasGrayed = new ArrayList();
69 69
        List<UUID> vocUuidList = new ArrayList<>();
70 70
        getVocabularies().stream().forEach(p -> vocUuidList.add(p.getUuid()));
71 71
        Collection<TermDto> terms = CdmStore.getService(IVocabularyService.class).getNamedAreaTerms(vocUuidList);
72 72
        for (TermDto term: terms) {
73 73
            if (term.getLevel() != null && term.getLevel().equals(level)){
74 74
                areasChecked.add(term);
75
            }else if (term.getLevel() != null && term.getLevel().isHigher(level)){
76
                Object[] children = ((TermDtoContentProvider)this.getViewer().getContentProvider()).getChildren(term);
77
                boolean checked = false;
78
                if (children != null && children.length >0){
79
                    for (Object o: children){
80
                        if (o instanceof TermDto){
81
                            TermDto dto = ((TermDto)o);
82
                            if (dto.getLevel() != null && dto.getLevel().equals(level)){
83
                                checked = true;
84
                            }
85
                        }
86
                    }
87
                }
88
                if (checked){
89
                    areasGrayed.add(term);
90
                }
91 75
            }
92 76
        }
93 77

  
94 78
        treeComposite.getViewer().setInput(getVocabularies());
79
        Collections.sort(areasChecked, (o1, o2)->o1.getOrderIndex()-o2.getOrderIndex());
95 80

  
96 81
        treeComposite.setCheckedElements(areasChecked.toArray());
97
        treeComposite.setGrayedElements(areasGrayed.toArray());
82
        treeComposite.update();
83

  
98 84
    }
99 85

  
100 86
    @Override

Also available in: Unified diff