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

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/SingleSelectionAttributeEditor.java (-26 / +48 lines)
Lines 34-39 Link Here
34
34
35
	private CCombo combo;
35
	private CCombo combo;
36
36
37
	private boolean ignoreNotification;
38
39
	private Text text;
40
37
	public SingleSelectionAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
41
	public SingleSelectionAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
38
		super(manager, taskAttribute);
42
		super(manager, taskAttribute);
39
	}
43
	}
Lines 41-83 Link Here
41
	@Override
45
	@Override
42
	public void createControl(Composite parent, FormToolkit toolkit) {
46
	public void createControl(Composite parent, FormToolkit toolkit) {
43
		if (isReadOnly()) {
47
		if (isReadOnly()) {
44
			Text text = new Text(parent, SWT.FLAT | SWT.READ_ONLY);
48
			text = new Text(parent, SWT.FLAT | SWT.READ_ONLY);
45
			text.setFont(EditorUtil.TEXT_FONT);
49
			text.setFont(EditorUtil.TEXT_FONT);
46
			toolkit.adapt(text, false, false);
50
			toolkit.adapt(text, false, false);
47
			text.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
51
			text.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
48
			String label = getValueLabel();
52
			refresh();
49
			if ("".equals(label)) { //$NON-NLS-1$
50
				// if set to the empty string the label will use 64px on GTK 
51
				text.setText(" "); //$NON-NLS-1$
52
			} else {
53
				text.setText(label);
54
			}
55
			setControl(text);
53
			setControl(text);
56
		} else {
54
		} else {
57
			combo = new CCombo(parent, SWT.FLAT | SWT.READ_ONLY);
55
			combo = new CCombo(parent, SWT.FLAT | SWT.READ_ONLY);
58
			toolkit.adapt(combo, false, false);
56
			toolkit.adapt(combo, false, false);
59
			combo.setFont(EditorUtil.TEXT_FONT);
57
			combo.setFont(EditorUtil.TEXT_FONT);
60
			combo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
58
			combo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
61
59
			refresh();
62
			Map<String, String> labelByValue = getAttributeMapper().getOptions(getTaskAttribute());
63
			if (labelByValue != null) {
64
				values = labelByValue.keySet().toArray(new String[0]);
65
				for (String value : values) {
66
					combo.add(labelByValue.get(value));
67
				}
68
			}
69
70
			select(getValue(), getValueLabel());
71
72
			if (values != null) {
60
			if (values != null) {
73
				combo.addSelectionListener(new SelectionAdapter() {
61
				combo.addSelectionListener(new SelectionAdapter() {
74
					@Override
62
					@Override
75
					public void widgetSelected(SelectionEvent event) {
63
					public void widgetSelected(SelectionEvent event) {
76
						int index = combo.getSelectionIndex();
64
						if (!ignoreNotification) {
77
						if (index > -1) {
65
							int index = combo.getSelectionIndex();
78
							Assert.isNotNull(values);
66
							if (index > -1) {
79
							Assert.isLegal(index >= 0 && index <= values.length - 1);
67
								Assert.isNotNull(values);
80
							setValue(values[index]);
68
								Assert.isLegal(index >= 0 && index <= values.length - 1);
69
								setValue(values[index]);
70
							}
81
						}
71
						}
82
					}
72
					}
83
				});
73
				});
Lines 109-116 Link Here
109
	}
99
	}
110
100
111
	public void setValue(String value) {
101
	public void setValue(String value) {
112
		getAttributeMapper().setValue(getTaskAttribute(), value);
102
		String oldValue = getAttributeMapper().getValue(getTaskAttribute());
113
		attributeChanged();
103
		if (!oldValue.equals(value)) {
104
			getAttributeMapper().setValue(getTaskAttribute(), value);
105
			attributeChanged();
106
		}
114
	}
107
	}
115
108
116
	void selectDefaultValue() {
109
	void selectDefaultValue() {
Lines 120-123 Link Here
120
		}
113
		}
121
	}
114
	}
122
115
116
	@Override
117
	public void refresh() {
118
		try {
119
			ignoreNotification = true;
120
			if (text != null) {
121
				String label = getValueLabel();
122
				if ("".equals(label)) { //$NON-NLS-1$
123
					// if set to the empty string the label will use 64px on GTK 
124
					text.setText(" "); //$NON-NLS-1$
125
				} else {
126
					text.setText(label);
127
				}
128
			} else {
129
				combo.removeAll();
130
				Map<String, String> labelByValue = getAttributeMapper().getOptions(getTaskAttribute());
131
				if (labelByValue != null) {
132
					values = labelByValue.keySet().toArray(new String[0]);
133
					for (String value : values) {
134
						combo.add(labelByValue.get(value));
135
					}
136
				}
137
				select(getValue(), getValueLabel());
138
				combo.redraw();
139
			}
140
		} finally {
141
			ignoreNotification = false;
142
		}
143
	}
144
123
}
145
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/BooleanAttributeEditor.java (-3 / +17 lines)
Lines 25-30 Link Here
25
 * @author Steffen Pingel
25
 * @author Steffen Pingel
26
 */
26
 */
27
public class BooleanAttributeEditor extends AbstractAttributeEditor {
27
public class BooleanAttributeEditor extends AbstractAttributeEditor {
28
	private Button button;
29
30
	private boolean ignoreNotification;
28
31
29
	public BooleanAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
32
	public BooleanAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
30
		super(manager, taskAttribute);
33
		super(manager, taskAttribute);
Lines 32-46 Link Here
32
35
33
	@Override
36
	@Override
34
	public void createControl(Composite parent, FormToolkit toolkit) {
37
	public void createControl(Composite parent, FormToolkit toolkit) {
35
		final Button button = toolkit.createButton(parent, super.getLabel(), SWT.CHECK);
38
		button = toolkit.createButton(parent, super.getLabel(), SWT.CHECK);
36
		button.setEnabled(!isReadOnly());
39
		button.setEnabled(!isReadOnly());
37
		button.setSelection(getValue());
38
		button.addSelectionListener(new SelectionAdapter() {
40
		button.addSelectionListener(new SelectionAdapter() {
39
			@Override
41
			@Override
40
			public void widgetSelected(SelectionEvent e) {
42
			public void widgetSelected(SelectionEvent e) {
41
				setValue(button.getSelection());
43
				if (!ignoreNotification) {
44
					setValue(button.getSelection());
45
				}
42
			}
46
			}
43
		});
47
		});
48
		refresh();
44
		setControl(button);
49
		setControl(button);
45
	}
50
	}
46
51
Lines 58-61 Link Here
58
		attributeChanged();
63
		attributeChanged();
59
	}
64
	}
60
65
66
	@Override
67
	public void refresh() {
68
		try {
69
			ignoreNotification = true;
70
			button.setSelection(getValue());
71
		} finally {
72
			ignoreNotification = false;
73
		}
74
	}
61
}
75
}
(-)src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java (+15 lines)
Lines 213-216 Link Here
213
		this.readOnly = readOnly;
