3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
;
12 import org
.eclipse
.swt
.widgets
.Shell
;
14 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
15 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
16 import eu
.etaxonomy
.cdm
.model
.agent
.Institution
;
17 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
18 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
19 import eu
.etaxonomy
.cdm
.model
.common
.GrantedAuthorityImpl
;
20 import eu
.etaxonomy
.cdm
.model
.common
.Group
;
21 import eu
.etaxonomy
.cdm
.model
.common
.ICdmBase
;
22 import eu
.etaxonomy
.cdm
.model
.common
.User
;
23 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
24 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
25 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
26 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
27 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
28 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
29 import eu
.etaxonomy
.cdm
.model
.occurrence
.Collection
;
30 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
31 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
32 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
33 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
34 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
35 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
36 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
37 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
38 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
45 public class SelectionDialogFactory
{
47 public static <T
extends ICdmBase
> T
getSelectionFromDialog(Class
<T
> clazz
, Shell shell
, ConversationHolder conversation
, T curentSelection
){
49 if(clazz
.equals(Taxon
.class)){
50 return (T
) TaxonBaseSelectionDialog
.selectTaxon(shell
, conversation
, (Taxon
) curentSelection
);
52 if(clazz
.equals(Synonym
.class)){
53 return (T
) TaxonBaseSelectionDialog
.selectSynonym(shell
, conversation
);
55 if(clazz
.equals(TaxonBase
.class)){
56 return (T
) TaxonBaseSelectionDialog
.selectTaxonBase(shell
, conversation
);
58 if(clazz
.equals(Classification
.class)){
59 return (T
) ClassificationSelectionDialog
.select(shell
, conversation
, (Classification
) curentSelection
);
61 if(clazz
.equals(TaxonNode
.class)){
62 return (T
) TaxonNodeSelectionDialog
.select(shell
, conversation
, null, null, (TaxonNode
) curentSelection
, null);
64 if(clazz
.equals(Reference
.class)){
65 return (T
) ReferenceSelectionDialog
.select(shell
, conversation
, (Reference
) curentSelection
);
67 if(clazz
.equals(TaxonNameBase
.class)){
68 return (T
) NameSelectionDialog
.select(shell
, conversation
, (TaxonNameBase
) curentSelection
);
70 if(clazz
.equals(Team
.class)){
71 return (T
) TeamSelectionDialog
.select(shell
, conversation
, (Team
) curentSelection
);
73 if(clazz
.equals(AgentBase
.class)){
74 return (T
) AgentSelectionDialog
.select(shell
, conversation
, (AgentBase
) curentSelection
);
76 if(clazz
.equals(Feature
.class)){
77 return (T
) FeatureSelectionDialog
.select(shell
, conversation
, (Feature
) curentSelection
);
79 if(clazz
.equals(FeatureTree
.class)){
80 return (T
) FeatureTreeSelectionDialog
.select(shell
, conversation
, (FeatureTree
) curentSelection
);
82 if(clazz
.equals(PolytomousKey
.class)){
83 return (T
) PolytomousKeySelectionDialog
.select(shell
, conversation
, (PolytomousKey
) curentSelection
);
85 if(clazz
.equals(PolytomousKeyNode
.class)){
86 StoreUtil
.warningDialog("Not implemented yet", SelectionDialogFactory
.class,
87 "This functionality is not implemented yet.");
90 if(clazz
.equals(DerivedUnit
.class)){
91 return (T
) DerivedUnitSelectionDialog
.select(shell
, conversation
, (DerivedUnit
) curentSelection
);
93 if(clazz
.equals(FieldUnit
.class)){
94 return (T
) FieldObservationSelectionDialog
.select(shell
, conversation
, (FieldUnit
) curentSelection
);
96 if(clazz
.equals(NamedArea
.class)){
97 return (T
) NamedAreaSelectionDialog
.select(shell
, conversation
, (NamedArea
) curentSelection
);
99 if(clazz
.equals(Collection
.class)){
100 return (T
) CollectionSelectionDialog
.select(shell
, conversation
, (Collection
) curentSelection
);
102 if(clazz
.equals(User
.class)){
103 return (T
) UserSelectionDialog
.select(shell
, conversation
, (User
) curentSelection
);
105 if(clazz
.equals(GrantedAuthorityImpl
.class)){
106 return (T
) GrantedAuthoritySelectionDialog
.select(shell
, conversation
, (GrantedAuthorityImpl
) curentSelection
);
108 if (clazz
.equals(Person
.class)){
109 return (T
) PersonSelectionDialog
.select(shell
, conversation
, (Person
) curentSelection
);
111 if(clazz
.equals(Group
.class)){
112 return (T
) GroupSelectionDialog
.select(shell
, conversation
, (Group
) curentSelection
);
114 if(clazz
.equals(Institution
.class)){
115 return (T
) InstitutionSelectionDialog
.select(shell
, conversation
, (Institution
) curentSelection
);