ref #8677: layout and labeling in aggregation config wizard
authorKatja Luther <k.luther@bgbm.org>
Wed, 4 Dec 2019 08:52:12 +0000 (09:52 +0100)
committerKatja Luther <k.luther@bgbm.org>
Wed, 4 Dec 2019 08:53:09 +0000 (09:53 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/TermDtoContentProvider.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/AvailableDistributionPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/CheckBoxTreeComposite.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/OriginalSourceTypeComparator.java [new file with mode: 0755]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/SuperAreaSelectionWizard.java
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
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/wizard/NamedAreaTermDtoContentProvider.java [new file with mode: 0755]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/wizard/SuperAreaPage.java [moved from eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/SuperAreaPage.java with 61% similarity]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/AbstractOriginalSourceElement.java

index bb77dd5ee7d1645fc14138b91282c1b1f72af060..53c2f15cf981faf4652063396281eef9f4b3bc14 100644 (file)
@@ -88,16 +88,24 @@ public class TermDtoContentProvider extends TreeNodeContentProvider {
        }
 
     public Collection<? extends TermDto> getChildTerms(TermVocabularyDto voc) {
-        Collection<TermDto> children = vocabularyToChildTermMap.get(voc);
+        Collection<TermDto> children = getVocabularyToChildTermMap().get(voc);
         if(children==null){
             children = new ArrayList<>(CdmStore.getService(IVocabularyService.class).getCompleteTermHierarchy(voc));
-            vocabularyToChildTermMap.put(voc, children);
+            getVocabularyToChildTermMap().put(voc, children);
         }
         return children;
     }
 
     public void removeVocabularyFromCache(TermVocabularyDto voc){
-        vocabularyToChildTermMap.remove(voc);
+        getVocabularyToChildTermMap().remove(voc);
+    }
+
+    public Map<TermVocabularyDto, Collection<TermDto>> getVocabularyToChildTermMap() {
+        return vocabularyToChildTermMap;
+    }
+
+    public void setVocabularyToChildTermMap(Map<TermVocabularyDto, Collection<TermDto>> vocabularyToChildTermMap) {
+        this.vocabularyToChildTermMap = vocabularyToChildTermMap;
     }
 
 }