213
		this.readOnly = readOnly;
214
	}
214
	}
215
215
216
	/**
217
	 * Refreshes the state of the widget from the data model. The default implementation throws
218
	 * <code>UnsupportedOperationException</code>.
219
	 * 
220
	 * <p>
221
	 * Subclasses should overwrite this method.
222
	 * 
223
	 * @since 3.1
224
	 * @throws UnsupportedOperationException
225
	 *             if this method is not supported by the editor
226
	 */
227
	public void refresh() {
228
		throw new UnsupportedOperationException();
229
	}
230
216
}
231
}
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java (-2 / +168 lines)
Lines 11-27 Link Here
11
11
12
package org.eclipse.mylyn.internal.bugzilla.ui.editor;
12
package org.eclipse.mylyn.internal.bugzilla.ui.editor;
13
13
14
import java.util.Collections;
15
import java.util.HashMap;
16
import java.util.List;
17
import java.util.Map;
14
import java.util.Set;
18
import java.util.Set;
15
19
16
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.NullProgressMonitor;
17
import org.eclipse.jface.dialogs.IMessageProvider;
23
import org.eclipse.jface.dialogs.IMessageProvider;
24
import org.eclipse.mylyn.commons.core.StatusHandler;
18
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
25
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
19
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
26
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
20
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField;
27
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField;
28
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler;
21
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
29
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
30
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
31
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin;
32
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
22
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
33
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
23
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData;
34
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData;
24
import org.eclipse.mylyn.tasks.core.data.TaskData;
35
import org.eclipse.mylyn.tasks.core.data.TaskData;
36
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
37
import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent;
38
import org.eclipse.mylyn.tasks.core.data.TaskDataModelListener;
25
import org.eclipse.mylyn.tasks.ui.TasksUi;
39
import org.eclipse.mylyn.tasks.ui.TasksUi;
26
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
40
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
27
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
41
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
Lines 29-34 Link Here
29
import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory;
43
import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory;
30
import org.eclipse.mylyn.tasks.ui.editors.LayoutHint;
44
import org.eclipse.mylyn.tasks.ui.editors.LayoutHint;
31
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
45
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
46
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
32
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor;
47
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor;
33
48
34
/**
49
/**
Lines 41-48 Link Here
41
56
42
	public static final String ID_PART_BUGZILLA_FLAGS = "org.eclipse.mylyn.bugzilla.ui.editors.part.flags"; //$NON-NLS-1$
57
	public static final String ID_PART_BUGZILLA_FLAGS = "org.eclipse.mylyn.bugzilla.ui.editors.part.flags"; //$NON-NLS-1$
43
58
59
	private final Map<TaskAttribute, AbstractAttributeEditor> attributeEditorMap;
60
61
	private TaskDataModelListener productListener;
62
44
	public BugzillaTaskEditorPage(TaskEditor editor) {
63
	public BugzillaTaskEditorPage(TaskEditor editor) {
45
		super(editor, BugzillaCorePlugin.CONNECTOR_KIND);
64
		this(editor, BugzillaCorePlugin.CONNECTOR_KIND);
46
	}
65
	}
47
66
48
	/**
67
	/**
Lines 53-58 Link Here
53
	 */
