View | Details | Raw Unified | Return to bug 226851 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java (-5 / +49 lines)
Lines 186-192 Link Here
186
					atr.getMetaData().defaults().setLabel(desc).setReadOnly(false);
186
					atr.getMetaData().defaults().setLabel(desc).setReadOnly(false);
187
					atr.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
187
					atr.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
188
					atr.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT);
188
					atr.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT);
189
					atr.getMetaData().setReadOnly(true);
189
					switch (customField.getType()) {
190
					case 1: // Free Text
191
						atr.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT);
192
						break;
193
					case 2: // Drop Down
194
						atr.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT);
195
						break;
196
					case 3: // Multiple-Selection Box
197
						atr.getMetaData().setType(TaskAttribute.TYPE_MULTI_SELECT);
198
						break;
199
					case 4: // Large Text Box
200
						atr.getMetaData().setType(TaskAttribute.TYPE_LONG_TEXT);
201
						break;
202
					case 5: // Date/Time
203
						atr.getMetaData().setType(TaskAttribute.TYPE_DATE);
204
						break;
205
206
					default:
207
						List<String> options = customField.getOptions();
208
						if (options.size() > 0) {
209
							atr.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT);
210
						} else {
211
							atr.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT);
212
						}
213
					}
214
					atr.getMetaData().setReadOnly(false);
190
					atr.setValue(parsedText);
215
					atr.setValue(parsedText);
191
				}
216
				}
192
			} else {
217
			} else {
Lines 371-381 Link Here
371
					atr.getMetaData().defaults().setLabel(bugzillaCustomField.getDescription());
396
					atr.getMetaData().defaults().setLabel(bugzillaCustomField.getDescription());
372
					atr.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
397
					atr.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
373
398
374
					List<String> options = bugzillaCustomField.getOptions();
399
					switch (bugzillaCustomField.getType()) {
375
					if (options.size() > 0) {
400
					case 1: // Free Text
376
						atr.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT);
377
					} else {
378
						atr.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT);
401
						atr.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT);
402
						break;
403
					case 2: // Drop Down
404
						atr.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT);
405
						break;
406
					case 3: // Multiple-Selection Box
407
						atr.getMetaData().setType(TaskAttribute.TYPE_MULTI_SELECT);
408
						break;
409
					case 4: // Large Text Box
410
						atr.getMetaData().setType(TaskAttribute.TYPE_LONG_TEXT);
411
						break;
412
					case 5: // Date/Time
413
						atr.getMetaData().setType(TaskAttribute.TYPE_DATE);
414
						break;
415
416
					default:
417
						List<String> options = bugzillaCustomField.getOptions();
418
						if (options.size() > 0) {
419
							atr.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT);
420
						} else {
421
							atr.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT);
422
						}
379
					}
423
					}
380
					atr.getMetaData().setReadOnly(false);
424
					atr.getMetaData().setReadOnly(false);
381
				}
425
				}
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCustomField.java (-2 / +41 lines)
Lines 20-26 Link Here
20
 */
20
 */
