3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.taxeditor
.bulkeditor
.input
;
13 import java
.util
.HashMap
;
16 import org
.eclipse
.core
.commands
.IParameterValues
;
17 import org
.eclipse
.ui
.IEditorInput
;
19 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
20 import eu
.etaxonomy
.cdm
.model
.common
.Group
;
21 import eu
.etaxonomy
.cdm
.model
.common
.User
;
22 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
23 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
24 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
25 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
29 * BulkEditorInputTypeValues class.
36 public class BulkEditorInputTypeValues
implements IParameterValues
{
38 public enum BulkEditorInputType
{
39 REFERENCE("Reference", ReferenceEditorInput
.ID
), NAME("Name",
40 NameEditorInput
.ID
), AGENT("Authors and Author Teams",
41 AgentEditorInput
.ID
), OCCURRENCE("Specimens and Observations",
42 OccurrenceEditorInput
.ID
), NAME_RELATIONSHIP(
43 "Name Relationship", NameRelationshipEditorInput
.ID
), USER(
44 "User", UserEditorInput
.ID
), GROUP("Group", GroupEditorInput
.ID
);
49 BulkEditorInputType(String label
, String id
) {
54 public static BulkEditorInputType
getById(String id
) {
56 for (BulkEditorInputType type
: values()) {
57 if (id
.equals(type
.id
)) {
65 public static BulkEditorInputType
getByType(Class clazz
) {
66 if (Reference
.class.isAssignableFrom(clazz
)) {
68 } else if (TaxonNameBase
.class.isAssignableFrom(clazz
)) {
70 } else if (AgentBase
.class.isAssignableFrom(clazz
)) {
72 } else if (SpecimenOrObservationBase
.class.isAssignableFrom(clazz
)) {
74 } else if (NameRelationship
.class.isAssignableFrom(clazz
)) {
75 return NAME_RELATIONSHIP
;
76 } else if (Group
.class.isAssignableFrom(clazz
)) {
78 } else if (User
.class.isAssignableFrom(clazz
)) {
84 public static BulkEditorInputType
getByInput(IEditorInput input
) {
85 if (input
instanceof ReferenceEditorInput
) {
87 } else if (input
instanceof NameEditorInput
) {
89 } else if (input
instanceof AgentEditorInput
) {
91 } else if (input
instanceof OccurrenceEditorInput
) {
93 } else if (input
instanceof NameRelationshipEditorInput
) {
94 return NAME_RELATIONSHIP
;
95 } else if (input
instanceof UserEditorInput
) {
97 } else if (input
instanceof GroupEditorInput
) {
103 public static AbstractBulkEditorInput
getInput(
104 BulkEditorInputType inputType
) {
107 return new ReferenceEditorInput();
109 return new NameEditorInput();
111 return new AgentEditorInput();
113 return new OccurrenceEditorInput();
114 case NAME_RELATIONSHIP
:
115 return new NameRelationshipEditorInput();
117 return new UserEditorInput();
119 return new GroupEditorInput();
121 throw new IllegalStateException(
122 "No input class for the given input type defined.");
130 * @see org.eclipse.core.commands.IParameterValues#getParameterValues()
137 * @return a {@link java.util.Map} object.
140 public Map
getParameterValues() {
141 final Map values
= new HashMap();
143 // TODO user role determines which editor inputs are returned
144 for (BulkEditorInputType inputType
: BulkEditorInputType
.values()) {
145 values
.put(inputType
.label
, inputType
.id
);