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
.command
;
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
;
26 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.AbstractBulkEditorInput
;
27 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.AgentEditorInput
;
28 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.GroupEditorInput
;
29 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.NameEditorInput
;
30 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.NameRelationshipEditorInput
;
31 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.OccurrenceEditorInput
;
32 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.ReferenceEditorInput
;
33 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.UserEditorInput
;
37 * BulkEditorInputTypeValues class.
44 public class BulkEditorInputTypeValues
implements IParameterValues
{
46 public enum BulkEditorInputType
{
47 REFERENCE("Reference", ReferenceEditorInput
.ID
), NAME("Name",
48 NameEditorInput
.ID
), AGENT("Authors and Author Teams",
49 AgentEditorInput
.ID
), OCCURRENCE("Specimens and Observations",
50 OccurrenceEditorInput
.ID
), NAME_RELATIONSHIP(
51 "Name Relationship", NameRelationshipEditorInput
.ID
), USER(
52 "User", UserEditorInput
.ID
), GROUP("Group", GroupEditorInput
.ID
);
57 BulkEditorInputType(String label
, String id
) {
62 public static BulkEditorInputType
getById(String id
) {
64 for (BulkEditorInputType type
: values()) {
65 if (id
.equals(type
.id
)) {
73 public static BulkEditorInputType
getByType(Class clazz
) {
74 if (Reference
.class.isAssignableFrom(clazz
)) {
76 } else if (TaxonNameBase
.class.isAssignableFrom(clazz
)) {
78 } else if (AgentBase
.class.isAssignableFrom(clazz
)) {
80 } else if (SpecimenOrObservationBase
.class.isAssignableFrom(clazz
)) {
82 } else if (NameRelationship
.class.isAssignableFrom(clazz
)) {
83 return NAME_RELATIONSHIP
;
84 } else if (Group
.class.isAssignableFrom(clazz
)) {
86 } else if (User
.class.isAssignableFrom(clazz
)) {
92 public static BulkEditorInputType
getByInput(IEditorInput input
) {
93 if (input
instanceof ReferenceEditorInput
) {
95 } else if (input
instanceof NameEditorInput
) {
97 } else if (input
instanceof AgentEditorInput
) {
99 } else if (input
instanceof OccurrenceEditorInput
) {
101 } else if (input
instanceof NameRelationshipEditorInput
) {
102 return NAME_RELATIONSHIP
;
103 } else if (input
instanceof UserEditorInput
) {
105 } else if (input
instanceof GroupEditorInput
) {
111 public static AbstractBulkEditorInput
getInput(
112 BulkEditorInputType inputType
) {
115 return new ReferenceEditorInput();
117 return new NameEditorInput();
119 return new AgentEditorInput();
121 return new OccurrenceEditorInput();
122 case NAME_RELATIONSHIP
:
123 return new NameRelationshipEditorInput();
125 return new UserEditorInput();
127 return new GroupEditorInput();
129 throw new IllegalStateException(
130 "No input class for the given input type defined.");
138 * @see org.eclipse.core.commands.IParameterValues#getParameterValues()
145 * @return a {@link java.util.Map} object.
148 public Map
getParameterValues() {
149 final Map values
= new HashMap();
151 // TODO user role determines which editor inputs are returned
152 for (BulkEditorInputType inputType
: BulkEditorInputType
.values()) {
153 values
.put(inputType
.label
, inputType
.id
);