ref #7981 enable source modes for checked aggregation modes and some code cleaning
authorAndreas Müller <a.mueller@bgbm.org>
Fri, 1 Oct 2021 07:24:10 +0000 (09:24 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Fri, 1 Oct 2021 07:24:10 +0000 (09:24 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/StructuredDescriptionAggregationConfigurationWizardPage.java

index 7ffadf97ccfbe7ded4a5fbf01d4f2be784686126..3fe21d8f0461a5415de52821eb97270ad3da6b42 100755 (executable)
@@ -187,6 +187,7 @@ public class StructuredDescriptionAggregationConfigurationWizardPage extends Agg
         updateLowerRankCombo();
         comboLowerRank.addListener(SWT.Selection, this);
 
+        //aggregation mode viewer
         Label aggregationModeLabel = new Label(control, SWT.NULL);
         aggregationModeLabel.setText(Messages.DistributionAggregationWizardPage_AGGREGATION_MODE);
         aggregationModeLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_AGGR_MODE);
@@ -201,12 +202,10 @@ public class StructuredDescriptionAggregationConfigurationWizardPage extends Agg
                 }
                 return null;
             }
-
         });
         List<AggregationMode> aggregationModeList = AggregationMode.list(AggregationType.StructuredDescription);
         aggregationModeViewer.setInput(aggregationModeList);
         aggregationModeViewer.setCheckedElements(configurator.getAggregationModes().toArray());
-
         aggregationModeViewer.addCheckStateListener(new ICheckStateListener(){
             @Override
             public void checkStateChanged(    CheckStateChangedEvent event){
@@ -226,15 +225,12 @@ public class StructuredDescriptionAggregationConfigurationWizardPage extends Agg
 
                 comboSourceModeChildParent.setEnabled(toParentChecked);
                 comboSourceModeWithinTaxon.setEnabled(withinChecked);
-//                AggregationSourceMode areaMode = (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
-                AggregationSourceMode taxonMode = (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
-//                getSourceTypeViewer().getTable().setEnabled(((areachecked && (areaMode.equals(AggregationSourceMode.ALL) || areaMode.equals(AggregationSourceMode.ALL_SAMEVALUE) ) )|| toParentChecked && (taxonMode.equals(AggregationSourceMode.ALL) || taxonMode.equals(AggregationSourceMode.ALL_SAMEVALUE) )) );
                 getWizard().getContainer().updateButtons();
-              }
+            }
         });
 
+        //source mode within taxon
         Label sourceModeLabelWithin = new Label(control, SWT.NULL);
-
         sourceModeLabelWithin.setText(Messages.DistributionAggregationWizardPage_SOURCEMODE_WITHIN_TAXON);
         sourceModeLabelWithin.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_WITHIN_TAXON);
         comboSourceModeWithinTaxon = new Combo(control,  SWT.BORDER| SWT.READ_ONLY);
@@ -245,13 +241,14 @@ public class StructuredDescriptionAggregationConfigurationWizardPage extends Agg
             comboSourceModeWithinTaxon.setData(mode.getLabel(), mode);
         }
 
-        comboSourceModeWithinTaxon.setEnabled(false);
+        comboSourceModeWithinTaxon.setEnabled(configurator.getAggregationModes().contains(AggregationMode.WithinTaxon));
         comboSourceModeWithinTaxon.select(0);
         comboSourceModeWithinTaxon.addListener(SWT.Selection, this);
-        Label sourceModeLabel = new Label(control, SWT.NULL);
 
-        sourceModeLabel.setText(Messages.DistributionAggregationWizardPage_SOURCEMODE_CHILD_PARENT);
-        sourceModeLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_CHILD_PARENT);
+        //source mode child parent
+        Label sourceModeChildParentLabel = new Label(control, SWT.NULL);
+        sourceModeChildParentLabel.setText(Messages.DistributionAggregationWizardPage_SOURCEMODE_CHILD_PARENT);
+        sourceModeChildParentLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_SOURCEMODE_CHILD_PARENT);
         comboSourceModeChildParent = new Combo(control,  SWT.BORDER| SWT.READ_ONLY);
         comboSourceModeChildParent.setText(Messages.DistributionAggregationWizardPage_AGGREGATION_MODE);
 
@@ -260,10 +257,13 @@ public class StructuredDescriptionAggregationConfigurationWizardPage extends Agg
             comboSourceModeChildParent.setData(mode.getLabel(), mode);
         }
 
-        comboSourceModeChildParent.setEnabled(false);
+        comboSourceModeChildParent.setEnabled(configurator.getAggregationModes().contains(AggregationMode.ToParent));
         comboSourceModeChildParent.select(0);
         comboSourceModeChildParent.addListener(SWT.Selection, this);
         GridLayoutFactory.fillDefaults();
+
+        //source type
+        //TODO: distinguis within taxon and parent child source types
         Label sourceTypeLabel = new Label(control, SWT.NULL);
         sourceTypeLabel.setText(Messages.DistributionAggregationWizardPage_SOURCE_TYPE);
         sourceTypeLabel.setToolTipText(Messages.DistributionAggregationWizardPage_TOOLTIP_SOURCE_TYPE);