ref #8774: show which terms are duplicates in dialog
authorKatja Luther <k.luther@bgbm.org>
Fri, 27 Nov 2020 11:44:41 +0000 (12:44 +0100)
committerKatja Luther <k.luther@bgbm.org>
Fri, 27 Nov 2020 11:44:41 +0000 (12:44 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/AbstractAddFeatureHandler.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties

index 7ee4c35d1e58596b7d023663c590b3bb283e4c96..a74ff040ee9816ce89893ac1d9dabbe5d3fad77f 100755 (executable)
@@ -8,7 +8,9 @@
 */
 package eu.etaxonomy.taxeditor.featuretree.e4.handler;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 import javax.inject.Named;
 
@@ -63,16 +65,19 @@ public abstract class AbstractAddFeatureHandler {
 
         if (dialog.open() == IStatus.OK) {
             Collection<DefinedTermBase> additionalTerms = wizard.getAdditionalFeatures();
+            List<DefinedTermBase> duplicates = new ArrayList<>();
             for (DefinedTermBase term : additionalTerms) {
 
+                boolean isDuplicate = false;
                 if (!parent.getTree().isAllowDuplicate()){
-                    boolean isDuplicate = editor.checkDuplicates(term.getUuid(), parent.getTree().getUuid());
+                    isDuplicate = editor.checkDuplicates(term.getUuid(), parent.getTree().getUuid());
                     if (isDuplicate){
-                        MessagingUtils.informationDialog(Messages.AddFeatureHandler_Duplicates_not_allowed, Messages.AddFeatureHandler_Duplicates_not_allowed_message);
-                        return;
+                        duplicates.add(term);
                     }
                 }
-
+                if (isDuplicate){
+                    continue;
+                }
                 AddFeatureOperation operation = new AddFeatureOperation(term.getUuid(), parent, editor, editor);
 //                AbstractUtility.executeOperation(operation, sync);
                 editor.addOperation(operation);
@@ -93,6 +98,13 @@ public abstract class AbstractAddFeatureHandler {
                     ((AbstractTermTreeEditor)editor).getViewer().setExpandedElements(expandedElements);
                 }
             }
+            if (!duplicates.isEmpty()){
+                String termsTitles = "";
+                for (DefinedTermBase term: duplicates){
+                    termsTitles = termsTitles + term.getTitleCache() +"\n";
+                }
+                MessagingUtils.informationDialog(Messages.AddFeatureHandler_Duplicates_not_allowed, Messages.AddFeatureHandler_Duplicates_not_allowed_message +  "\n"+termsTitles);
+            }
         }
     }
 
index 77da7a25f6d8c10be0c5e395c87bd81ce0ffb987..40cc31d61f42ae67b33cb71b8c9d6bd33e5fa003 100644 (file)
@@ -307,7 +307,7 @@ FeatureTreeSelectionDialog_NEW_TREE=New Term tree
 FeatureTreeSelectionDialog_TREE_LABEL=Term tree label
 
 AddFeatureHandler_Duplicates_not_allowed=No duplicates allowed
-AddFeatureHandler_Duplicates_not_allowed_message=This term tree does not allow duplicates and there exist a node with this term already.
+AddFeatureHandler_Duplicates_not_allowed_message=This term tree does not allow duplicates and there exist nodes with following terms:
 
 NonViralNameDetails_confirmDeleteOfZoologicalNameParts=The publication and original publication year needs to be removed
 NonViralNameDetails_descriptionDeleteZoologicalNameParts=If you click Yes, the original publication and publication year is removed and the nomenclatural code is changed.
index 3a0679513873cf4036f836e96ce7a468dd40a270..c480aeba3b20d272ef65c1ed4ed56c6341469862 100644 (file)
@@ -307,7 +307,7 @@ FeatureTreeSelectionDialog_NEW_TREE=Neuer Termbaum
 FeatureTreeSelectionDialog_TREE_LABEL=Termbaumname
 
 AddFeatureHandler_Duplicates_not_allowed=Keine Duplikate erlaubt
-AddFeatureHandler_Duplicates_not_allowed_message=Der Termbaum erlaubt keine Duplikate und für diesen Term existiert bereits ein Knoten.
+AddFeatureHandler_Duplicates_not_allowed_message=Der Termbaum erlaubt keine Duplikate und für folgende Terme existieren bereits Knoten:
 
 NonViralNameDetails_confirmDeleteOfZoologicalNameParts=Breed, Publication Date und Original Publication Date müssen entfernt werden.
 NonViralNameDetails_descriptionDeleteZoologicalNameParts=Bestätigen Sie, wenn Sie Breed, Publication Date und Original Publication Date löschen und den Nomenklatorischen Code des Namens ändern wollen.