Lines 127-134
Link Here
|
127 |
|
127 |
|
128 |
@Override |
128 |
@Override |
129 |
protected void createCustomAttributeLayout(Composite composite) { |
129 |
protected void createCustomAttributeLayout(Composite composite) { |
|
|
130 |
RepositoryTaskAttribute attribute = null; |
131 |
try { |
132 |
RepositoryConfiguration configuration = BugzillaCorePlugin.getRepositoryConfiguration(this.repository, |
133 |
false); |
134 |
if (configuration != null) { |
135 |
List<BugzillaCustomField> customFields = configuration.getCustomFields(); |
136 |
if (!customFields.isEmpty()) { |
137 |
for (BugzillaCustomField bugzillaCustomField : customFields) { |
138 |
List<String> optionList = bugzillaCustomField.getOptions(); |
139 |
attribute = this.taskData.getAttribute(bugzillaCustomField.getName()); |
140 |
if (attribute == null) { |
141 |
RepositoryTaskAttribute newattribute = new RepositoryTaskAttribute( |
142 |
bugzillaCustomField.getName(), bugzillaCustomField.getDescription(), false); |
143 |
newattribute.setReadOnly(false); |
144 |
this.taskData.addAttribute(bugzillaCustomField.getName(), newattribute); |
145 |
} |
146 |
final RepositoryTaskAttribute cfattribute = this.taskData.getAttribute(bugzillaCustomField.getName()); |
147 |
Label label = createLabel(composite, cfattribute); |
148 |
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); |
149 |
if (optionList != null && !optionList.isEmpty()) { |
150 |
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
151 |
data.horizontalSpan = 1; |
152 |
final CCombo attributeCombo = new CCombo(composite, SWT.FLAT | SWT.READ_ONLY); |
153 |
getManagedForm().getToolkit().adapt(attributeCombo, true, true); |
154 |
attributeCombo.setFont(TEXT_FONT); |
155 |
attributeCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); |
156 |
if (hasChanged(cfattribute)) { |
157 |
attributeCombo.setBackground(getColorIncoming()); |
158 |
} |
159 |
attributeCombo.setLayoutData(data); |
130 |
|
160 |
|
131 |
RepositoryTaskAttribute attribute = this.taskData.getAttribute(BugzillaReportElement.DEPENDSON.getKeyString()); |
161 |
for (String val : optionList) { |
|
|
162 |
if (val != null) { |
163 |
attributeCombo.add(val); |
164 |
} |
165 |
} |
166 |
String value = cfattribute.getValue(); |
167 |
if (value == null) { |
168 |
value = ""; |
169 |
} |
170 |
if (attributeCombo.indexOf(value) != -1) { |
171 |
attributeCombo.select(attributeCombo.indexOf(value)); |
172 |
} |
173 |
attributeCombo.clearSelection(); |
174 |
attributeCombo.addSelectionListener(new SelectionAdapter() { |
175 |
@Override |
176 |
public void widgetSelected(SelectionEvent event) { |
177 |
if (attributeCombo.getSelectionIndex() > -1) { |
178 |
String sel = attributeCombo.getItem(attributeCombo.getSelectionIndex()); |
179 |
cfattribute.setValue(sel); |
180 |
attributeChanged(cfattribute); |
181 |
attributeCombo.clearSelection(); |
182 |
} |
183 |
} |
184 |
}); |
185 |
} else { |
186 |
Text cfField = createTextField(composite, cfattribute, SWT.FLAT); |
187 |
GridDataFactory.fillDefaults().hint(135, SWT.DEFAULT).applyTo(cfField); |
188 |
} |
189 |
} |
190 |
|
191 |
getManagedForm().getToolkit().paintBordersFor(composite); |
192 |
} |
193 |
} |
194 |
} catch (CoreException e) { |
195 |
// ignore |
196 |
} |
197 |
|
198 |
attribute = this.taskData.getAttribute(BugzillaReportElement.DEPENDSON.getKeyString()); |
132 |
if (attribute != null && !attribute.isReadOnly()) { |
199 |
if (attribute != null && !attribute.isReadOnly()) { |
133 |
Label label = createLabel(composite, attribute); |
200 |
Label label = createLabel(composite, attribute); |
134 |
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); |
201 |
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); |
Lines 239-328
Link Here
|
239 |
|
306 |
|
240 |
if (taskData.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()) != null) |
307 |
if (taskData.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()) != null) |
241 |
addBugzillaTimeTracker(getManagedForm().getToolkit(), composite); |
308 |
addBugzillaTimeTracker(getManagedForm().getToolkit(), composite); |
242 |
|
|
|
243 |
try { |
244 |
RepositoryConfiguration configuration = BugzillaCorePlugin.getRepositoryConfiguration(this.repository, |
245 |
false); |
246 |
if (configuration != null) { |
247 |
List<BugzillaCustomField> customFields = configuration.getCustomFields(); |
248 |
if (!customFields.isEmpty()) { |
249 |
Section cfSection = getManagedForm().getToolkit().createSection(composite, |
250 |
ExpandableComposite.SHORT_TITLE_BAR); |
251 |
cfSection.setText(LABEL_CUSTOM_FIELD); |
252 |
GridLayout gl = new GridLayout(); |
253 |
GridData gd = new GridData(SWT.FILL, SWT.NONE, false, false); |
254 |
gd.horizontalSpan = 4; |
255 |
cfSection.setLayout(gl); |
256 |
cfSection.setLayoutData(gd); |
257 |
|
258 |
Composite cfComposite = getManagedForm().getToolkit().createComposite(cfSection); |
259 |
gl = new GridLayout(4, false); |
260 |
cfComposite.setLayout(gl); |
261 |
gd = new GridData(); |
262 |
gd.horizontalSpan = 5; |
263 |
cfComposite.setLayoutData(gd); |
264 |
for (BugzillaCustomField bugzillaCustomField : customFields) { |
265 |
List<String> optionList = bugzillaCustomField.getOptions(); |
266 |
attribute = this.taskData.getAttribute(bugzillaCustomField.getName()); |
267 |
if (attribute == null) { |
268 |
RepositoryTaskAttribute newattribute = new RepositoryTaskAttribute( |
269 |
bugzillaCustomField.getName(), bugzillaCustomField.getDescription(), false); |
270 |
newattribute.setReadOnly(false); |
271 |
this.taskData.addAttribute(bugzillaCustomField.getName(), newattribute); |
272 |
} |
273 |
final RepositoryTaskAttribute cfattribute = this.taskData.getAttribute(bugzillaCustomField.getName()); |
274 |
Label label = createLabel(cfComposite, cfattribute); |
275 |
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); |
276 |
if (optionList != null && !optionList.isEmpty()) { |
277 |
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
278 |
data.horizontalSpan = 1; |
279 |
final CCombo attributeCombo = new CCombo(cfComposite, SWT.FLAT | SWT.READ_ONLY); |
280 |
getManagedForm().getToolkit().adapt(attributeCombo, true, true); |
281 |
attributeCombo.setFont(TEXT_FONT); |
282 |
attributeCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); |
283 |
if (hasChanged(cfattribute)) { |
284 |
attributeCombo.setBackground(getColorIncoming()); |
285 |
} |
286 |
attributeCombo.setLayoutData(data); |
287 |
|
288 |
for (String val : optionList) { |
289 |
if (val != null) { |
290 |
attributeCombo.add(val); |
291 |
} |
292 |
} |
293 |
String value = cfattribute.getValue(); |
294 |
if (value == null) { |
295 |
value = ""; |
296 |
} |
297 |
if (attributeCombo.indexOf(value) != -1) { |
298 |
attributeCombo.select(attributeCombo.indexOf(value)); |
299 |
} |
300 |
attributeCombo.clearSelection(); |
301 |
attributeCombo.addSelectionListener(new SelectionAdapter() { |
302 |
@Override |
303 |
public void widgetSelected(SelectionEvent event) { |
304 |
if (attributeCombo.getSelectionIndex() > -1) { |
305 |
String sel = attributeCombo.getItem(attributeCombo.getSelectionIndex()); |
306 |
cfattribute.setValue(sel); |
307 |
attributeChanged(cfattribute); |
308 |
attributeCombo.clearSelection(); |
309 |
} |
310 |
} |
311 |
}); |
312 |
} else { |
313 |
Text cfField = createTextField(cfComposite, cfattribute, SWT.FLAT); |
314 |
GridDataFactory.fillDefaults().hint(135, SWT.DEFAULT).applyTo(cfField); |
315 |
} |
316 |
} |
317 |
|
318 |
getManagedForm().getToolkit().paintBordersFor(cfComposite); |
319 |
cfSection.setClient(cfComposite); |
320 |
} |
321 |
} |
322 |
} catch (CoreException e) { |
323 |
// ignore |
324 |
} |
325 |
|
326 |
} |
309 |
} |
327 |
|
310 |
|
328 |
private boolean hasCustomAttributeChanges() { |
311 |
private boolean hasCustomAttributeChanges() { |