72
	 */
54
	public BugzillaTaskEditorPage(TaskEditor editor, String connectorKind) {
73
	public BugzillaTaskEditorPage(TaskEditor editor, String connectorKind) {
55
		super(editor, connectorKind);
74
		super(editor, connectorKind);
75
		this.attributeEditorMap = new HashMap<TaskAttribute, AbstractAttributeEditor>();
56
	}
76
	}
57
77
58
	@Override
78
	@Override
Lines 138-144 Link Here
138
						}
158
						}
139
					});
159
					});
140
				}
160
				}
141
161
				BugzillaTaskEditorPage.this.addToAttributeEditorMap(taskAttribute, editor);
142
				return editor;
162
				return editor;
143
			}
163
			}
144
		};
164
		};
Lines 186-189 Link Here
186
		super.doSubmit();
206
		super.doSubmit();
187
	}
207
	}
188
208
209
	@Override
210
	protected void createParts() {
211
		attributeEditorMap.clear();
212
		super.createParts();
213
	}
214
215
	@Override
216
	protected TaskDataModel createModel(TaskEditorInput input) throws CoreException {
217
		TaskDataModel model = super.createModel(input);
218
		productListener = new ProductSelectionListener();
219
		model.addModelListener(productListener);
220
		return model;
221
	}
222
223
	/**
224
	 * @since 3.1
225
	 */
226
	public void addToAttributeEditorMap(TaskAttribute attribute, AbstractAttributeEditor editor) {
227
		if (attributeEditorMap.containsKey(attribute)) {
228
			attributeEditorMap.remove(attribute);
229
		}
230
		attributeEditorMap.put(attribute, editor);
231
	}
232
233
	/**
234
	 * @since 3.1
235
	 */
236
	public AbstractAttributeEditor getEditorForAttribute(TaskAttribute attribute) {
237
		return attributeEditorMap.get(attribute);
238
	}
239
240
	/**
241
	 * @since 3.1
242
	 */
243
	public Map<TaskAttribute, AbstractAttributeEditor> getAttributeEditorMap() {
244
		return attributeEditorMap;
245
	}
246
247
	/**
248
	 * @since 3.1
249
	 */
250
	public void refresh() {
251
		try {
252
			showEditorBusy(true);
253
			for (AbstractAttributeEditor abstractAttributeEditor : attributeEditorMap.values()) {
254
				try {
255
					abstractAttributeEditor.refresh();
256
				} catch (UnsupportedOperationException e) {
257
					// ignore
258
				}
259
			}
260
		} finally {
261
			showEditorBusy(false);
262
		}
263
	}
264
265
	public void refresh(TaskAttribute attributeComponent) {
266
		AbstractAttributeEditor editor = getEditorForAttribute(attributeComponent);
267
		if (editor != null) {
268
			try {
269
				editor.refresh();
270
			} catch (UnsupportedOperationException e) {
271
				// ignore
272
			}
273
		}
274
	}
