1 package eu
.etaxonomy
.taxeditor
.bulkeditor
.input
;
3 import java
.util
.HashMap
;
5 import java
.util
.ResourceBundle
;
7 import org
.eclipse
.jface
.action
.IContributionItem
;
8 import org
.eclipse
.swt
.SWT
;
9 import org
.eclipse
.ui
.IEditorInput
;
10 import org
.eclipse
.ui
.PlatformUI
;
11 import org
.eclipse
.ui
.menus
.CommandContributionItem
;
12 import org
.eclipse
.ui
.menus
.CommandContributionItemParameter
;
14 import eu
.etaxonomy
.cdm
.api
.service
.IAgentService
;
15 import eu
.etaxonomy
.cdm
.api
.service
.IGroupService
;
16 import eu
.etaxonomy
.cdm
.api
.service
.IMediaService
;
17 import eu
.etaxonomy
.cdm
.api
.service
.INameService
;
18 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
19 import eu
.etaxonomy
.cdm
.api
.service
.IReferenceService
;
20 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
21 import eu
.etaxonomy
.cdm
.api
.service
.IUserService
;
22 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
23 import eu
.etaxonomy
.cdm
.model
.common
.Group
;
24 import eu
.etaxonomy
.cdm
.model
.common
.User
;
25 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
26 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
27 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
28 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
29 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
31 import eu
.etaxonomy
.taxeditor
.bulkeditor
.IBulkEditorConstants
;
33 public enum BulkEditorInputType
{
34 AGENT(Messages
.BulkEditorInputType_0
, AgentEditorInput
.ID
),
35 REFERENCE(Messages
.BulkEditorInputType_1
, ReferenceEditorInput
.ID
),
36 NAME(Messages
.BulkEditorInputType_2
, NameEditorInput
.ID
),
37 NAME_RELATIONSHIP(Messages
.BulkEditorInputType_3
, NameRelationshipEditorInput
.ID
),
38 OCCURRENCE(Messages
.BulkEditorInputType_4
, OccurrenceEditorInput
.ID
),
39 USER(Messages
.BulkEditorInputType_5
, UserEditorInput
.ID
),
40 GROUP(Messages
.BulkEditorInputType_6
, GroupEditorInput
.ID
),
41 TAXON(Messages
.BulkEditorInputType_7
, TaxonEditorInput
.ID
),
42 MEDIA(Messages
.BulkEditorInputType_8
, MediaEditorInput
.ID
);
46 public ResourceBundle resourceBundle
;
48 BulkEditorInputType(String label
, String id
) {
53 public IContributionItem
createContributionItem(){
54 return createContributionItem(label
, id
);
62 private IContributionItem
createContributionItem(String label
,
64 CommandContributionItemParameter parameter
= new CommandContributionItemParameter(
65 PlatformUI
.getWorkbench().getActiveWorkbenchWindow(), null,
66 IBulkEditorConstants
.DYNAMIC_OPEN_MENU_ID
, SWT
.NONE
);
68 parameter
.label
= label
;
70 Map parameters
= new HashMap();
71 parameters
.put(IBulkEditorConstants
.INPUT_TYPE_PARAMETER_ID
, inputType
);
72 parameter
.parameters
= parameters
;
74 return new CommandContributionItem(parameter
);
77 public static BulkEditorInputType
getById(String id
) {
79 for (BulkEditorInputType type
: values()) {
80 if (id
.equals(type
.id
)) {
88 public static BulkEditorInputType
getByType(Class clazz
) {
89 if (Reference
.class.isAssignableFrom(clazz
)) {
91 } else if (TaxonNameBase
.class.isAssignableFrom(clazz
)) {
93 } else if (AgentBase
.class.isAssignableFrom(clazz
)) {
95 } else if (SpecimenOrObservationBase
.class.isAssignableFrom(clazz
)) {
97 } else if (NameRelationship
.class.isAssignableFrom(clazz
)) {
98 return NAME_RELATIONSHIP
;
99 } else if (Group
.class.isAssignableFrom(clazz
)) {
101 } else if (User
.class.isAssignableFrom(clazz
)) {
103 } else if (TaxonBase
.class.isAssignableFrom(clazz
)){
105 } else if (Media
.class.isAssignableFrom(clazz
)){
111 public static BulkEditorInputType
getByInput(IEditorInput input
) {
112 if (input
instanceof ReferenceEditorInput
) {
114 } else if (input
instanceof NameEditorInput
) {
116 } else if (input
instanceof AgentEditorInput
) {
118 } else if (input
instanceof OccurrenceEditorInput
) {
120 } else if (input
instanceof NameRelationshipEditorInput
) {
121 return NAME_RELATIONSHIP
;
122 } else if (input
instanceof UserEditorInput
) {
124 } else if (input
instanceof GroupEditorInput
) {
126 } else if (input
instanceof TaxonEditorInput
){
128 }else if (input
instanceof MediaEditorInput
){
134 public static AbstractBulkEditorInput
getInput(
135 BulkEditorInputType inputType
) {
138 return new ReferenceEditorInput();
140 return new NameEditorInput();
142 return new AgentEditorInput();
144 return new OccurrenceEditorInput();
145 case NAME_RELATIONSHIP
:
146 return new NameRelationshipEditorInput();
148 return new UserEditorInput();
150 return new GroupEditorInput();
152 return new TaxonEditorInput();
154 return new MediaEditorInput();
156 throw new IllegalStateException(
157 "No input class for the given input type defined."); //$NON-NLS-1$
161 public static Class
getServiceClass(
162 BulkEditorInputType inputType
) {
165 return IReferenceService
.class;
167 return INameService
.class;
169 return IAgentService
.class;
171 return IOccurrenceService
.class;
172 case NAME_RELATIONSHIP
:
173 return INameService
.class;
175 return IUserService
.class;
177 return IGroupService
.class;
179 return ITaxonService
.class;
181 return IMediaService
.class;
183 throw new IllegalStateException(
184 "No input class for the given input type defined."); //$NON-NLS-1$