Lines 24-31
Link Here
|
24 |
import org.eclipse.jface.layout.GridLayoutFactory; |
24 |
import org.eclipse.jface.layout.GridLayoutFactory; |
25 |
import org.eclipse.jface.viewers.ILabelProvider; |
25 |
import org.eclipse.jface.viewers.ILabelProvider; |
26 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; |
26 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; |
|
|
27 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField; |
27 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaReportElement; |
28 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaReportElement; |
28 |
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; |
29 |
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_OPERATION; |
31 |
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_OPERATION; |
30 |
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin; |
32 |
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin; |
31 |
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages; |
33 |
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages; |
Lines 39-44
Link Here
|
39 |
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor; |
41 |
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor; |
40 |
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; |
42 |
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; |
41 |
import org.eclipse.swt.SWT; |
43 |
import org.eclipse.swt.SWT; |
|
|
44 |
import org.eclipse.swt.custom.CCombo; |
42 |
import org.eclipse.swt.events.ModifyEvent; |
45 |
import org.eclipse.swt.events.ModifyEvent; |
43 |
import org.eclipse.swt.events.ModifyListener; |
46 |
import org.eclipse.swt.events.ModifyListener; |
44 |
import org.eclipse.swt.events.SelectionAdapter; |
47 |
import org.eclipse.swt.events.SelectionAdapter; |
Lines 76-81
Link Here
|
76 |
|
79 |
|
77 |
private static final String LABEL_TIME_TRACKING = "Bugzilla Time Tracking"; |
80 |
private static final String LABEL_TIME_TRACKING = "Bugzilla Time Tracking"; |
78 |
|
81 |
|
|
|
82 |
private static final String LABEL_CUSTOM_FIELD = "Custom Fields"; |
83 |
|
79 |
protected Text keywordsText; |
84 |
protected Text keywordsText; |
80 |
|
85 |
|
81 |
protected Text estimateText; |
86 |
protected Text estimateText; |
Lines 207-212
Link Here
|
207 |
if (taskData.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()) != null) |
212 |
if (taskData.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()) != null) |
208 |
addBugzillaTimeTracker(getManagedForm().getToolkit(), composite); |
213 |
addBugzillaTimeTracker(getManagedForm().getToolkit(), composite); |
209 |
|
214 |
|
|
|
215 |
try { |
216 |
RepositoryConfiguration configuration = BugzillaCorePlugin.getRepositoryConfiguration(this.repository, |
217 |
false); |
218 |
if (configuration != null) { |
219 |
List<BugzillaCustomField> customFields = configuration.getCustomFields(); |
220 |
if (!customFields.isEmpty()) { |
221 |
Section cfSection = getManagedForm().getToolkit().createSection(composite, |
222 |
ExpandableComposite.SHORT_TITLE_BAR); |
223 |
cfSection.setText(LABEL_CUSTOM_FIELD); |
224 |
GridLayout gl = new GridLayout(); |
225 |
GridData gd = new GridData(SWT.FILL, SWT.NONE, false, false); |
226 |
gd.horizontalSpan = 4; |
227 |
cfSection.setLayout(gl); |
228 |
cfSection.setLayoutData(gd); |
229 |
|
230 |
Composite cfComposite = getManagedForm().getToolkit().createComposite(cfSection); |
231 |
gl = new GridLayout(4, false); |
232 |
cfComposite.setLayout(gl); |
233 |
gd = new GridData(); |
234 |
gd.horizontalSpan = 5; |
235 |
cfComposite.setLayoutData(gd); |
236 |
for (BugzillaCustomField bugzillaCustomField : customFields) { |
237 |
List<String> optionList = bugzillaCustomField.getOptions(); |
238 |
attribute = this.taskData.getAttribute(bugzillaCustomField.getName()); |
239 |
if (attribute == null) { |
240 |
RepositoryTaskAttribute newattribute = new RepositoryTaskAttribute( |
241 |
bugzillaCustomField.getName(), bugzillaCustomField.getDescription(), false); |
242 |
newattribute.setReadOnly(false); |
243 |
this.taskData.addAttribute(bugzillaCustomField.getName(), newattribute); |
244 |
} |
245 |
final RepositoryTaskAttribute cfattribute = this.taskData.getAttribute(bugzillaCustomField.getName()); |
246 |
Label label = createLabel(cfComposite, cfattribute); |
247 |
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); |
248 |
if (optionList != null && !optionList.isEmpty()) { |
249 |
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
250 |
data.horizontalSpan = 1; |
251 |
final CCombo attributeCombo = new CCombo(cfComposite, SWT.FLAT | SWT.READ_ONLY); |
252 |
getManagedForm().getToolkit().adapt(attributeCombo, true, true); |
253 |
attributeCombo.setFont(TEXT_FONT); |
254 |
attributeCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); |
255 |
if (hasChanged(cfattribute)) { |
256 |
attributeCombo.setBackground(getColorIncoming()); |
257 |
} |
258 |
attributeCombo.setLayoutData(data); |
259 |
|
260 |
for (String val : optionList) { |
261 |
if (val != null) { |
262 |
attributeCombo.add(val); |
263 |
} |
264 |
} |
265 |
String value = cfattribute.getValue(); |
266 |
if (value == null) { |
267 |
value = ""; |
268 |
} |
269 |
if (attributeCombo.indexOf(value) != -1) { |
270 |
attributeCombo.select(attributeCombo.indexOf(value)); |
271 |
} |
272 |
attributeCombo.clearSelection(); |
273 |
attributeCombo.addSelectionListener(new SelectionAdapter() { |
274 |
@Override |
275 |
public void widgetSelected(SelectionEvent event) { |
276 |
if (attributeCombo.getSelectionIndex() > -1) { |
277 |
String sel = attributeCombo.getItem(attributeCombo.getSelectionIndex()); |
278 |
cfattribute.setValue(sel); |
279 |
attributeChanged(cfattribute); |
280 |
attributeCombo.clearSelection(); |
281 |
} |
282 |
} |
283 |
}); |
284 |
} else { |
285 |
Text cfField = createTextField(cfComposite, cfattribute, SWT.FLAT); |
286 |
GridDataFactory.fillDefaults().hint(135, SWT.DEFAULT).applyTo(cfField); |
287 |
} |
288 |
} |
289 |
|
290 |
getManagedForm().getToolkit().paintBordersFor(cfComposite); |
291 |
cfSection.setClient(cfComposite); |
292 |
} |
293 |
} |
294 |
} catch (CoreException e) { |
295 |
// ignore |
296 |
} |
297 |
|
210 |
} |
298 |
} |
211 |
|
299 |
|
212 |
private boolean hasCustomAttributeChanges() { |
300 |
private boolean hasCustomAttributeChanges() { |