Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / selection / SelectionDialogFactory.java
index a90ce1c9bca1c861a41b1d44c3dcd2411259cd3b..c47fa2925f8fad9d8c10d94776648c5cd33527a2 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
 * Copyright (C) 2009 EDIT
 * European Distributed Institute of Taxonomy
@@ -44,6 +43,9 @@ import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
+import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
+import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
+import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
 
 /**
  * @author n.hoffmann
@@ -73,21 +75,30 @@ public class SelectionDialogFactory {
                if(clazz.equals(TaxonNode.class)){
                        return (T) TaxonNodeSelectionDialog.select(shell, conversation, null, null, (TaxonNode) currentSelection, ((TaxonNode) currentSelection).getClassification());
                }
+               if(clazz.equals(Reference.class) && parentElement instanceof NomenclaturalReferenceDetailElement){
+                       return (T) NomenclaturalReferenceSelectionDialog.select(shell, conversation, (Reference) currentSelection);
+               }
                if(clazz.equals(Reference.class)){
                        return (T) ReferenceSelectionDialog.select(shell, conversation, (Reference) currentSelection);
                }
+               
                if(clazz.equals(TaxonNameBase.class)){
                        return (T) NameSelectionDialog.select(shell, conversation, (TaxonNameBase) currentSelection);
                }
                if(clazz.equals(Team.class)){
                        return (T) TeamSelectionDialog.select(shell, conversation, (Team) currentSelection);
                }
-               if(clazz.equals(TeamOrPersonBase.class)){
+               if(clazz.equals(TeamOrPersonBase.class) && parentElement instanceof AuthorshipDetailElement){
+            return (T) NomenclaturalAuthorSelectionDialog.select(shell, conversation, (AgentBase) currentSelection, false);
+        }else if(clazz.equals(TeamOrPersonBase.class)){
                    //TODO: add TeamOrPersonBaseSelectionDialog (see ticket #4545)
-                   return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
+                   return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection, false);
                }
+               if(clazz.equals(Person.class) && parentElement instanceof TeamMemberElement){
+                   return (T) NomenclaturalPersonAuthorSelectionDialog.select(shell, conversation, (AgentBase) currentSelection, true);
+        }
                if(clazz.equals(AgentBase.class)){
-                       return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
+                       return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection, false);
                }
                if(clazz.equals(Feature.class)){
                        return (T) FeatureSelectionDialog.select(shell, conversation, (Feature) currentSelection);
@@ -114,10 +125,10 @@ public class SelectionDialogFactory {
                }
                if(clazz.equals(NamedArea.class)){
                    if(parentElement instanceof IEntityElement && ((IEntityElement) parentElement).getEntity() instanceof DerivedUnitFacade){
-                       return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, Country.uuidCountryVocabulary);
+                       return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, DerivedUnit.class.getCanonicalName(), Country.uuidCountryVocabulary);
                    }
                    else{
-                       return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection);
+                       return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, parentElement.getClass().getCanonicalName());
                    }
                }
                if(clazz.equals(Collection.class)){