ref #8677: set default selections, sort combos and other smaller issues
authorKatja Luther <k.luther@bgbm.org>
Wed, 4 Dec 2019 13:18:59 +0000 (14:18 +0100)
committerKatja Luther <k.luther@bgbm.org>
Wed, 4 Dec 2019 13:18:59 +0000 (14:18 +0100)
eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/bundle.properties
eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/bundle_de.properties
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/DistributionAggregationConfiguratorWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/DistributionAggregationWizardPage.java

index f9a64d4269275db352ed1c6575b46290ef03aba0..a63073f9dc211b33ed5e6a54a7cfe048b72c08c5 100644 (file)
@@ -22,7 +22,7 @@ command.label.14 = Classification
 command.label.15 = New\r
 command.label.16 = Edit\r
 command.label.fixClassificationHierarchy = Create taxon hierarchy\r
-command.label.subtreeOperations = Set for subtree\r
+command.label.subtreeOperations = Edit subtree\r
 command.label.nodeUpdates = Set Flags ...\r
 menu.label.0 = Refresh\r
 command.label.17 = List\r
index 212bdd5c77a242a1062eaf6b84c1f77f9ae19379..e95817853aabae6c5359f1f823bf08d266252d4c 100644 (file)
@@ -22,7 +22,7 @@ command.label.14 = Klassifikation
 command.label.15 = Neu\r
 command.label.16 = Bearbeiten\r
 command.label.fixClassificationHierarchy = Erzeuge Taxon-Hierarchie\r
-command.label.subtreeOperations = Setze für Teilbaum\r
+command.label.subtreeOperations = Teilbaum bearbeiten\r
 command.label.nodeUpdates = Setze Flags ...\r
 menu.label.0 = Aktualisieren\r
 command.label.17 = Liste\r
@@ -50,9 +50,9 @@ command.label.moveFactualData = Verschiebe Faktendaten zu Taxon
 command.label.moveFactualDataSetNameInSource = Verschiebe Faktendaten zu anderem Taxon und setze den Namen in der Quelle, wenn dieser leer ist\r
 command.name.moveFactualData = Verschiebe Faktendaten \r
 command.name.moveFactualDataSetNameInSource = Verschiebe Faktendaten zu anderem Taxon und setze den Namen in der Quelle, wenn dieser leer ist\r
-command.label.setSecForSubtree = Secundum Referenz\r
+command.label.setSecForSubtree = Setze Secundum Referenz\r
 command.name.setSecForSubtree = Setze Secundum für Teilbaum\r
-command.label.setPublishForSubtree = Publish Flag\r
+command.label.setPublishForSubtree = Setze Publish Flag\r
 command.name.setPublishForSubtree = Setze Publish Flag für Teilbaum\r
 command.name.setUnplaced = Setze Unplaced Flag\r
 command.label.setUnplaced = Setze Unplaced Flag\r
index c3567a3042764f3f28dbfc9443b5e5c998f7f7b2..2d8c47b730d67724367051d4c4458b2e0337d86a 100755 (executable)
@@ -56,6 +56,8 @@ public class DistributionAggregationConfiguratorWizard extends Wizard implements
         configurator.getTaxonNodeFilter().setRankMax(page.getHigherRank());
         configurator.getTaxonNodeFilter().setRankMin(page.getLowerRank());
         configurator.setAggregationMode(page.getAggregationMode());
+        configurator.setToParentSourceMode(page.getSourceModeChildParent());
+        configurator.setWithinTaxonSourceMode(page.getSourceModeSuperAreaSubArea());
 
         UUID uuid = longRunningTaskService.invoke(configurator);
 
