ref #7981: select configuration default values
authorKatja Luther <k.luther@bgbm.org>
Fri, 8 Oct 2021 09:48:10 +0000 (11:48 +0200)
committerKatja Luther <k.luther@bgbm.org>
Fri, 8 Oct 2021 09:48:10 +0000 (11:48 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/AggregationConfigurationWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/DistributionAggregationWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/StructuredAggregationConfigurationWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/StructuredDescriptionAggregationConfigurationWizardPage.java

index dd6e65b3455c1854e867609d3b3661bd8a486e3b..7a42558af70498bcbe03dd2f0383f3e9bc23e7ed 100755 (executable)
@@ -25,6 +25,7 @@ import eu.etaxonomy.cdm.api.service.description.AggregationMode;
 import eu.etaxonomy.cdm.api.service.description.AggregationSourceMode;
 import eu.etaxonomy.cdm.api.service.description.DescriptionAggregationBase;
 import eu.etaxonomy.cdm.api.service.description.DescriptionAggregationConfigurationBase;
+import eu.etaxonomy.cdm.filter.LogicFilter;
 import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
@@ -99,6 +100,7 @@ public abstract class AggregationConfigurationWizardPage<T extends DescriptionAg
             comboHigherRank.add(rank.getLabel());
             comboHigherRank.setData(rank.getLabel(), rank);
         }
+        
     }
 
    protected void updateLowerRankCombo() {
@@ -126,8 +128,8 @@ public abstract class AggregationConfigurationWizardPage<T extends DescriptionAg
        }
        rankList.sort(comparator);
        for (Rank rank: rankList){
-           comboLowerRank.add(rank.getLabel());
-           comboLowerRank.setData(rank.getLabel(), rank);
+          comboLowerRank.add(rank.getLabel());
+          comboLowerRank.setData(rank.getLabel(), rank);
        }
    }
 
@@ -174,6 +176,7 @@ public abstract class AggregationConfigurationWizardPage<T extends DescriptionAg
 
    public EnumSet<OriginalSourceType> getSourceTypes(){
        List<OriginalSourceType> list = new ArrayList<>();
+       if (sourceTypeViewer == null) return null;
        for (Object o: sourceTypeViewer.getCheckedElements()){
            String string = null;
            if (o instanceof String){
@@ -198,4 +201,24 @@ public abstract class AggregationConfigurationWizardPage<T extends DescriptionAg
        }
        return result;
    }
+   
+   protected void setConfigValueToRankCombo(Combo rankCombo) {
+               int index = 0;
+       if (configurator.getTaxonNodeFilter().getRankMax() == null){
+               rankCombo.select(index);
+       }else{        
+               Rank rank = null;
+               for (String item: rankCombo.getItems()){
+                       if (rankCombo.getData(item) instanceof Rank){
+                               rank = (Rank) rankCombo.getData(item);
+                               if (rank.getUuid().equals(configurator.getTaxonNodeFilter().getRankMax().getUuid())){
+                                       rankCombo.select(index);
+                                       break;
+                               }
+                       }
+                       index++;
+               }
+       }
+       }
+
 }
\ No newline at end of file
index 4978777ad806d845fbda3e0cbeb7ec354a572aee..750f9c7eb0993d9c46d19d5c58d1518192e92035 100755 (executable)
@@ -44,6 +44,7 @@ import eu.etaxonomy.cdm.api.service.description.DistributionAggregation;
 import eu.etaxonomy.cdm.api.service.description.DistributionAggregationConfiguration;
 import eu.etaxonomy.cdm.filter.LogicFilter;
 import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
+import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
@@ -200,12 +201,15 @@ public class DistributionAggregationWizardPage
 
         comboHigherRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
         updateHigherRankCombo();
+        setConfigValueToRankCombo(comboHigherRank);
         comboHigherRank.addListener(SWT.Selection, this);
 
         Label lowerRankLabel = new Label(control, SWT.NULL);
         lowerRankLabel.setText(Messages.DistributionAggregationWizardPage_LOWEST_RANK);
         comboLowerRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
         updateLowerRankCombo();
+        
+        setConfigValueToRankCombo(comboLowerRank);
         comboLowerRank.addListener(SWT.Selection, this);
 
         separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
@@ -375,6 +379,7 @@ public class DistributionAggregationWizardPage
         setControl(composite);
     }
 
