Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / selection / SelectionDialogFactory.java
index 7f38851d4e78383ef4898fe6f0058fade0cc3300..dbb9ef191ff0f779af69632c8cbd3e063a63ab30 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
 * Copyright (C) 2009 EDIT
 * European Distributed Institute of Taxonomy
@@ -21,7 +20,6 @@ import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
 import eu.etaxonomy.cdm.model.common.Group;
 import eu.etaxonomy.cdm.model.common.ICdmBase;
-import eu.etaxonomy.cdm.model.common.TermType;
 import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.description.FeatureTree;
@@ -29,6 +27,7 @@ import eu.etaxonomy.cdm.model.description.PolytomousKey;
 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
 import eu.etaxonomy.cdm.model.location.Country;
 import eu.etaxonomy.cdm.model.location.NamedArea;
+import eu.etaxonomy.cdm.model.media.Media;
 import eu.etaxonomy.cdm.model.molecular.Amplification;
 import eu.etaxonomy.cdm.model.molecular.Primer;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
@@ -43,12 +42,11 @@ import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.store.CdmStore;
 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.description.detail.DistributionDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
+import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
 
 /**
  * @author n.hoffmann
@@ -78,9 +76,13 @@ 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);
                }
@@ -88,16 +90,16 @@ public class SelectionDialogFactory {
                        return (T) TeamSelectionDialog.select(shell, conversation, (Team) currentSelection);
                }
                if(clazz.equals(TeamOrPersonBase.class) && parentElement instanceof AuthorshipDetailElement){
-            return (T) NomenclaturalAuthorSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
+            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) NomenclaturalAuthorSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
+                   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);
@@ -123,14 +125,11 @@ public class SelectionDialogFactory {
                    return (T) SpecimenOrObservationBaseSelectionDialog.select(shell, conversation, (SpecimenOrObservationBase) currentSelection);
                }
                if(clazz.equals(NamedArea.class)){
-                   if(parentElement instanceof DistributionDetailElement){
-//                return (T) NamedAreaSelectionForDistributionDialog.select(shell, conversation, (NamedArea) currentSelection, CdmStore.getTermManager().getPreferredVocabulary(TermType.NamedArea));
-                return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, Country.uuidCountryVocabulary);
-                   }else if(parentElement instanceof IEntityElement && ((IEntityElement) parentElement).getEntity() instanceof DerivedUnitFacade){
-                       return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, Country.uuidCountryVocabulary);
+                   if(parentElement instanceof IEntityElement && ((IEntityElement) parentElement).getEntity() instanceof DerivedUnitFacade){
+                       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)){
@@ -157,6 +156,9 @@ public class SelectionDialogFactory {
                if(clazz.equals(Amplification.class)){
                    return (T) AmplificationSelectionDialog.select(shell, conversation, (Amplification) currentSelection);
                }
+               if(clazz.equals(Media.class)){
+                   return (T) MediaSelectionDialog.select(shell, conversation, (Media) currentSelection);
+               }
 
                return null;
        }