index d594486ea42455bae90146c8cc4bc3e54598b636..45c6d0e6564da83ed87bbdf2fee4912deee24ee2 100755 (executable)
@@ -57,6 +57,7 @@ import eu.etaxonomy.cdm.model.term.TermType;
 import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.ui.combo.OriginalSourceTypeComparator;
 import eu.etaxonomy.taxeditor.ui.dialog.SuperAreaSelectionWizard;
 
 /**
@@ -70,7 +71,8 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
     private Combo comboHigherRank;
     private Combo comboLowerRank;
 
-    private Combo comboSourceMode;
+    private Combo comboSourceModeChildParent;
+    private Combo comboSourceModeSubAreaSuperArea;
 
     private CheckboxTableViewer aggregationModeViewer;
 
@@ -98,12 +100,21 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
     Object[] checkedElements;
     Map<String, OriginalSourceType> typeMap = new HashMap();
 
+    Comparator comparator = new Comparator<Rank>(){
+
+        @Override
+        public int compare(Rank o1, Rank o2) {
+            return o2.compareTo(o1);
+        }
+
+    };
+
 
     /**
      * @param pageName
      */
     public DistributionAggregationWizardPage(DistributionAggregationConfiguration configurator) {
-        super("Set Publish Flag Configuration");
+        super("Distribution aggregation configuration");
         this.configurator = configurator;
 
         this.setDescription("Configure the aggregation");
@@ -232,6 +243,8 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
         comboHigherRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
         updateHigherRankCombo();
         comboHigherRank.addListener(SWT.Selection, this);
+
+
         Label lowerRankLabel = new Label(control, SWT.NULL);
         lowerRankLabel.setText("Lowest rank");
         comboLowerRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
@@ -276,15 +289,21 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
             public void checkStateChanged(    CheckStateChangedEvent event){
                 Object[] checked =aggregationModeViewer.getCheckedElements();
                 boolean areachecked = false;
+                boolean toParentChecked = false;
                 for (int i = 0; i<checked.length;i++){
                     if (checked[i] instanceof AggregationMode){
                         if (((AggregationMode)checked[i]).equals(AggregationMode.WithinTaxon)){
                             areachecked = true;
                         }
+                        if (((AggregationMode)checked[i]).equals(AggregationMode.ToParent)){
+                            toParentChecked = true;
+                        }
                     }
                 }
                 comboAreaLevel.setEnabled(areachecked);
                 buttonSuperArea.setEnabled(areachecked);
+                comboSourceModeSubAreaSuperArea.setEnabled(areachecked);
+                comboSourceModeChildParent.setEnabled(toParentChecked);
                 getWizard().getContainer().updateButtons();
               }
         });
@@ -322,16 +341,38 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
 
 
         Label sourceModeLabel = new Label(control, SWT.NULL);
-        sourceModeLabel.setText("Source mode");
-        comboSourceMode = new Combo(control,  SWT.BORDER| SWT.READ_ONLY);
-        comboSourceMode.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
+
+        sourceModeLabel.setText("Source mode child/parent");
+        sourceModeLabel.setToolTipText("Defines the source mode if aggregation from child to parent taxon is selected.");
+        comboSourceModeChildParent = new Combo(control,  SWT.BORDER| SWT.READ_ONLY);
+        comboSourceModeChildParent.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
+        comboSourceModeChildParent.add("None");
+        comboSourceModeChildParent.setData(null);
         for (AggregationSourceMode mode :AggregationSourceMode.values()){
-            comboSourceMode.add(mode.toString());
-            comboSourceMode.setData(mode.toString(), mode);
+            comboSourceModeChildParent.add(mode.toString());
+            comboSourceModeChildParent.setData(mode.toString(), mode);
+
         }
 
-        comboSourceMode.addSelectionListener(this);
+        comboSourceModeChildParent.addSelectionListener(this);
+        comboSourceModeChildParent.setEnabled(false);
+        comboSourceModeChildParent.select(0);
+
+        Label sourceModeLabelSuperArea = new Label(control, SWT.NULL);
+        sourceModeLabelSuperArea.setText("Source mode sub area/super area");
+        sourceModeLabelSuperArea.setToolTipText("Defines the source mode if aggregation from sub area to super area is selected.");
+        comboSourceModeSubAreaSuperArea = new Combo(control,  SWT.BORDER| SWT.READ_ONLY);
+        comboSourceModeSubAreaSuperArea.setText(Messages.DistributionAggregationConfiguration_AggregationMode);
+        comboSourceModeSubAreaSuperArea.add("None");
+        comboSourceModeSubAreaSuperArea.setData(null);
+        for (AggregationSourceMode mode :AggregationSourceMode.values()){
+            comboSourceModeSubAreaSuperArea.add(mode.toString());
+            comboSourceModeSubAreaSuperArea.setData(mode.toString(), mode);
+        }
 