21
public class BugzillaCustomField implements Serializable {
21
public class BugzillaCustomField implements Serializable {
22
22
23
	private static final long serialVersionUID = 5703683576871326128L;
23
	// old version	private static final long serialVersionUID = 5703683576871326128L;
24
	private static final long serialVersionUID = 7273310489883205486L;
24
25
25
	public static final String CUSTOM_FIELD_PREFIX = "cf_";
26
	public static final String CUSTOM_FIELD_PREFIX = "cf_";
26
27
Lines 30-38 Link Here
30
31
31
	private List<String> options = new ArrayList<String>();
32
	private List<String> options = new ArrayList<String>();
32
33
33
	public BugzillaCustomField(String description, String name) {
34
	private int type = -1;
35
36
	private String typeDesc = null;
37
38
	private boolean enterBug = false;
39
40
	public BugzillaCustomField(String description, String name, String type, String typeDesc, String enterBug) {
34
		this.description = description;
41
		this.description = description;
35
		this.name = name;
42
		this.name = name;
43
44
		if (type != null && !type.equals("")) {
45
			this.type = Integer.parseInt(type);
46
		}
47
		if (typeDesc != null && !typeDesc.equals("")) {
48
			this.typeDesc = typeDesc;
49
		}
50
		if (enterBug != null && !enterBug.equals("")) {
51
			this.enterBug = enterBug.equals("1");
52
		}
36
	}
53
	}
37
54
38
	public String getName() {
55
	public String getName() {
Lines 54-57 Link Here
54
	public void addOption(String option) {
71
	public void addOption(String option) {
55
		this.options.add(option);
72
		this.options.add(option);
56
	}
73
	}
74
75
	/*
76
	* @since 3.0.2
77
	*/
78
	public int getType() {
79
		return type;
80
	}
81
82
	/*
83
	* @since 3.0.2
84
	*/
85
	public String getTypeDesc() {
86
		return typeDesc;
87
	}
88
89
	/*
90
	* @since 3.0.2
91
	*/
92
	public boolean isEnterBug() {
93
		return enterBug;
94
	}
95
57
}
96
}
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java (-1 / +57 lines)
Lines 140-146 Link Here
140
				updateAttribute(data, BugzillaAttribute.SHORT_DESC);
140
				updateAttribute(data, BugzillaAttribute.SHORT_DESC);
141
			}
141
			}
142
		},
142
		},
143
		VERSION_CURRENT(4.5f) {
143
		VERSION_4_5(4.5f) {
144
			@Override
145
			void migrate(TaskRepository repository, TaskData data) {
146
				// migrate custom attributes
147
				for (TaskAttribute attribute : data.getRoot().getAttributes().values()) {
148
					if (attribute.getId().startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) {
149
						RepositoryConfiguration configuration = BugzillaCorePlugin.getRepositoryConfiguration(repository.getRepositoryUrl());
150
151
						BugzillaCustomField customField = null;
152
						String actName = attribute.getId();
153
						for (BugzillaCustomField bugzillaCustomField : configuration.getCustomFields()) {
154
							if (actName.equals(bugzillaCustomField.getName())) {
155
								customField = bugzillaCustomField;
156
								break;
157
							}
158
						}
159
						if (customField != null) {
160
							String desc = customField.getDescription();
161
							attribute.getMetaData().defaults().setLabel(desc).setReadOnly(false);
162
							attribute.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
163
							attribute.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT);
164
							switch (customField.getType()) {
165
							case 1: // Free Text
166
								attribute.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT);
167
								break;
168
							case 2: // Drop Down
169
								attribute.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT);
170
								break;
171
							case 3: // Multiple-Selection Box
172
								attribute.getMetaData().setType(TaskAttribute.TYPE_MULTI_SELECT);
173
								break;
174
							case 4: // Large Text Box
175
								attribute.getMetaData().setType(TaskAttribute.TYPE_LONG_TEXT);
176
								break;
177
							case 5: // Date/Time
178
								attribute.getMetaData().setType(TaskAttribute.TYPE_DATE);
179
								break;
180
181
							default:
182
								List<String> options = customField.getOptions();
183
								if (options.size() > 0) {
184
									attribute.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT);
185
								} else {
186
									attribute.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT);
187
								}
188
							}
189
							attribute.getMetaData().setReadOnly(false);
190
						}
191
					}
192
				}
193
			}
194
		},
195
		VERSION_CURRENT(4.6f) {
144
			@Override
196
			@Override
145
			void migrate(TaskRepository repository, TaskData data) {
197
			void migrate(TaskRepository repository, TaskData data) {
146
				data.setVersion(TaskDataVersion.VERSION_CURRENT.toString());
198
				data.setVersion(TaskDataVersion.VERSION_CURRENT.toString());
Lines 442-445 Link Here
442
		return new BugzillaAttributeMapper(taskRepository);
494
		return new BugzillaAttributeMapper(taskRepository);
443
	}
495
	}
444
496
497
	public static void setVersionToTaskDataVersion(TaskData data) {
498
		data.setVersion(TaskDataVersion.VERSION_CURRENT.toString());
499
	}
500
445
}
501
}
(-)src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java (-1 / +19 lines)
Lines 82-87 Link Here
82
82
83
	private static final String ELEMENT_TYPE = "type";
