-// $Id$
/**
* Copyright (C) 2009 EDIT
-* European Distributed Institute of Taxonomy
+* 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.
*/
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
import eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.agent.Institution;
import eu.etaxonomy.cdm.model.agent.Person;
import eu.etaxonomy.cdm.model.agent.Team;
+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.description.FeatureTree;
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.name.TaxonNameBase;
+import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.cdm.model.media.Rights;
+import eu.etaxonomy.cdm.model.molecular.Amplification;
+import eu.etaxonomy.cdm.model.molecular.Primer;
+import eu.etaxonomy.cdm.model.name.TaxonName;
import eu.etaxonomy.cdm.model.occurrence.Collection;
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
-import eu.etaxonomy.cdm.model.occurrence.FieldObservation;
+import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
+import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.Synonym;
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.store.StoreUtil;
+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;
+import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement;
/**
* @author n.hoffmann
*/
public class SelectionDialogFactory {
- public static <T extends ICdmBase> T getSelectionFromDialog(Class<T> clazz, Shell shell, ConversationHolder conversation, T curentSelection){
-
+ public static <T extends ICdmBase> T getSelectionFromDialog(Class<T> clazz, Shell shell, //ConversationHolder conversation,
+ T currentSelection){
+ return getSelectionFromDialog(clazz, shell, //conversation,
+ currentSelection, null);
+ }
+
+ public static <T extends ICdmBase> T getSelectionFromDialog(Class<T> clazz, Shell shell, //ConversationHolder conversation,
+ T currentSelection, ICdmFormElement parentElement){
+
if(clazz.equals(Taxon.class)){
- return (T) TaxonBaseSelectionDialog.selectTaxon(shell, conversation, (Taxon) curentSelection);
+ return (T) TaxonSelectionDialog.selectTaxon(shell, //conversation,
+ (Taxon) currentSelection);
}
if(clazz.equals(Synonym.class)){
- return (T) TaxonBaseSelectionDialog.selectSynonym(shell, conversation);
+ return (T) TaxonBaseSelectionDialog.selectSynonym(shell );//,conversation);
}
if(clazz.equals(TaxonBase.class)){
- return (T) TaxonBaseSelectionDialog.selectTaxonBase(shell, conversation);
+ return (T) TaxonBaseSelectionDialog.selectTaxonBase(shell);//, conversation);
}
if(clazz.equals(Classification.class)){
- return (T) ClassificationSelectionDialog.select(shell, conversation, (Classification) curentSelection);
+ return (T) ClassificationSelectionDialog.select(shell, //conversation,
+ (Classification) currentSelection);
}
if(clazz.equals(TaxonNode.class)){
- return (T) TaxonNodeSelectionDialog.select(shell, conversation, null, null, (TaxonNode) curentSelection, null);
+ return (T) TaxonNodeSelectionDialog.select(shell, //conversation,
+ null, null, (TaxonNode) currentSelection, ((TaxonNode) currentSelection).getClassification().getUuid());
+ }
+ if(clazz.equals(Reference.class) && parentElement instanceof NomenclaturalReferenceDetailElement){
+ return (T) NomenclaturalReferenceSelectionDialog.select(shell, //conversation,
+ (Reference) currentSelection, ((NomenclaturalReferenceDetailElement)parentElement).getEntity().getCombinationAuthorship());
}
if(clazz.equals(Reference.class)){
- return (T) ReferenceSelectionDialog.select(shell, conversation, (Reference) curentSelection);
+ if (parentElement instanceof ReferenceDetailElement){
+ return (T) ReferenceSelectionDialog.select(shell, //conversation,
+ ((ReferenceDetailElement) parentElement).getEntity(), true);
+ }
+ return (T) ReferenceSelectionDialog.select(shell, //conversation,
+ (Reference) currentSelection);
}
- if(clazz.equals(TaxonNameBase.class)){
- return (T) NameSelectionDialog.select(shell, conversation, (TaxonNameBase) curentSelection);
+
+ if(clazz.equals(TaxonName.class)){
+ return (T) NameSelectionDialog.select(shell, //conversation,
+ (TaxonName) currentSelection);
}
if(clazz.equals(Team.class)){
- return (T) TeamSelectionDialog.select(shell, conversation, (Team) curentSelection);
- }
+ return (T) TeamSelectionDialog.select(shell, //conversation,
+ (Team) currentSelection);
+ }
+ 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, 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) curentSelection);
+ return (T) AgentSelectionDialog.select(shell, //conversation,
+ (AgentBase) currentSelection, false);
}
if(clazz.equals(Feature.class)){
- return (T) FeatureSelectionDialog.select(shell, conversation, (Feature) curentSelection);
+ return (T) FeatureSelectionDialog.select(shell, //conversation,
+ (Feature) currentSelection);
}
if(clazz.equals(FeatureTree.class)){
- return (T) FeatureTreeSelectionDialog.select(shell, conversation, (FeatureTree) curentSelection);
+ return (T) FeatureTreeSelectionDialog.select(shell, //conversation,
+ (FeatureTree) currentSelection);
}
if(clazz.equals(PolytomousKey.class)){
- return (T) PolytomousKeySelectionDialog.select(shell, conversation, (PolytomousKey) curentSelection);
+ return (T) PolytomousKeySelectionDialog.select(shell, //conversation,
+ (PolytomousKey) currentSelection);
}
if(clazz.equals(PolytomousKeyNode.class)){
- StoreUtil.warningDialog("Not implemented yet", SelectionDialogFactory.class,
+ MessagingUtils.warningDialog("Not implemented yet", SelectionDialogFactory.class,
"This functionality is not implemented yet.");
return null;
}
- if(clazz.equals(DerivedUnitBase.class)){
- return (T) DerivedUnitSelectionDialog.select(shell, conversation, (DerivedUnitBase) curentSelection);
+ if(clazz.equals(DerivedUnit.class)){
+ return (T) DerivedUnitSelectionDialog.select(shell, //conversation,
+ (DerivedUnit) currentSelection);
+ }
+ if(clazz.equals(FieldUnit.class)){
+ return (T) FieldUnitSelectionDialog.select(shell, //conversation,
+ (FieldUnit) currentSelection);
}
- if(clazz.equals(FieldObservation.class)){
- return (T) FieldObservationSelectionDialog.select(shell, conversation, (FieldObservation) curentSelection);
+ if(clazz.equals(SpecimenOrObservationBase.class)){
+ return (T) SpecimenOrObservationBaseSelectionDialog.select(shell, //conversation,
+ (SpecimenOrObservationBase) currentSelection);
}
if(clazz.equals(NamedArea.class)){
- return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) curentSelection);
+ 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, parentElement.getClass().getCanonicalName());
+ }
}
if(clazz.equals(Collection.class)){
- return (T) CollectionSelectionDialog.select(shell, conversation, (Collection) curentSelection);
+ return (T) CollectionSelectionDialog.select(shell, //conversation,
+ (Collection) currentSelection);
}
if(clazz.equals(User.class)){
- return (T) UserSelectionDialog.select(shell, conversation, (User) curentSelection);
+ return (T) UserSelectionDialog.select(shell, //conversation,
+ (User) currentSelection);
}
if(clazz.equals(GrantedAuthorityImpl.class)){
- return (T) GrantedAuthoritySelectionDialog.select(shell, conversation, (GrantedAuthorityImpl) curentSelection);
+ return (T) GrantedAuthoritySelectionDialog.select(shell, //conversation,
+ (GrantedAuthorityImpl) currentSelection);
}
if (clazz.equals(Person.class)){
- return (T) PersonSelectionDialog.select(shell, conversation, (Person) curentSelection);
+ return (T) PersonSelectionDialog.select(shell, //conversation,
+ (Person) currentSelection);
}
if(clazz.equals(Group.class)){
- return (T) GroupSelectionDialog.select(shell, conversation, (Group) curentSelection);
+ return (T) GroupSelectionDialog.select(shell, //conversation,
+ (Group) currentSelection);
}
if(clazz.equals(Institution.class)){
- return (T) InstitutionSelectionDialog.select(shell, conversation, (Institution) curentSelection);
+ return (T) InstitutionSelectionDialog.select(shell, //conversation,
+ (Institution) currentSelection);
+ }
+ if(clazz.equals(Primer.class)){
+ return (T) PrimerSelectionDialog.select(shell, //conversation,
+ (Primer) currentSelection);
}
-
+ 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);
+ }
+ if(clazz.equals(Rights.class)){
+ return (T) RightsSelectionDialog.select(shell, //conversation,
+ (Rights) currentSelection);
+ }
+
return null;
}
-
+
+ public static <T extends ICdmBase> T getSelectionFromExtDialog(Class<T> clazz, Shell shell, //ConversationHolder conversation,
+ ICdmFormElement parentElement){
+ return (T) ExtReferenceSelectionDialog.select(shell, //conversation,
+ null);
+ }
+
+
}