+        comboSourceModeSubAreaSuperArea.addSelectionListener(this);
+        comboSourceModeSubAreaSuperArea.setEnabled(false);
+        comboSourceModeSubAreaSuperArea.select(0);
         Label sourceTypeLabel = new Label(control, SWT.NULL);
         sourceTypeLabel.setText("Source type");
 
@@ -348,12 +389,15 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
         });
 
         List<String> typeStrings = new ArrayList<>();
-        Arrays.stream(OriginalSourceType.values()).forEach(p ->typeMap.put(p.getMessage(), p));
-        Arrays.stream(OriginalSourceType.values()).forEach(p ->typeStrings.add(p.getMessage()));
-//        typeStrings.sort(new OriginalSourceTypeComparator(null));
+        OriginalSourceType[] typeArray = OriginalSourceType.values();
+        Arrays.sort(typeArray, new OriginalSourceTypeComparator(null));
+        Arrays.stream(typeArray).forEach(p ->typeMap.put(p.getMessage(), p));
+        Arrays.stream(typeArray).forEach(p ->typeStrings.add(p.getMessage()));
+        typeStrings.remove(OriginalSourceType.NomenclaturalReference.getMessage());
         sourceTypeViewer.setInput(typeStrings);
         sourceTypeViewer.setChecked(OriginalSourceType.PrimaryMediaSource.getMessage(), true);
         sourceTypeViewer.setChecked(OriginalSourceType.PrimaryTaxonomicSource.getMessage(), true);
+        sourceTypeViewer.getTable().setEnabled(false);
 
         //aggregation mode
 
@@ -370,7 +414,7 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
         }
 
         comboStatusOrder.addSelectionListener(this);
-
+        comboStatusOrder.select(0);
 
         checkExportUnpublished = new Button(composite,  SWT.CHECK);
         checkExportUnpublished.setText("Export unpublished taxa");