index 81249ebcdee88bee0bfe0ba0ba70683eeed627f5..0748f4edf6a45cc323e0f36d1da43526822f1163 100755 (executable)
@@ -39,6 +39,8 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  */
 public class AvailableDistributionPage extends AbstractTermSelectionWizardPage<TermDto> {
 
+
+
     public AvailableDistributionPage(String pageName) {
         super(pageName, TermType.NamedArea);
         this.localPref = true;
@@ -46,6 +48,7 @@ public class AvailableDistributionPage extends AbstractTermSelectionWizardPage<T
 
     }
 
+
     @Override
     public void createControl(Composite parent) {
         setTitle(Messages.AvailableDistributionPage_PAGE_TITLE);
index 1568d2e1f96c2001fbf151f51d967871b939781d..4cff5afb8c4d0667dc1992e5e41cb0494b069b32 100644 (file)
@@ -177,6 +177,22 @@ public class CheckBoxTreeComposite extends Composite implements SelectionListene
 
     }
 
+    /**
+     * Grays the tree items corresponding to the given elements.<br>
+     * @param elements
+     */
+    public void setGrayedElements(Object[] elements) {
+        viewer.setGrayedElements(elements);
+        for (Object element: elements) {
+            viewer.reveal(element);
+        }
+        TreeItem[] rootItems = viewer.getTree().getItems();
+        for (TreeItem rootItem : rootItems) {
+            updateItem(rootItem);
+        }
+
+    }
+
     @Override
     public void widgetSelected(SelectionEvent e) {
         ITreeSelection structuredSelection = viewer.getStructuredSelection();
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/OriginalSourceTypeComparator.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/OriginalSourceTypeComparator.java
new file mode 100755 (executable)
index 0000000..f2f656e
--- /dev/null
@@ -0,0 +1,101 @@
+/**
+* Copyright (C) 2019 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.ui.combo;
+
+import java.util.Comparator;
+
+import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
+import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
+
+/**
+ * @author pplitzner, k.luther
+ * @since 04.12.2019
+ */
+/**
+ * Sorts source type combo alphabetically <b>except</b> for PrimaryTaxonomicSource resp.
+ * PrimaryMediaSource which are always on top depending on the IdentifiableSource;
+ * <br>
+ * The last two are always "Other" followed by "Unknown"
+ * @author pplitzner
+ * @date Jan 6, 2017
+ *
+ */
+public class OriginalSourceTypeComparator implements Comparator<OriginalSourceType>{
+
+    private OriginalSourceBase entity;
+
+    public OriginalSourceTypeComparator(OriginalSourceBase entity) {
+        this.entity = entity;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int compare(OriginalSourceType o1, OriginalSourceType o2) {
+        if(o1==null){
+            if(o2==null){
+                return 0;
+            }
+            else{
+                return -1;
+            }
+        }
+        if(o2==null){
+            return 1;
+        }
+        //both are either taxonomic or media
+        else if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource)
+                && o2.equals(OriginalSourceType.PrimaryMediaSource)){
+            if(entity != null && entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
+                return 1;
+            }
+            else{
+                return -1;
+            }
+        }
+        else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)
+                && o1.equals(OriginalSourceType.PrimaryMediaSource)){
+            if(entity != null && entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
+                return -1;
+            }
+            else{
+                return 1;
+            }
+        }
+        //one is not taxonomic or media
+        else if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource)
+                ||o1.equals(OriginalSourceType.PrimaryMediaSource)){
+            return -1;
+
+        }
+        else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)
+                || o2.equals(OriginalSourceType.PrimaryMediaSource)){
+            return 1;
+        }
+        //The last two are always "Other" followed by "Unknown"
+        else if(o1.equals(OriginalSourceType.Other)){
+            if(o2.equals(OriginalSourceType.Unknown)){
+                return -11;
+            }
+            else{
+                return 1;
+            }
+        }
+        if(o2.equals(OriginalSourceType.Other)){
+            return 1;
+        }
+        else{
+            String message1 = o1.getKey();
+            String message2 = o2.getKey();
+            return message1.compareTo(message2);
+        }
+    }
+
+}
\ No newline at end of file
index ca0c5f6dbd9160d13c40f04ca8cd3b818f0108aa..db7cf37378bb24c9fdb68bb0ea0d99219cdc99ba 100755 (executable)
@@ -20,7 +20,7 @@ import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
 import eu.etaxonomy.cdm.persistence.dto.TermDto;
 import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
 import eu.etaxonomy.taxeditor.l10n.Messages;
-import eu.etaxonomy.taxeditor.preference.wizard.SuperAreaPage;
+import eu.etaxonomy.taxeditor.ui.dialog.configurator.wizard.SuperAreaPage;
 
 /**
  * @author k.luther
index 0c23c0fca1b872cb2e14ff73de59ccd06506d3bd..c3567a3042764f3f28dbfc9443b5e5c998f7f7b2 100755 (executable)
@@ -11,18 +11,22 @@ package eu.etaxonomy.taxeditor.ui.dialog.configurator;
 import java.util.UUID;
 
 import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Display;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.service.description.DistributionAggregationConfiguration;
 import eu.etaxonomy.cdm.api.service.longrunningService.ILongRunningTasksService;
+import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
 import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
 import eu.etaxonomy.taxeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
 
 /**
  * @author k.luther
  * @since 15.11.2019
  */
-public class DistributionAggregationConfiguratorWizard extends Wizard {
+public class DistributionAggregationConfiguratorWizard extends Wizard implements IPostMoniteredOperationEnabled {
     private final DistributionAggregationConfiguration configurator;
     private DistributionAggregationWizardPage page;
     private ILongRunningTasksService longRunningTaskService;
@@ -55,6 +59,20 @@ public class DistributionAggregationConfiguratorWizard extends Wizard {
 
         UUID uuid = longRunningTaskService.invoke(configurator);
 
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                AbstractUtility.executeMoniteredOperation("Aggregate Distributions",
+                        uuid,
+                        1000,
+                        false,
+                        DistributionAggregationConfiguratorWizard.this,
+                        null,
+                        true);
+
+            }
+
+        });
 
         return true;
     }
@@ -68,4 +86,11 @@ public class DistributionAggregationConfiguratorWizard extends Wizard {
     }
 
 
+    @Override
+    public void postOperation(IRemotingProgressMonitor monitor) {
+        // TODO Auto-generated method stub
+
+    }
+
+
 }
index 7c38bc81655a49d7a1bdf3c5c2f2305808af7da2..e558ca64a1ae4c9a5d4615bd79d7995d678896ea 100755 (executable)
@@ -106,7 +106,7 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
         super("Set Publish Flag Configuration");
         this.configurator = configurator;
 