275
276
	private class ProductSelectionListener extends TaskDataModelListener {
277
		@Override
278
		public void attributeChanged(TaskDataModelEvent event) {
279
			TaskAttribute taskAttribute = event.getTaskAttribute();
280
			if (taskAttribute != null) {
281
				if (taskAttribute.getId().equals(BugzillaAttribute.PRODUCT.getKey())) {
282
					RepositoryConfiguration repositoryConfiguration = null;
283
					try {
284
						repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(
285
								getModel().getTaskRepository(), false, new NullProgressMonitor());
286
					} catch (CoreException e) {
287
						StatusHandler.log(new RepositoryStatus(getTaskRepository(), IStatus.ERROR,
288
								BugzillaUiPlugin.ID_PLUGIN, 0, "Failed to obtain repository configuration", e)); //$NON-NLS-1$
289
						getTaskEditor().setMessage("Problem occured when updating attributes", IMessageProvider.ERROR); //$NON-NLS-1$
290
						return;
291
					}
292
293
					TaskAttribute attributeComponent = taskAttribute.getTaskData().getRoot().getMappedAttribute(
294
							BugzillaAttribute.COMPONENT.getKey());
295
					if (attributeComponent != null) {
296
						List<String> optionValues = repositoryConfiguration.getComponents(taskAttribute.getValue());
297
						Collections.sort(optionValues);
298
						attributeComponent.clearOptions();
299
						for (String option : optionValues) {
300
							attributeComponent.putOption(option, option);
301
						}
302
						if (optionValues.size() == 1) {
303
							attributeComponent.setValue(optionValues.get(0));
304
						} else {
305
							attributeComponent.setValue(""); //$NON-NLS-1$
306
						}
307
						refresh(attributeComponent);
308
					}
309
310
					TaskAttribute attributeTargetMilestone = taskAttribute.getTaskData().getRoot().getMappedAttribute(
311
							BugzillaAttribute.TARGET_MILESTONE.getKey());
312
					if (attributeTargetMilestone != null) {
313
						List<String> optionValues = repositoryConfiguration.getTargetMilestones(taskAttribute.getValue());
314
						Collections.sort(optionValues);
315
						attributeTargetMilestone.clearOptions();
316
						for (String option : optionValues) {
317
							attributeTargetMilestone.putOption(option, option);
318
						}
319
						if (optionValues.size() == 1) {
320
							attributeTargetMilestone.setValue(optionValues.get(0));
321
						} else {
322
							attributeTargetMilestone.setValue("---"); //$NON-NLS-1$
323
						}
324
						refresh(attributeTargetMilestone);
325
					}
326
327
					TaskAttribute attributeDefaultAssignee = taskAttribute.getTaskData().getRoot().getMappedAttribute(
328
							BugzillaAttribute.SET_DEFAULT_ASSIGNEE.getKey());
329
					if (attributeDefaultAssignee != null) {
330
						attributeDefaultAssignee.setValue("1"); //$NON-NLS-1$
331
						refresh(attributeDefaultAssignee);
332
					}
333
334
/*
335
 * 					add confirm_product_change to avoid verification page on submit
336
 */
337
					TaskAttribute attributeConfirmeProductChange = taskAttribute.getTaskData()
338
							.getRoot()
339
							.getMappedAttribute(BugzillaAttribute.CONFIRM_PRODUCT_CHANGE.getKey());
340
					if (attributeConfirmeProductChange == null) {
341
//						attributeConfirmeProductChange = taskAttribute.getTaskData().getRoot().createAttribute(
342
//								BugzillaAttribute.CONFIRM_PRODUCT_CHANGE.getKey());
343
						BugzillaTaskDataHandler.createAttribute(taskAttribute.getTaskData().getRoot(),
344
								BugzillaAttribute.CONFIRM_PRODUCT_CHANGE);
345
						attributeConfirmeProductChange = taskAttribute.getTaskData().getRoot().getMappedAttribute(
346
								BugzillaAttribute.CONFIRM_PRODUCT_CHANGE.getKey());
347
					}
348
					if (attributeConfirmeProductChange != null) {
349
						attributeConfirmeProductChange.setValue("1");
350
					}
351
				}
352
			}
353
		}
354
	}