83
	private static final String ELEMENT_TYPE = "type";
84
84
85
	private static final String ELEMENT_TYPE_DESC = "type_desc";
86
87
	private static final String ELEMENT_ENTER_BUG = "enter_bug";
88
85
	private static final String ELEMENT_REQUESTABLE = "requestable";
89
	private static final String ELEMENT_REQUESTABLE = "requestable";
86
90
87
	private static final String ELEMENT_SPECIFICALLY_REQUESTABLE = "specifically_requestable";
91
	private static final String ELEMENT_SPECIFICALLY_REQUESTABLE = "specifically_requestable";
Lines 156-161 Link Here
156
160
157
	private String currentMultiplicable;
161
	private String currentMultiplicable;
158
162
163
	private String currentTypeDesc = "";
164
165
	private String currentEnterBug = "";
166
159
	private StringBuffer characters = new StringBuffer();
167
	private StringBuffer characters = new StringBuffer();
160
168
161
	private String about;
169
	private String about;
Lines 239-244 Link Here
239
		} else if (localName.equals(ELEMENT_FIELD)) {
247
		} else if (localName.equals(ELEMENT_FIELD)) {
240
			state = state | IN_FIELD;
248
			state = state | IN_FIELD;
241
			parseResource(attributes);
249
			parseResource(attributes);
250
			currentName = "";
251
			currentDescription = "";
252
			currentType = "";
253
			currentTypeDesc = "";
254
			currentEnterBug = "";
242
		} else if (localName.equals(ELEMENT_FLAG_TYPES)) {
255
		} else if (localName.equals(ELEMENT_FLAG_TYPES)) {
243
			state = state | IN_FLAG_TYPES;
256
			state = state | IN_FLAG_TYPES;
244
		} else if (localName.equals(ELEMENT_FLAG_TYPE)) {
257
		} else if (localName.equals(ELEMENT_FLAG_TYPE)) {
Lines 363-369 Link Here
363
			state = state & ~IN_FIELDS;
376
			state = state & ~IN_FIELDS;
364
		} else if (localName.equals(ELEMENT_FIELD)) {
377
		} else if (localName.equals(ELEMENT_FIELD)) {
365
			if (currentName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) {
378
			if (currentName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) {
366
				BugzillaCustomField newField = new BugzillaCustomField(currentDescription, currentName);
379
				BugzillaCustomField newField = new BugzillaCustomField(currentDescription, currentName, currentType,
380
						currentTypeDesc, currentEnterBug);
367
				List<String> customOptionList = customOption.get(currentName);
381
				List<String> customOptionList = customOption.get(currentName);
368
				if (customOptionList != null && !customOptionList.isEmpty()) {
382
				if (customOptionList != null && !customOptionList.isEmpty()) {
369
					newField.setOptions(customOptionList);
383
					newField.setOptions(customOptionList);
Lines 375-380 Link Here
375
			currentDescription = characters.toString();
389
			currentDescription = characters.toString();
376
		} else if (localName.equals(ELEMENT_TYPE)) {
390
		} else if (localName.equals(ELEMENT_TYPE)) {
377
			currentType = characters.toString();
391
			currentType = characters.toString();
392
		} else if (localName.equals(ELEMENT_TYPE_DESC)) {
393
			currentTypeDesc = characters.toString();
394
		} else if (localName.equals(ELEMENT_ENTER_BUG)) {
395
			currentEnterBug = characters.toString();
378
		} else if (localName.equals(ELEMENT_REQUESTABLE)) {
396
		} else if (localName.equals(ELEMENT_REQUESTABLE)) {
379
			currentRequestable = characters.toString();
397
			currentRequestable = characters.toString();
380
		} else if (localName.equals(ELEMENT_SPECIFICALLY_REQUESTABLE)) {
398
		} else if (localName.equals(ELEMENT_SPECIFICALLY_REQUESTABLE)) {

Return to bug 226851