-        this.setDescription(Messages.SetPublishConfiguration_Description_Configurator);
+        this.setDescription("Configure the aggregation");
 
     }
 
@@ -159,7 +159,7 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
             });
         }
         checkUseSelectedClassification= new Button(composite,  SWT.RADIO);
-        checkUseSelectedClassification.setText("Export selected classification");
+        checkUseSelectedClassification.setText("Aggregate selected classification");
         checkUseSelectedClassification.addListener(SWT.Selection, new Listener() {
            @Override
            public void handleEvent(Event e) {
@@ -228,12 +228,12 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
         control.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
 
         Label higherRankLabel = new Label(control, SWT.NULL);
-        higherRankLabel.setText("Higher rank");
+        higherRankLabel.setText("Highest rank");
         comboHigherRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
         updateHigherRankCombo();
         comboHigherRank.addListener(SWT.Selection, this);
         Label lowerRankLabel = new Label(control, SWT.NULL);
-        lowerRankLabel.setText("Lower rank");
+        lowerRankLabel.setText("Lowest rank");
         comboLowerRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
         updateLowerRankCombo();
         comboLowerRank.addListener(SWT.Selection, this);
@@ -254,10 +254,10 @@ public class DistributionAggregationWizardPage extends WizardPage implements Lis
             public String getText(Object element){
                 if (element instanceof AggregationMode){
                     if (((AggregationMode)element).equals(AggregationMode.ToParent)){
-                        return "from child to parent";
+                        return "From child to parent taxon";
                     }
                     if (((AggregationMode)element).equals(AggregationMode.WithinTaxon)){
-                        return "from sub area to super area";
+                        return "From sub area to super area";
                     }
                 }
                 return null;
@@ -350,6 +350,7 @@ 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));
         sourceTypeViewer.setInput(typeStrings);
         sourceTypeViewer.setChecked(OriginalSourceType.PrimaryMediaSource.getMessage(), true);
         sourceTypeViewer.setChecked(OriginalSourceType.PrimaryTaxonomicSource.getMessage(), true);
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/wizard/NamedAreaTermDtoContentProvider.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/wizard/NamedAreaTermDtoContentProvider.java
new file mode 100755 (executable)
index 0000000..0a80946
--- /dev/null
@@ -0,0 +1,36 @@
+/**
+* Copyright (C) 2019 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.ui.dialog.configurator.wizard;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
+import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
+import eu.etaxonomy.taxeditor.editor.definedterm.TermDtoContentProvider;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @since 03.12.2019
+ */
+public class NamedAreaTermDtoContentProvider extends TermDtoContentProvider {
+
+    @Override
+    public Collection<? extends TermDto> getChildTerms(TermVocabularyDto voc) {
+        Collection<TermDto> children = getVocabularyToChildTermMap().get(voc);
+        if(children==null){
+            children = new ArrayList<>(CdmStore.getService(IVocabularyService.class).getCompleteTermHierarchy(voc));
+            getVocabularyToChildTermMap().put(voc, children);
+        }
+        return children;
+    }
+
+}
similarity index 61%
rename from eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/SuperAreaPage.java
rename to eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/wizard/SuperAreaPage.java
index a6fa041ac31ee3d5e45955d8074584b59dd2ee9a..7290e135c78d5de96e8b1e8aa7eade0ef9a27cb8 100755 (executable)
@@ -6,7 +6,7 @@
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
-package eu.etaxonomy.taxeditor.preference.wizard;
+package eu.etaxonomy.taxeditor.ui.dialog.configurator.wizard;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -24,6 +24,8 @@ import eu.etaxonomy.cdm.persistence.dto.TermDto;
 import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermSorter;
 import eu.etaxonomy.taxeditor.editor.definedterm.TermDtoContentProvider;
 import eu.etaxonomy.taxeditor.editor.definedterm.TermDtoLabelProvider;
+import eu.etaxonomy.taxeditor.preference.wizard.AvailableDistributionPage;
+import eu.etaxonomy.taxeditor.preference.wizard.CheckBoxTreeComposite;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
@@ -62,19 +64,37 @@ public class SuperAreaPage extends AvailableDistributionPage {
      */
     private void setLevelChecked() {
         initialiseVocabularies();
-        List<TermDto> areasWithLevel= new ArrayList();
-        List<UUID> uuidList = new ArrayList<>();
-        getVocabularies().stream().forEach(p -> uuidList.add(p.getUuid()));
-        Collection<TermDto> terms = CdmStore.getService(IVocabularyService.class).getTerms(uuidList);
+        List<TermDto> areasChecked= new ArrayList();
+        List<TermDto> areasGrayed = new ArrayList();
+        List<UUID> vocUuidList = new ArrayList<>();
+        getVocabularies().stream().forEach(p -> vocUuidList.add(p.getUuid()));
+        Collection<TermDto> terms = CdmStore.getService(IVocabularyService.class).getNamedAreaTerms(vocUuidList);
         for (TermDto term: terms) {
             if (term.getLevel() != null && term.getLevel().equals(level)){
-                areasWithLevel.add(term);
+                areasChecked.add(term);
+            }else if (term.getLevel() != null && term.getLevel().isHigher(level)){
+                Object[] children = ((TermDtoContentProvider)this.getViewer().getContentProvider()).getChildren(term);
+                boolean checked = false;
+                if (children != null && children.length >0){
+                    for (Object o: children){
+                        if (o instanceof TermDto){
+                            TermDto dto = ((TermDto)o);
+                            if (dto.getLevel() != null && dto.getLevel().equals(level)){
+                                checked = true;
+                            }
+                        }
+                    }
+                }
+                if (checked){
+                    areasGrayed.add(term);
+                }
             }
         }
 
         treeComposite.getViewer().setInput(getVocabularies());
 
-        treeComposite.setCheckedElements(areasWithLevel.toArray());
+        treeComposite.setCheckedElements(areasChecked.toArray());
+        treeComposite.setGrayedElements(areasGrayed.toArray());
     }
 
     @Override
index 945089ad7fb6a931b2eedb353290e155f806eb8c..e3f666594add637c275cce80e18f6211fa8f5f6c 100644 (file)
@@ -9,8 +9,6 @@
 
 package eu.etaxonomy.taxeditor.ui.section.supplemental;
 
-import java.util.Comparator;
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionListener;
 
@@ -19,6 +17,7 @@ import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
 import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
+import eu.etaxonomy.taxeditor.ui.combo.OriginalSourceTypeComparator;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
@@ -83,86 +82,5 @@ public abstract class AbstractOriginalSourceElement<T extends OriginalSourceBase
 
        }
 
-       /**
-        * Sorts source type combo alphabetically <b>except</b> for PrimaryTaxonomicSource resp.
-        * PrimaryMediaSource which are always on top depending on the IdentifiableSource;
-        * <br>
-        * The last two are always "Other" followed by "Unknown"
-        * @author pplitzner
-        * @date Jan 6, 2017
-        *
-        */
-       private class OriginalSourceTypeComparator implements Comparator<OriginalSourceType>{
-
-           private OriginalSourceBase entity;
 
-        public OriginalSourceTypeComparator(OriginalSourceBase entity) {
-            this.entity = entity;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public int compare(OriginalSourceType o1, OriginalSourceType o2) {
-            if(o1==null){
-                if(o2==null){
-                    return 0;
-                }
-                else{
-                    return -1;
-                }
-            }
-            if(o2==null){
-                return 1;
-            }
-            //both are either taxonomic or media
-            else if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource)
-                    && o2.equals(OriginalSourceType.PrimaryMediaSource)){
-                if(entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
-                    return 1;
-                }
-                else{
-                    return -1;
-                }
-            }
-            else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)
-                    && o1.equals(OriginalSourceType.PrimaryMediaSource)){
-                if(entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
-                    return -1;
-                }
-                else{
-                    return 1;
-                }
-            }
-            //one is not taxonomic or media
-            else if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource)
-                    ||o1.equals(OriginalSourceType.PrimaryMediaSource)){
-                return -1;
-
-            }
-            else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)
-                    || o2.equals(OriginalSourceType.PrimaryMediaSource)){
-                return 1;
-            }
-            //The last two are always "Other" followed by "Unknown"
-            else if(o1.equals(OriginalSourceType.Other)){
-                if(o2.equals(OriginalSourceType.Unknown)){
-                    return -11;
-                }
-                else{
-                    return 1;
-                }
-            }
-            if(o2.equals(OriginalSourceType.Other)){
-                return 1;
-            }
-            else{
-                String message1 = o1.getKey();
-                String message2 = o2.getKey();
-                return message1.compareTo(message2);
-            }
-        }
-
-       }
 }