ref #8776: fix d&d for not allow duplicates
authorKatja Luther <k.luther@bgbm.org>
Mon, 31 May 2021 09:30:41 +0000 (11:30 +0200)
committerKatja Luther <k.luther@bgbm.org>
Mon, 31 May 2021 09:30:41 +0000 (11:30 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/termtree/e4/TermTreeDtoDropAdapter.java

index fa1e232197a1cde45f0171ef4fcb8c5f4cc6befc..f66184ea611761ebcf47bebbb12ad081580a254c 100755 (executable)
@@ -253,6 +253,13 @@ public class TermTreeDtoDropAdapter extends ViewerDropAdapter {
         if (target instanceof TermNodeDto && ((TermNodeDto)target).getTree().isFlat() && getCurrentLocation() == LOCATION_ON){
             isSupported = false;
         }
+        TermDto term = null;
+        if (getSelectedObject() instanceof TermNodeDto){
+            term = ((TermNodeDto)getSelectedObject()).getTerm();
+        }
+        if ((target instanceof TermNodeDto && !((TermNodeDto)target).getTree().isAllowDuplicate() && ((TermNodeDto)target).getTree().getTerms().contains(term)) || (target instanceof TermTreeDto && !((TermTreeDto)target).isAllowDuplicate() && ((TermTreeDto)target).getTerms().contains(term))){
+            isSupported = false;
+        }
         return isSupported;
     }