@@ -390,9 +434,16 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
 
     @Override
     public void widgetSelected(SelectionEvent e) {
-        if (e.getSource().equals(comboSourceMode)){
-            configurator.setToParentSourceMode((AggregationSourceMode)comboSourceMode.getData(comboSourceMode.getText()));
-            configurator.setWithinTaxonSourceMode((AggregationSourceMode)comboSourceMode.getData(comboSourceMode.getText()));
+
+        if (e.getSource().equals(comboSourceModeChildParent) || e.getSource().equals(comboSourceModeSubAreaSuperArea)){
+            AggregationSourceMode modeChild = (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
+            AggregationSourceMode modeArea = (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
+            if ((modeChild != null && modeChild.equals(AggregationSourceMode.ALL) || modeChild.equals(AggregationSourceMode.ALL_SAMEVALUE)) ||(modeArea != null && modeArea.equals(AggregationSourceMode.ALL) || modeArea.equals(AggregationSourceMode.ALL_SAMEVALUE))){
+                sourceTypeViewer.getTable().setEnabled(true);
+            }else{
+                sourceTypeViewer.getTable().setEnabled(false);
+            }
+
         }
 
         if (e.getSource().equals(comboAreaLevel)){
@@ -436,7 +487,7 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
 
     private void updateHigherRankCombo() {
         comboHigherRank.removeAll();
-
+        List<Rank> rankList = new ArrayList<>();
         TaxonName name = null;
         if (subTreeNode != null){
             if (subTreeNode.getTaxon() != null){
@@ -446,28 +497,30 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
         comboHigherRank.add("");
         if (name != null){
             for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
-                if (useClassification()){
-                    comboHigherRank.add(rank.getLabel());
-                    comboHigherRank.setData(rank.getLabel(), rank);
-                }else if (name != null && name.getRank().isHigher(rank)){
-                    comboHigherRank.add(rank.getLabel());
-                    comboHigherRank.setData(rank.getLabel(), rank);
+                if (useClassification() || (name != null && name.getRank().isHigher(rank))){
+                    rankList.add(rank);
                 }
-
             }
         }else{
             for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
-                comboHigherRank.add(rank.getLabel());
-                comboHigherRank.setData(rank.getLabel(), rank);
+                rankList.add(rank);
             }
         }
 
+        rankList.sort(comparator);
+        for (Rank rank: rankList){
+            comboHigherRank.add(rank.getLabel());
+            comboHigherRank.setData(rank.getLabel(), rank);
+        }
+
+
     }
 
 
    private void updateLowerRankCombo() {
        comboLowerRank.removeAll();
        TaxonName name = null;
+       List<Rank> rankList = new ArrayList<>();
        if (subTreeNode != null){
            if (subTreeNode.getTaxon() != null){
                name = subTreeNode.getTaxon().getName();
@@ -476,17 +529,19 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
        comboLowerRank.add("");
        for (Rank rank: CdmStore.getTermManager().getPreferredTerms(Rank.class)){
            if (subTreeNode == null && (comboHigherRank.getText() == null || (comboHigherRank.getData(comboHigherRank.getText()) != null && ((Rank)comboHigherRank.getData(comboHigherRank.getText())).isHigher(rank)))){
-               comboLowerRank.add(rank.getLabel());
-               comboLowerRank.setData(rank.getLabel(), rank);
+               rankList.add(rank);
            }else if (name == null || name.getRank().isHigher(rank)) {
                if(StringUtils.isBlank(comboHigherRank.getText()) || comboHigherRank.getData(comboHigherRank.getText()) != null && ((Rank)comboHigherRank.getData(comboHigherRank.getText())).isHigher(rank)){
                // the rank is lower than higher rank and lower than the rank of the subtree name
-                   comboLowerRank.add(rank.getLabel());
-                   comboLowerRank.setData(rank.getLabel(), rank);
+                   rankList.add(rank);
                }
            }
        }
-
+       rankList.sort(comparator);
+       for (Rank rank: rankList){
+           comboLowerRank.add(rank.getLabel());
+           comboLowerRank.setData(rank.getLabel(), rank);
+       }
 
    }
 
@@ -504,9 +559,18 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
        return null;
    }
 
-   public AggregationSourceMode getSourceMode(){
-       if (StringUtils.isNotBlank(comboSourceMode.getText())){
-           return (AggregationSourceMode)comboSourceMode.getData(comboSourceMode.getText());
+
+   public AggregationSourceMode getSourceModeChildParent(){
+       if (StringUtils.isNotBlank(comboSourceModeChildParent.getText())){
+           return (AggregationSourceMode)comboSourceModeChildParent.getData(comboSourceModeChildParent.getText());
+       }
+       return null;
+   }
+
+   public AggregationSourceMode getSourceModeSuperAreaSubArea(){
+       if (StringUtils.isNotBlank(comboSourceModeSubAreaSuperArea.getText())){
+           return (AggregationSourceMode)comboSourceModeSubAreaSuperArea.getData(comboSourceModeSubAreaSuperArea.getText());
+
        }
        return null;
    }
@@ -549,12 +613,12 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
        return EnumSet.copyOf(list);
    }
 
-   public List<AggregationMode> getAggregationMode(){
+   public List<AggregationSourceMode> getAggregationMode(){
 
-       List<AggregationMode> result = new ArrayList<>();
+       List<AggregationSourceMode> result = new ArrayList<>();
        for (Object o: aggregationModeViewer.getCheckedElements()){
-           if (o instanceof AggregationMode){
-               result.add((AggregationMode)o);
+           if (o instanceof AggregationSourceMode){
+               result.add((AggregationSourceMode)o);
            }
        }
        return result;