+       
     @Override
     public void widgetSelected(SelectionEvent e) {
 
index 05785ca69583ca81349f29bf04b345c0b9cf71f2..be64ddf25cb228408156f10aaf52314c95337e60 100755 (executable)
@@ -65,8 +65,19 @@ public class StructuredAggregationConfigurationWizard extends Wizard implements
 //        }
         TaxonNodeFilter filter = configurator.getTaxonNodeFilter();
         if (!page.useHigherLevel()) {
-            UUID minRankUuid = dataSet.getMinRank() != null? dataSet.getMinRank().getUuid(): null;
-            UUID maxRankUuid = dataSet.getMinRank() != null? dataSet.getMaxRank().getUuid(): null;
+               UUID minRankUuid = null;
+               UUID maxRankUuid = null;
+               if (page.getHigherRank() != null){
+                       maxRankUuid = page.getHigherRank().getUuid();
+               }else{
+                       maxRankUuid = dataSet.getMaxRank() != null? dataSet.getMaxRank().getUuid(): null;
+                       
+               }
+               if (page.getLowerRank() != null){
+                       minRankUuid = page.getLowerRank().getUuid();
+               }else{
+                       minRankUuid = dataSet.getMinRank() != null? dataSet.getMinRank().getUuid(): null;
+               }
             filter.setRankMax(maxRankUuid);
             filter.setRankMin(minRankUuid);
 
index 9ca7e6ed409d697c84d2e8ab624e4549c24aade1..6add11f804f52c0b6743fbad9a591be9b606894d 100755 (executable)
@@ -35,8 +35,10 @@ import eu.etaxonomy.cdm.api.service.description.AggregationSourceMode;
 import eu.etaxonomy.cdm.api.service.description.AggregationType;
 import eu.etaxonomy.cdm.api.service.description.StructuredDescriptionAggregation;
 import eu.etaxonomy.cdm.api.service.description.StructuredDescriptionAggregationConfiguration;
+import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.persistence.dto.DescriptiveDataSetBaseDto;
 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
 import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.ui.combo.OriginalSourceTypeComparator;
@@ -54,6 +56,8 @@ public class StructuredDescriptionAggregationConfigurationWizardPage
 
     protected Button checkIncludeDefaultDescriptions;
     protected Button checkIncludeLiteratureDescriptions;
+    protected DescriptiveDataSetBaseDto ddsDTO;
+    
 
     private Label selectSubtreeLabel;
 
@@ -62,6 +66,8 @@ public class StructuredDescriptionAggregationConfigurationWizardPage
         this.configurator = configurator;
         this.setDescription(Messages.DistributionAggregationWizardPage_DESCRIPTION);
         selectedNodes = nodes;
+        ddsDTO = CdmApplicationState.getCurrentAppConfig().getDescriptiveDataSetService().getDescriptiveDataSetDtoByUuid(configurator.getDatasetUuid());
+        
     }
 
     @Override
@@ -98,6 +104,7 @@ public class StructuredDescriptionAggregationConfigurationWizardPage
                }
            }
         });
+       
 
         //   ... from selected subtree
         checkUseSelectedSubtree= new Button(radioComposite, SWT.RADIO);
@@ -212,12 +219,14 @@ public class StructuredDescriptionAggregationConfigurationWizardPage
 
         comboHigherRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
         updateHigherRankCombo();
+        setConfigValueToRankCombo(comboHigherRank, ddsDTO.getMaxRank().getUuid());
         comboHigherRank.addListener(SWT.Selection, this);
 
         Label lowerRankLabel = new Label(control, SWT.NULL);
         lowerRankLabel.setText(Messages.DistributionAggregationWizardPage_LOWEST_RANK);
         comboLowerRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
         updateLowerRankCombo();
+        setConfigValueToRankCombo(comboLowerRank, ddsDTO.getMinRank().getUuid());
         comboLowerRank.addListener(SWT.Selection, this);
 
         //aggregation mode viewer
@@ -307,7 +316,7 @@ public class StructuredDescriptionAggregationConfigurationWizardPage
         comboSourceModeChildParent.addListener(SWT.Selection, this);
         GridLayoutFactory.fillDefaults();
 
-        //source type
+        /*source type
         //TODO: distinguish within taxon and parent child source types
         Label sourceTypeLabel = new Label(control, SWT.NULL);
         sourceTypeLabel.setText(Messages.DistributionAggregationWizardPage_SOURCE_TYPE);
@@ -332,6 +341,7 @@ public class StructuredDescriptionAggregationConfigurationWizardPage
         sourceTypeViewer.setChecked(OriginalSourceType.PrimaryMediaSource.getLabel(), true);
         sourceTypeViewer.setChecked(OriginalSourceType.PrimaryTaxonomicSource.getLabel(), true);
         sourceTypeViewer.getTable().setEnabled(false);
+        */
         setControl(control);
     }
 
@@ -355,11 +365,11 @@ public class StructuredDescriptionAggregationConfigurationWizardPage
         }
 
         if (event.widget.equals(this.comboSourceModeChildParent) || event.widget.equals(this.comboSourceModeWithinTaxon)){
-            if (getSourceModeChildParent().equals(AggregationSourceMode.NONE) && getSourceModeWithinTaxon().equals(AggregationSourceMode.NONE)){
-                sourceTypeViewer.getTable().setEnabled(false);
-            }else {
-                sourceTypeViewer.getTable().setEnabled(true);
-            }
+//            if (getSourceModeChildParent().equals(AggregationSourceMode.NONE) && getSourceModeWithinTaxon().equals(AggregationSourceMode.NONE)){
+//                sourceTypeViewer.getTable().setEnabled(false);
+//            }else {
+//                sourceTypeViewer.getTable().setEnabled(true);
+//            }
         }
     }
 
@@ -373,4 +383,24 @@ public class StructuredDescriptionAggregationConfigurationWizardPage
         }
         return result;
     }
+    
+    protected void setConfigValueToRankCombo(Combo rankCombo, UUID rankUuid) {
+               int index = 0;
+               
+       if (rankUuid == null){
+                       rankCombo.select(index);
+       }else{        
+               Rank rank = null;
+               for (String item: rankCombo.getItems()){
+                       if (rankCombo.getData(item) instanceof Rank){
+                               rank = (Rank) rankCombo.getData(item);
+                               if (rank.getUuid().equals(rankUuid)){
+                                       rankCombo.select(index);
+                                       break;
+                               }
+                       }
+                       index++;
+               }
+       }
+       }
 }
\ No newline at end of file