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
;
36 * <p>BulkEditorInputTypeValues class.</p>
42 public class BulkEditorInputTypeValues
implements IParameterValues
{
44 public enum BulkEditorInputType
{
45 REFERENCE("Reference", ReferenceEditorInput
.ID
),
46 NAME("Name", NameEditorInput
.ID
),
47 AGENT("Authors and Author Teams", AgentEditorInput
.ID
),
48 OCCURRENCE("Specimens or Observations", OccurrenceEditorInput
.ID
),
49 NAME_RELATIONSHIP("Name Relationship", NameRelationshipEditorInput
.ID
),
50 USER("User", UserEditorInput
.ID
),
51 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
)) {
77 else if (TaxonNameBase
.class.isAssignableFrom(clazz
)) {
80 else if (AgentBase
.class.isAssignableFrom(clazz
)) {
83 else if (SpecimenOrObservationBase
.class.isAssignableFrom(clazz
)){
86 else if (NameRelationship
.class.isAssignableFrom(clazz
)){
87 return NAME_RELATIONSHIP
;
89 else if (Group
.class.isAssignableFrom(clazz
)){
92 else if (User
.class.isAssignableFrom(clazz
)){
98 public static BulkEditorInputType
getByInput(IEditorInput input
) {
99 if (input
instanceof ReferenceEditorInput
) {
102 else if (input
instanceof NameEditorInput
) {
105 else if (input
instanceof AgentEditorInput
) {
108 else if (input
instanceof OccurrenceEditorInput
) {
111 else if (input
instanceof NameRelationshipEditorInput
) {
112 return NAME_RELATIONSHIP
;
114 else if(input
instanceof UserEditorInput
){
117 else if(input
instanceof GroupEditorInput
){
123 public static AbstractBulkEditorInput
getInput(BulkEditorInputType inputType
){
126 return new ReferenceEditorInput();
128 return new NameEditorInput();
130 return new AgentEditorInput();
132 return new OccurrenceEditorInput();
133 case NAME_RELATIONSHIP
:
134 return new NameRelationshipEditorInput();
136 return new UserEditorInput();
138 return new GroupEditorInput();
140 throw new IllegalStateException("No input class for the given input type defined.");
146 * @see org.eclipse.core.commands.IParameterValues#getParameterValues()
149 * <p>getParameterValues</p>
151 * @return a {@link java.util.Map} object.
153 public Map
getParameterValues() {
154 final Map values
= new HashMap();
156 // TODO user role determines which editor inputs are returned
157 for (BulkEditorInputType inputType
: BulkEditorInputType
.values()){
158 values
.put(inputType
.label
, inputType
.id
);