### Eclipse Workspace Patch 1.0 #P org.eclipse.mylyn.tasks.ui Index: src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java,v retrieving revision 1.301 diff -u -r1.301 AbstractRepositoryTaskEditor.java --- src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java 23 Apr 2008 05:54:30 -0000 1.301 +++ src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java 24 Apr 2008 20:08:02 -0000 @@ -245,7 +245,7 @@ protected static final String CONTEXT_MENU_ID = "#MylynRepositoryEditor"; - private FormToolkit toolkit; + protected FormToolkit toolkit; private ScrolledForm form; #P org.eclipse.mylyn.bugzilla.ui Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java,v retrieving revision 1.103 diff -u -r1.103 BugzillaTaskEditor.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java 14 Apr 2008 04:25:43 -0000 1.103 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java 24 Apr 2008 20:08:03 -0000 @@ -86,7 +86,7 @@ private static final String LABEL_TIME_TRACKING = "Bugzilla Time Tracking"; private static final String LABEL_CUSTOM_FIELD = "Custom Fields"; - + protected Text keywordsText; protected Text estimateText; @@ -120,7 +120,7 @@ // config.setRightImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT)); // compareInput = new BugzillaCompareInput(config); } - + @Override protected boolean supportsCommentSort() { return false; @@ -129,15 +129,19 @@ @Override protected void createCustomAttributeLayout(Composite composite) { RepositoryTaskAttribute attribute = null; + int customFieldsAnz = 0; try { RepositoryConfiguration configuration = BugzillaCorePlugin.getRepositoryConfiguration(this.repository, false, new NullProgressMonitor()); - + if (configuration != null) { List customFields = configuration.getCustomFields(); if (!customFields.isEmpty()) { for (BugzillaCustomField bugzillaCustomField : customFields) { - List optionList = bugzillaCustomField.getOptions(); + if (!bugzillaCustomField.isEnterBug()) { + continue; + } + customFieldsAnz++; attribute = this.taskData.getAttribute(bugzillaCustomField.getName()); if (attribute == null) { RepositoryTaskAttribute newattribute = new RepositoryTaskAttribute( @@ -148,48 +152,216 @@ final RepositoryTaskAttribute cfattribute = this.taskData.getAttribute(bugzillaCustomField.getName()); Label label = createLabel(composite, cfattribute); GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); - if (optionList != null && !optionList.isEmpty()) { - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.horizontalSpan = 1; - final CCombo attributeCombo = new CCombo(composite, SWT.FLAT | SWT.READ_ONLY); - getManagedForm().getToolkit().adapt(attributeCombo, true, true); - attributeCombo.setFont(TEXT_FONT); - attributeCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + + switch (bugzillaCustomField.getType()) { + case 1: // Free Text + Text freeText = createTextField(composite, cfattribute, SWT.FLAT); + GridData freeTextData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + freeTextData.horizontalSpan = 1; + freeTextData.verticalSpan = 1; + if (hasChanged(cfattribute)) { + freeText.setBackground(getColorIncoming()); + } + freeText.setLayoutData(freeTextData); + break; + case 2: // Drop Down + List optionList = bugzillaCustomField.getOptions(); + GridData dropDownData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + dropDownData.horizontalSpan = 1; + final CCombo dropDown = new CCombo(composite, SWT.FLAT | SWT.READ_ONLY); + getManagedForm().getToolkit().adapt(dropDown, true, true); + dropDown.setFont(TEXT_FONT); + dropDown.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); if (hasChanged(cfattribute)) { - attributeCombo.setBackground(getColorIncoming()); + dropDown.setBackground(getColorIncoming()); } - attributeCombo.setLayoutData(data); + dropDown.setLayoutData(dropDownData); for (String val : optionList) { if (val != null) { - attributeCombo.add(val); + dropDown.add(val); } } String value = cfattribute.getValue(); if (value == null) { value = ""; } - if (attributeCombo.indexOf(value) != -1) { - attributeCombo.select(attributeCombo.indexOf(value)); + if (dropDown.indexOf(value) != -1) { + dropDown.select(dropDown.indexOf(value)); } - attributeCombo.clearSelection(); - attributeCombo.addSelectionListener(new SelectionAdapter() { + dropDown.clearSelection(); + dropDown.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - if (attributeCombo.getSelectionIndex() > -1) { - String sel = attributeCombo.getItem(attributeCombo.getSelectionIndex()); + if (dropDown.getSelectionIndex() > -1) { + String sel = dropDown.getItem(dropDown.getSelectionIndex()); cfattribute.setValue(sel); attributeChanged(cfattribute); - attributeCombo.clearSelection(); + dropDown.clearSelection(); } } }); - } else { - Text cfField = createTextField(composite, cfattribute, SWT.FLAT); - GridDataFactory.fillDefaults().hint(135, SWT.DEFAULT).applyTo(cfField); + break; + case 3: // Multiple-Selection Box + final org.eclipse.swt.widgets.List multiSelect; + List multiSelectOptionList = bugzillaCustomField.getOptions(); + multiSelect = new org.eclipse.swt.widgets.List(composite, SWT.MULTI | SWT.V_SCROLL);// SWT.BORDER + multiSelect.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + multiSelect.setFont(TEXT_FONT); + GridData multiSelectData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + multiSelectData.horizontalSpan = 1; + multiSelectData.heightHint = 95; + multiSelect.setLayoutData(multiSelectData); + if (hasChanged(cfattribute)) { + multiSelect.setBackground(getColorIncoming()); + } + if (multiSelectOptionList != null) { + for (String cc : multiSelectOptionList) { + multiSelect.add(cc); + } + } + java.util.List multiSelectValues = cfattribute.getValues(); + if (multiSelectValues != null) { + for (String item : multiSelectValues) { + int i = multiSelect.indexOf(item); + if (i != -1) { + multiSelect.select(i); + } + } + } + + multiSelect.addSelectionListener(new SelectionListener() { + + public void widgetSelected(SelectionEvent e) { + for (String selected : multiSelect.getItems()) { + int index = multiSelect.indexOf(selected); + if (multiSelect.isSelected(index)) { + List remove = cfattribute.getValues(); + if (!remove.contains(selected)) { + cfattribute.addValue(selected); + } + } else { + cfattribute.removeValue(selected); + } + } + attributeChanged(cfattribute); + } + + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(label); + break; + case 4: // Large Text Box + Text largeText = createTextField(composite, cfattribute, SWT.FLAT); + GridData largeTextData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + largeTextData.horizontalSpan = 1; + largeTextData.heightHint = 95; + largeText.setLayoutData(largeTextData); + break; + case 5: // Date/Time + Composite dateWithClear = toolkit.createComposite(composite); + GridLayout layout = new GridLayout(2, false); + layout.marginWidth = 1; + dateWithClear.setLayout(layout); + + final DatePicker dateTimePicker = new DatePicker(dateWithClear, /* SWT.NONE */SWT.BORDER, + cfattribute.getValue(), true); + dateTimePicker.setFont(TEXT_FONT); + dateTimePicker.setDatePattern("yyyy-MM-dd hh:mm:ss"); + if (hasChanged(attribute)) { + dateTimePicker.setBackground(getColorIncoming()); + } + dateTimePicker.addPickerSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent e) { + // ignore + } + + public void widgetSelected(SelectionEvent e) { + Calendar cal = dateTimePicker.getDate(); + if (cal != null) { + Date d = cal.getTime(); + SimpleDateFormat f = (SimpleDateFormat) SimpleDateFormat.getDateInstance(); + f.applyPattern("yyyy-MM-dd hh:mm:ss"); + + cfattribute.setValue(f.format(d)); + attributeChanged(cfattribute); + // TODO goes dirty even if user presses cancel + // markDirty(true); + } else { + cfattribute.setValue(""); + attributeChanged(cfattribute); + dateTimePicker.setDate(null); + } + } + }); + + ImageHyperlink clearDeadlineDate = toolkit.createImageHyperlink(dateWithClear, SWT.NONE); + clearDeadlineDate.setImage(TasksUiImages.getImage(TasksUiImages.REMOVE)); + clearDeadlineDate.setToolTipText("Clear"); + clearDeadlineDate.addHyperlinkListener(new HyperlinkAdapter() { + + @Override + public void linkActivated(HyperlinkEvent e) { + cfattribute.setValue(""); + attributeChanged(cfattribute); + dateTimePicker.setDate(null); + } + }); + + break; + default: + List optionListDefault = bugzillaCustomField.getOptions(); + if (optionListDefault != null && !optionListDefault.isEmpty()) { + GridData dropDownDefaultData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + dropDownDefaultData.horizontalSpan = 1; + final CCombo dropDownDefault = new CCombo(composite, SWT.FLAT | SWT.READ_ONLY); + getManagedForm().getToolkit().adapt(dropDownDefault, true, true); + dropDownDefault.setFont(TEXT_FONT); + dropDownDefault.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + if (hasChanged(cfattribute)) { + dropDownDefault.setBackground(getColorIncoming()); + } + dropDownDefault.setLayoutData(dropDownDefaultData); + + for (String valDefault : optionListDefault) { + if (valDefault != null) { + dropDownDefault.add(valDefault); + } + } + String dropDownValue = cfattribute.getValue(); + if (dropDownValue == null) { + dropDownValue = ""; + } + if (dropDownDefault.indexOf(dropDownValue) != -1) { + dropDownDefault.select(dropDownDefault.indexOf(dropDownValue)); + } + dropDownDefault.clearSelection(); + dropDownDefault.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + if (dropDownDefault.getSelectionIndex() > -1) { + String sel = dropDownDefault.getItem(dropDownDefault.getSelectionIndex()); + cfattribute.setValue(sel); + attributeChanged(cfattribute); + dropDownDefault.clearSelection(); + } + } + }); + } else { + Text freeTextDefault = createTextField(composite, cfattribute, SWT.FLAT); + GridData freeTextDefaultData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + freeTextDefaultData.horizontalSpan = 1; + freeTextDefaultData.verticalSpan = 1; + if (hasChanged(cfattribute)) { + freeTextDefault.setBackground(getColorIncoming()); + } + freeTextDefault.setLayoutData(freeTextDefaultData); + } + break; } } - getManagedForm().getToolkit().paintBordersFor(composite); } } @@ -197,15 +369,21 @@ // ignore } + if (customFieldsAnz % 2 == 1) { + @SuppressWarnings("unused") + Label label = new Label(composite, SWT.None); + label = new Label(composite, SWT.None); + } + attribute = this.taskData.getAttribute(BugzillaReportElement.DEPENDSON.getKeyString()); if (attribute != null && !attribute.isReadOnly()) { Label label = createLabel(composite, attribute); GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); - + Composite textFieldComposite = getManagedForm().getToolkit().createComposite(composite); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).applyTo(textFieldComposite); GridLayoutFactory.swtDefaults().margins(1, 3).spacing(0, 3).applyTo(textFieldComposite); - + GridData textData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); textData.horizontalSpan = 1; textData.widthHint = 135; @@ -351,8 +529,8 @@ for (String bugNumber : values.split(",")) { final String bugId = bugNumber.trim(); final String bugUrl = repository.getRepositoryUrl() + IBugzillaConstants.URL_GET_SHOW_BUG + bugId; - final AbstractTask task = TasksUi.getTaskListManager().getTaskList().getTask(repository.getRepositoryUrl(), - bugId); + final AbstractTask task = TasksUi.getTaskListManager().getTaskList().getTask( + repository.getRepositoryUrl(), bugId); createTaskListHyperlink(hyperlinksComposite, bugId, bugUrl, task); } } @@ -414,7 +592,8 @@ operation = BUGZILLA_OPERATION.valueOf(repositoryOperation.getKnobName()); } catch (RuntimeException e) { // FIXME: ? - StatusHandler.log(new Status(IStatus.INFO, BugzillaUiPlugin.PLUGIN_ID, "Unrecognized operation: " + repositoryOperation.getKnobName(), e)); + StatusHandler.log(new Status(IStatus.INFO, BugzillaUiPlugin.PLUGIN_ID, "Unrecognized operation: " + + repositoryOperation.getKnobName(), e)); operation = null; } @@ -623,7 +802,8 @@ List validKeywords = new ArrayList(); try { - validKeywords = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, new NullProgressMonitor()).getKeywords(); + validKeywords = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, + new NullProgressMonitor()).getKeywords(); } catch (Exception ex) { // ignore } @@ -672,7 +852,8 @@ @Override public void linkActivated(HyperlinkEvent e) { if (BugzillaTaskEditor.this.getEditor() instanceof TaskEditor) { - TasksUiUtil.openUrl(repository.getRepositoryUrl() + IBugzillaConstants.URL_SHOW_VOTES + taskData.getTaskId()); + TasksUiUtil.openUrl(repository.getRepositoryUrl() + IBugzillaConstants.URL_SHOW_VOTES + + taskData.getTaskId()); } } }); @@ -682,7 +863,8 @@ @Override public void linkActivated(HyperlinkEvent e) { if (BugzillaTaskEditor.this.getEditor() instanceof TaskEditor) { - TasksUiUtil.openUrl(repository.getRepositoryUrl() + IBugzillaConstants.URL_VOTE + taskData.getTaskId()); + TasksUiUtil.openUrl(repository.getRepositoryUrl() + IBugzillaConstants.URL_VOTE + + taskData.getTaskId()); } } }); @@ -711,7 +893,8 @@ if (assignedAttribute != null) { String bugzillaVersion; try { - bugzillaVersion = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, new NullProgressMonitor()).getInstallVersion(); + bugzillaVersion = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, + new NullProgressMonitor()).getInstallVersion(); } catch (CoreException e1) { // ignore bugzillaVersion = "2.18"; @@ -800,9 +983,9 @@ if (haveRealName) { textField.setText(textField.getText() + " <" + taskData.getAttributeValue(BugzillaReportElement.QA_CONTACT.getKeyString()) + ">"); - } + } } - + super.addSelfToCC(composite); } Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java,v retrieving revision 1.48 diff -u -r1.48 NewBugzillaTaskEditor.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java 14 Apr 2008 04:25:43 -0000 1.48 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/NewBugzillaTaskEditor.java 24 Apr 2008 20:08:04 -0000 @@ -7,6 +7,11 @@ *******************************************************************************/ package org.eclipse.mylyn.internal.bugzilla.ui.editor; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; @@ -15,15 +20,21 @@ import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaReportElement; +import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration; import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin; +import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages; import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute; +import org.eclipse.mylyn.tasks.ui.DatePicker; import org.eclipse.mylyn.tasks.ui.editors.AbstractNewRepositoryTaskEditor; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -34,7 +45,10 @@ import org.eclipse.ui.IEditorSite; import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter; import org.eclipse.ui.forms.editor.FormEditor; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ImageHyperlink; import org.eclipse.ui.forms.widgets.Section; /** @@ -112,8 +126,255 @@ @Override protected void createCustomAttributeLayout(Composite composite) { + RepositoryTaskAttribute attribute = null; + int customFieldsAnz = 0; + try { + RepositoryConfiguration configuration = BugzillaCorePlugin.getRepositoryConfiguration(this.repository, + false, new NullProgressMonitor()); + + if (configuration != null) { + List customFields = configuration.getCustomFields(); + if (!customFields.isEmpty()) { + for (BugzillaCustomField bugzillaCustomField : customFields) { + + if (!bugzillaCustomField.isEnterBug()) { + continue; + } + customFieldsAnz++; + attribute = this.taskData.getAttribute(bugzillaCustomField.getName()); + if (attribute == null) { + RepositoryTaskAttribute newattribute = new RepositoryTaskAttribute( + bugzillaCustomField.getName(), bugzillaCustomField.getDescription(), false); + newattribute.setReadOnly(false); + this.taskData.addAttribute(bugzillaCustomField.getName(), newattribute); + } + final RepositoryTaskAttribute cfattribute = this.taskData.getAttribute(bugzillaCustomField.getName()); + Label label = createLabel(composite, cfattribute); + GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); + + switch (bugzillaCustomField.getType()) { + case 1: // Free Text + Text freeText = createTextField(composite, cfattribute, SWT.FLAT); + GridData freeTextData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + freeTextData.horizontalSpan = 1; + freeTextData.verticalSpan = 1; + if (hasChanged(cfattribute)) { + freeText.setBackground(getColorIncoming()); + } + freeText.setLayoutData(freeTextData); + break; + case 2: // Drop Down + List optionList = bugzillaCustomField.getOptions(); + GridData dropDownData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + dropDownData.horizontalSpan = 1; + final CCombo dropDown = new CCombo(composite, SWT.FLAT | SWT.READ_ONLY); + getManagedForm().getToolkit().adapt(dropDown, true, true); + dropDown.setFont(TEXT_FONT); + dropDown.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + if (hasChanged(cfattribute)) { + dropDown.setBackground(getColorIncoming()); + } + dropDown.setLayoutData(dropDownData); + + for (String val : optionList) { + if (val != null) { + dropDown.add(val); + } + } + String value = cfattribute.getValue(); + if (value == null) { + value = ""; + } + if (dropDown.indexOf(value) != -1) { + dropDown.select(dropDown.indexOf(value)); + } + dropDown.clearSelection(); + dropDown.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + if (dropDown.getSelectionIndex() > -1) { + String sel = dropDown.getItem(dropDown.getSelectionIndex()); + cfattribute.setValue(sel); + attributeChanged(cfattribute); + dropDown.clearSelection(); + } + } + }); + break; + case 3: // Multiple-Selection Box + final org.eclipse.swt.widgets.List multiSelect; + List multiSelectOptionList = bugzillaCustomField.getOptions(); + multiSelect = new org.eclipse.swt.widgets.List(composite, SWT.MULTI | SWT.V_SCROLL);// SWT.BORDER + multiSelect.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + multiSelect.setFont(TEXT_FONT); + GridData multiSelectData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + multiSelectData.horizontalSpan = 1; + multiSelectData.heightHint = 95; + multiSelect.setLayoutData(multiSelectData); + if (hasChanged(cfattribute)) { + multiSelect.setBackground(getColorIncoming()); + } + if (multiSelectOptionList != null) { + for (String cc : multiSelectOptionList) { + multiSelect.add(cc); + } + } + java.util.List multiSelectValues = cfattribute.getValues(); + if (multiSelectValues != null) { + for (String item : multiSelectValues) { + int i = multiSelect.indexOf(item); + if (i != -1) { + multiSelect.select(i); + } + } + } + + multiSelect.addSelectionListener(new SelectionListener() { + + public void widgetSelected(SelectionEvent e) { + for (String selected : multiSelect.getItems()) { + int index = multiSelect.indexOf(selected); + if (multiSelect.isSelected(index)) { + List remove = cfattribute.getValues(); + if (!remove.contains(selected)) { + cfattribute.addValue(selected); + } + } else { + cfattribute.removeValue(selected); + } + } + attributeChanged(cfattribute); + } + + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(label); + break; + case 4: // Large Text Box + Text largeText = createTextField(composite, cfattribute, SWT.FLAT); + GridData largeTextData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + largeTextData.horizontalSpan = 1; + largeTextData.heightHint = 95; + largeText.setLayoutData(largeTextData); + break; + case 5: // Date/Time + Composite dateWithClear = toolkit.createComposite(composite); + GridLayout layout = new GridLayout(2, false); + layout.marginWidth = 1; + dateWithClear.setLayout(layout); + + final DatePicker dateTimePicker = new DatePicker(dateWithClear, /* SWT.NONE */SWT.BORDER, + cfattribute.getValue(), true); + dateTimePicker.setFont(TEXT_FONT); + dateTimePicker.setDatePattern("yyyy-MM-dd hh:mm:ss"); + if (hasChanged(attribute)) { + dateTimePicker.setBackground(getColorIncoming()); + } + dateTimePicker.addPickerSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent e) { + // ignore + } + + public void widgetSelected(SelectionEvent e) { + Calendar cal = dateTimePicker.getDate(); + if (cal != null) { + Date d = cal.getTime(); + SimpleDateFormat f = (SimpleDateFormat) SimpleDateFormat.getDateInstance(); + f.applyPattern("yyyy-MM-dd hh:mm:ss"); + + cfattribute.setValue(f.format(d)); + attributeChanged(cfattribute); + // TODO goes dirty even if user presses cancel + // markDirty(true); + } else { + cfattribute.setValue(""); + attributeChanged(cfattribute); + dateTimePicker.setDate(null); + } + } + }); + + ImageHyperlink clearDeadlineDate = toolkit.createImageHyperlink(dateWithClear, SWT.NONE); + clearDeadlineDate.setImage(TasksUiImages.getImage(TasksUiImages.REMOVE)); + clearDeadlineDate.setToolTipText("Clear"); + clearDeadlineDate.addHyperlinkListener(new HyperlinkAdapter() { + + @Override + public void linkActivated(HyperlinkEvent e) { + cfattribute.setValue(""); + attributeChanged(cfattribute); + dateTimePicker.setDate(null); + } + }); + + break; + default: + List optionListDefault = bugzillaCustomField.getOptions(); + if (optionListDefault != null && !optionListDefault.isEmpty()) { + GridData dropDownDefaultData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + dropDownDefaultData.horizontalSpan = 1; + final CCombo dropDownDefault = new CCombo(composite, SWT.FLAT | SWT.READ_ONLY); + getManagedForm().getToolkit().adapt(dropDownDefault, true, true); + dropDownDefault.setFont(TEXT_FONT); + dropDownDefault.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + if (hasChanged(cfattribute)) { + dropDownDefault.setBackground(getColorIncoming()); + } + dropDownDefault.setLayoutData(dropDownDefaultData); + + for (String valDefault : optionListDefault) { + if (valDefault != null) { + dropDownDefault.add(valDefault); + } + } + String dropDownValue = cfattribute.getValue(); + if (dropDownValue == null) { + dropDownValue = ""; + } + if (dropDownDefault.indexOf(dropDownValue) != -1) { + dropDownDefault.select(dropDownDefault.indexOf(dropDownValue)); + } + dropDownDefault.clearSelection(); + dropDownDefault.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + if (dropDownDefault.getSelectionIndex() > -1) { + String sel = dropDownDefault.getItem(dropDownDefault.getSelectionIndex()); + cfattribute.setValue(sel); + attributeChanged(cfattribute); + dropDownDefault.clearSelection(); + } + } + }); + } else { + Text freeTextDefault = createTextField(composite, cfattribute, SWT.FLAT); + GridData freeTextDefaultData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + freeTextDefaultData.horizontalSpan = 1; + freeTextDefaultData.verticalSpan = 1; + if (hasChanged(cfattribute)) { + freeTextDefault.setBackground(getColorIncoming()); + } + freeTextDefault.setLayoutData(freeTextDefaultData); + } + break; + } + } + getManagedForm().getToolkit().paintBordersFor(composite); + } + } + } catch (CoreException e) { + // ignore + } + + if (customFieldsAnz % 2 == 1) { + @SuppressWarnings("unused") + Label label = new Label(composite, SWT.None); + label = new Label(composite, SWT.None); + } - RepositoryTaskAttribute attribute = this.taskData.getAttribute(BugzillaReportElement.DEPENDSON.getKeyString()); + attribute = this.taskData.getAttribute(BugzillaReportElement.DEPENDSON.getKeyString()); if (attribute != null && !attribute.isReadOnly()) { Label label = createLabel(composite, attribute); GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label); @@ -165,7 +426,8 @@ if (assignedAttribute != null) { String bugzillaVersion; try { - bugzillaVersion = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, new NullProgressMonitor()).getInstallVersion(); + bugzillaVersion = BugzillaCorePlugin.getRepositoryConfiguration(repository, false, + new NullProgressMonitor()).getInstallVersion(); } catch (CoreException e1) { // ignore bugzillaVersion = "2.18"; #P org.eclipse.mylyn.bugzilla.core Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCustomField.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCustomField.java,v retrieving revision 1.1 diff -u -r1.1 BugzillaCustomField.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCustomField.java 8 Apr 2008 22:42:23 -0000 1.1 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCustomField.java 24 Apr 2008 20:08:05 -0000 @@ -8,6 +8,7 @@ package org.eclipse.mylyn.internal.bugzilla.core; +import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -20,7 +21,8 @@ */ public class BugzillaCustomField implements Serializable { - private static final long serialVersionUID = 5703683576871326128L; +// old Version private static final long serialVersionUID = 5703683576871326128L; + private static final long serialVersionUID = 7486595630521536136L; public static final String CUSTOM_FIELD_PREFIX = "cf_"; @@ -30,9 +32,24 @@ private List options = new ArrayList(); - public BugzillaCustomField(String description, String name) { + private int type = -1; + + private String typeDesc = null; + + private boolean enterBug = false; + + public BugzillaCustomField(String description, String name, String type, String typeDesc, String enterBug) { this.description = description; this.name = name; + if (type != null && !type.equals("")) { + this.type = Integer.parseInt(type); + } + if (typeDesc != null && !typeDesc.equals("")) { + this.typeDesc = typeDesc; + } + if (enterBug != null && !enterBug.equals("")) { + this.enterBug = enterBug.equals("1"); + } } public String getName() { @@ -54,4 +71,16 @@ public void addOption(String option) { this.options.add(option); } + + public int getType() { + return type; + } + + public String getTypeDesc() { + return typeDesc; + } + + public boolean isEnterBug() { + return enterBug; + } } Index: src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java,v retrieving revision 1.8 diff -u -r1.8 SaxConfigurationContentHandler.java --- src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java 8 Apr 2008 22:42:23 -0000 1.8 +++ src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java 24 Apr 2008 20:08:06 -0000 @@ -62,6 +62,12 @@ private static final String ELEMENT_FIELD = "field"; + private static final String ELEMENT_TYPE = "type"; + + private static final String ELEMENT_TYPE_DESC = "type_desc"; + + private static final String ELEMENT_ENTER_BUG = "enter_bug"; + private static final String ELEMENT_SEVERITY = "severity"; private static final String ELEMENT_PRIORITY = "priority"; @@ -127,9 +133,17 @@ private int state = EXPECTING_ROOT; private String currentProduct = ""; - + private String currentName = ""; + private String currentDescription = ""; + + private String currentType = ""; + + private String currentTypeDesc = ""; + + private String currentEnterBug = ""; + private StringBuffer characters = new StringBuffer(); private String about; @@ -213,6 +227,11 @@ } else if (localName.equals(ELEMENT_FIELD)) { state = state | IN_FIELD; parseResource(attributes); + currentName = ""; + currentDescription = ""; + currentType = ""; + currentTypeDesc = ""; + currentEnterBug = ""; } else if (localName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) { state = state | IN_CUSTOM_OPTION; currentCustomOptionName = localName; @@ -331,14 +350,21 @@ state = state & ~IN_FIELDS; } else if (localName.equals(ELEMENT_FIELD)) { state = state & ~IN_FIELD; - } else if (localName.equals(ELEMENT_DESCRIPTION)) { if (currentName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) { - BugzillaCustomField newField = new BugzillaCustomField(characters.toString(), currentName); + BugzillaCustomField newField = new BugzillaCustomField(currentDescription, currentName, currentType, currentTypeDesc, currentEnterBug); List customOptionList = customOption.get(currentName); if (customOptionList != null && !customOptionList.isEmpty()) newField.setOptions(customOptionList); configuration.addCustomField(newField); } + } else if (localName.equals(ELEMENT_DESCRIPTION)) { + currentDescription = characters.toString(); + } else if (localName.equals(ELEMENT_TYPE)) { + currentType = characters.toString(); + } else if (localName.equals(ELEMENT_TYPE_DESC)) { + currentTypeDesc = characters.toString(); + } else if (localName.equals(ELEMENT_ENTER_BUG)) { + currentEnterBug = characters.toString(); } else if (localName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) { state = state & ~IN_CUSTOM_OPTION; currentCustomOptionName = "";