Project

General

Profile

« Previous | Next » 

Revision dc6d4f3c

Added by Niels Hoffmann about 13 years ago

Fixes #2320

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorInputTypeValues.java
1 1
// $Id$
2 2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
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.
9
*/
3
 * Copyright (C) 2007 EDIT
4
 * European Distributed Institute of Taxonomy 
5
 * http://www.e-taxonomy.eu
6
 * 
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.
9
 */
10 10

  
11 11
package eu.etaxonomy.taxeditor.bulkeditor.command;
12 12

  
......
33 33
import eu.etaxonomy.taxeditor.bulkeditor.input.UserEditorInput;
34 34

  
35 35
/**
36
 * <p>BulkEditorInputTypeValues class.</p>
37
 *
36
 * <p>
37
 * BulkEditorInputTypeValues class.
38
 * </p>
39
 * 
38 40
 * @author p.ciardelli
39 41
 * @created 20.08.2009
40 42
 * @version 1.0
41 43
 */
42 44
public class BulkEditorInputTypeValues implements IParameterValues {
43 45

  
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);
52
		
53
		
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);
53

  
54 54
		public String id;
55 55
		public String label;
56
		
57
		BulkEditorInputType(String label, String id){
56

  
57
		BulkEditorInputType(String label, String id) {
58 58
			this.id = id;
59 59
			this.label = label;
60 60
		}
61
		
62
		public static BulkEditorInputType getById(String id){
63
			
64
			for(BulkEditorInputType type : values()){
65
				if(id.equals(type.id)){
61

  
62
		public static BulkEditorInputType getById(String id) {
63

  
64
			for (BulkEditorInputType type : values()) {
65
				if (id.equals(type.id)) {
66 66
					return type;
67 67
				}
68 68
			}
69
			
69

  
70 70
			return null;
71 71
		}
72
		
73
		public static BulkEditorInputType getByType(Class clazz){
72

  
73
		public static BulkEditorInputType getByType(Class clazz) {
74 74
			if (Reference.class.isAssignableFrom(clazz)) {
75 75
				return REFERENCE;
76
			}
77
			else if (TaxonNameBase.class.isAssignableFrom(clazz)) {
76
			} else if (TaxonNameBase.class.isAssignableFrom(clazz)) {
78 77
				return NAME;
79
			}
80
			else if (AgentBase.class.isAssignableFrom(clazz)) {
78
			} else if (AgentBase.class.isAssignableFrom(clazz)) {
81 79
				return AGENT;
82
			}
83
			else if (SpecimenOrObservationBase.class.isAssignableFrom(clazz)){
80
			} else if (SpecimenOrObservationBase.class.isAssignableFrom(clazz)) {
84 81
				return OCCURRENCE;
85
			}
86
			else if (NameRelationship.class.isAssignableFrom(clazz)){
82
			} else if (NameRelationship.class.isAssignableFrom(clazz)) {
87 83
				return NAME_RELATIONSHIP;
88
			}
89
			else if (Group.class.isAssignableFrom(clazz)){
84
			} else if (Group.class.isAssignableFrom(clazz)) {
90 85
				return GROUP;
91
			}
92
			else if (User.class.isAssignableFrom(clazz)){
86
			} else if (User.class.isAssignableFrom(clazz)) {
93 87
				return USER;
94 88
			}
95 89
			return null;
96 90
		}
97
		
91

  
98 92
		public static BulkEditorInputType getByInput(IEditorInput input) {
99 93
			if (input instanceof ReferenceEditorInput) {
100 94
				return REFERENCE;
101
			}
102
			else if (input instanceof NameEditorInput) {
95
			} else if (input instanceof NameEditorInput) {
103 96
				return NAME;
104
			}
105
			else if (input instanceof AgentEditorInput) {
97
			} else if (input instanceof AgentEditorInput) {
106 98
				return AGENT;
107
			}
108
			else if (input instanceof OccurrenceEditorInput) {
99
			} else if (input instanceof OccurrenceEditorInput) {
109 100
				return OCCURRENCE;
110
			}
111
			else if (input instanceof NameRelationshipEditorInput) {
101
			} else if (input instanceof NameRelationshipEditorInput) {
112 102
				return NAME_RELATIONSHIP;
113
			}
114
			else if(input instanceof UserEditorInput){
103
			} else if (input instanceof UserEditorInput) {
115 104
				return USER;
116
			}
117
			else if(input instanceof GroupEditorInput){
105
			} else if (input instanceof GroupEditorInput) {
118 106
				return GROUP;
119 107
			}
120 108
			return null;
121 109
		}
122
		
123
		public static AbstractBulkEditorInput getInput(BulkEditorInputType inputType){
110

  
111
		public static AbstractBulkEditorInput getInput(
112
				BulkEditorInputType inputType) {
124 113
			switch (inputType) {
125 114
			case REFERENCE:
126 115
				return new ReferenceEditorInput();
......
137 126
			case GROUP:
138 127
				return new GroupEditorInput();
139 128
			default:
140
				throw new IllegalStateException("No input class for the given input type defined.");
129
				throw new IllegalStateException(
130
						"No input class for the given input type defined.");
141 131
			}
142 132
		}
143 133
	}
144
	
145
	/* (non-Javadoc)
134

  
135
	/*
136
	 * (non-Javadoc)
137
	 * 
146 138
	 * @see org.eclipse.core.commands.IParameterValues#getParameterValues()
147 139
	 */
148 140
	/**
149
	 * <p>getParameterValues</p>
150
	 *
141
	 * <p>
142
	 * getParameterValues
143
	 * </p>
144
	 * 
151 145
	 * @return a {@link java.util.Map} object.
152 146
	 */
147
	@Override
153 148
	public Map getParameterValues() {
154 149
		final Map values = new HashMap();
155
		
150

  
156 151
		// TODO user role determines which editor inputs are returned
157
		for (BulkEditorInputType inputType : BulkEditorInputType.values()){
152
		for (BulkEditorInputType inputType : BulkEditorInputType.values()) {
158 153
			values.put(inputType.label, inputType.id);
159
		}		
160
		
154
		}
155

  
161 156
		return values;
162 157
	}
163 158
}

Also available in: Unified diff