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
.Group
;
20 import eu
.etaxonomy
.cdm
.model
.common
.ICdmBase
;
21 import eu
.etaxonomy
.cdm
.model
.common
.User
;
22 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
23 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
24 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
25 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
26 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
27 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
28 import eu
.etaxonomy
.cdm
.model
.occurrence
.Collection
;
29 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
30 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldObservation
;
31 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
32 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
33 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
34 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
35 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
36 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
37 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
44 public class SelectionDialogFactory
{
46 public static <T
extends ICdmBase
> T
getSelectionFromDialog(Class
<T
> clazz
, Shell shell
, ConversationHolder conversation
, T curentSelection
){
48 if(clazz
.equals(Taxon
.class)){
49 return (T
) TaxonBaseSelectionDialog
.selectTaxon(shell
, conversation
, (Taxon
) curentSelection
);
51 if(clazz
.equals(Synonym
.class)){
52 return (T
) TaxonBaseSelectionDialog
.selectSynonym(shell
, conversation
);
54 if(clazz
.equals(TaxonBase
.class)){
55 return (T
) TaxonBaseSelectionDialog
.selectTaxonBase(shell
, conversation
);
57 if(clazz
.equals(Classification
.class)){
58 return (T
) ClassificationSelectionDialog
.select(shell
, conversation
, (Classification
) curentSelection
);
60 if(clazz
.equals(TaxonNode
.class)){
61 return (T
) TaxonNodeSelectionDialog
.select(shell
, conversation
, null, null, (TaxonNode
) curentSelection
, null);
63 if(clazz
.equals(Reference
.class)){
64 return (T
) ReferenceSelectionDialog
.select(shell
, conversation
, (Reference
) curentSelection
);
66 if(clazz
.equals(TaxonNameBase
.class)){
67 return (T
) NameSelectionDialog
.select(shell
, conversation
, (TaxonNameBase
) curentSelection
);
69 if(clazz
.equals(Team
.class)){
70 return (T
) TeamSelectionDialog
.select(shell
, conversation
, (Team
) curentSelection
);
72 if(clazz
.equals(AgentBase
.class)){
73 return (T
) AgentSelectionDialog
.select(shell
, conversation
, (AgentBase
) curentSelection
);
75 if(clazz
.equals(Feature
.class)){
76 return (T
) FeatureSelectionDialog
.select(shell
, conversation
, (Feature
) curentSelection
);
78 if(clazz
.equals(FeatureTree
.class)){
79 return (T
) FeatureTreeSelectionDialog
.select(shell
, conversation
, (FeatureTree
) curentSelection
);
81 if(clazz
.equals(PolytomousKey
.class)){
82 return (T
) PolytomousKeySelectionDialog
.select(shell
, conversation
, (PolytomousKey
) curentSelection
);
84 if(clazz
.equals(PolytomousKeyNode
.class)){
85 StoreUtil
.warningDialog("Not implemented yet", SelectionDialogFactory
.class,
86 "This functionality is not implemented yet.");
89 if(clazz
.equals(DerivedUnitBase
.class)){
90 return (T
) DerivedUnitSelectionDialog
.select(shell
, conversation
, (DerivedUnitBase
) curentSelection
);
92 if(clazz
.equals(FieldObservation
.class)){
93 return (T
) FieldObservationSelectionDialog
.select(shell
, conversation
, (FieldObservation
) curentSelection
);
95 if(clazz
.equals(NamedArea
.class)){
96 return (T
) NamedAreaSelectionDialog
.select(shell
, conversation
, (NamedArea
) curentSelection
);
98 if(clazz
.equals(Collection
.class)){
99 return (T
) CollectionSelectionDialog
.select(shell
, conversation
, (Collection
) curentSelection
);
101 if(clazz
.equals(User
.class)){
102 return (T
) UserSelectionDialog
.select(shell
, conversation
, (User
) curentSelection
);
104 if (clazz
.equals(Person
.class)){
105 return (T
) PersonSelectionDialog
.select(shell
, conversation
, (Person
) curentSelection
);
107 if(clazz
.equals(Group
.class)){
108 return (T
) GroupSelectionDialog
.select(shell
, conversation
, (Group
) curentSelection
);
110 if(clazz
.equals(Institution
.class)){
111 return (T
) InstitutionSelectionDialog
.select(shell
, conversation
, (Institution
) curentSelection
);