189
}
355
}
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttribute.java (-2 / +5 lines)
Lines 109-115 Link Here
109
109
110
	PRIORITY(Messages.BugzillaAttribute_Priority, "priority", TaskAttribute.TYPE_SINGLE_SELECT, false, false), //$NON-NLS-1$
110
	PRIORITY(Messages.BugzillaAttribute_Priority, "priority", TaskAttribute.TYPE_SINGLE_SELECT, false, false), //$NON-NLS-1$
111
111
112
	PRODUCT(Messages.BugzillaAttribute_Product, "product", TaskAttribute.TYPE_SHORT_TEXT, false, true), //$NON-NLS-1$
112
	PRODUCT(Messages.BugzillaAttribute_Product, "product", TaskAttribute.TYPE_SINGLE_SELECT, false, false), //$NON-NLS-1$
113
113
114
	REP_PLATFORM(Messages.BugzillaAttribute_Platform, "rep_platform", TaskAttribute.TYPE_SINGLE_SELECT, false, false), //$NON-NLS-1$
114
	REP_PLATFORM(Messages.BugzillaAttribute_Platform, "rep_platform", TaskAttribute.TYPE_SINGLE_SELECT, false, false), //$NON-NLS-1$
115
115
Lines 164-169 Link Here
164
164
165
	NEW_COMMENT(Messages.BugzillaAttribute_new_comment, "new_comment", TaskAttribute.TYPE_LONG_RICH_TEXT, true, false), //$NON-NLS-1$
165
	NEW_COMMENT(Messages.BugzillaAttribute_new_comment, "new_comment", TaskAttribute.TYPE_LONG_RICH_TEXT, true, false), //$NON-NLS-1$
166
166
167
	CONFIRM_PRODUCT_CHANGE(Messages.BugzillaAttribute_confirm_product_change,
168
			"confirm_product_change", TaskAttribute.TYPE_BOOLEAN, true, false), //$NON-NLS-1$
169
167
	// Used by search engine
170
	// Used by search engine
168
	LI(Messages.BugzillaAttribute_used_by_search_engine_li, "li", null, true, false), //$NON-NLS-1$
171
	LI(Messages.BugzillaAttribute_used_by_search_engine_li, "li", null, true, false), //$NON-NLS-1$
169
172
Lines 179-185 Link Here
179
182
180
	INSTALLATION(Messages.BugzillaAttribute_used_by_search_engine_installation, "installation", null, false, false), //$NON-NLS-1$
183
	INSTALLATION(Messages.BugzillaAttribute_used_by_search_engine_installation, "installation", null, false, false), //$NON-NLS-1$
181
184
182
	BUGS(Messages.BugzillaAttribute_used_by_search_engine_bugs, "bugs", null, false, false); //$NON-NLS-1$
185
	BUGS(Messages.BugzillaAttribute_used_by_search_engine_bugs, "bugs", null, false, false);
183
186
184
	private final boolean isHidden;
187
	private final boolean isHidden;
185
188
(-)src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties (+1 lines)
Lines 31-36 Link Here
31
BugzillaAttribute_Keywords=Keywords:
31
BugzillaAttribute_Keywords=Keywords:
32
BugzillaAttribute_Modified=Modified:
32
BugzillaAttribute_Modified=Modified:
33
BugzillaAttribute_new_comment=new comment
33
BugzillaAttribute_new_comment=new comment
34
BugzillaAttribute_confirm_product_change=Confirm Product Change(never shown in the UI)
34
BugzillaAttribute_Number_of_comments=Number of comments
35
BugzillaAttribute_Number_of_comments=Number of comments
35
BugzillaAttribute_Obsolete=Obsolete
36
BugzillaAttribute_Obsolete=Obsolete
36
BugzillaAttribute_open_status_values=open status values
37
BugzillaAttribute_open_status_values=open status values
(-)src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java (+2 lines)
Lines 91-96 Link Here
91
91
92
	public static String BugzillaAttribute_new_comment;
92
	public static String BugzillaAttribute_new_comment;
93
93
94
	public static String BugzillaAttribute_confirm_product_change;
95
94
	public static String BugzillaAttribute_Number_of_comments;
96
	public static String BugzillaAttribute_Number_of_comments;
95
97
96
	public static String BugzillaAttribute_Obsolete;
98
	public static String BugzillaAttribute_Obsolete;

Return to bug 166595