### Eclipse Workspace Patch 1.0 #P org.eclipse.mylyn.bugzilla.core Index: src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java,v retrieving revision 1.37 diff -u -r1.37 SaxMultiBugReportContentHandler.java --- src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java 12 Sep 2008 04:17:45 -0000 1.37 +++ src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java 30 Oct 2008 21:31:56 -0000 @@ -189,7 +189,32 @@ atr.getMetaData().defaults().setLabel(desc).setReadOnly(false); atr.getMetaData().setKind(TaskAttribute.KIND_DEFAULT); atr.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT); - atr.getMetaData().setReadOnly(true); + switch (customField.getType()) { + case 1: // Free Text + atr.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT); + break; + case 2: // Drop Down + atr.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT); + break; + case 3: // Multiple-Selection Box + atr.getMetaData().setType(TaskAttribute.TYPE_MULTI_SELECT); + break; + case 4: // Large Text Box + atr.getMetaData().setType(TaskAttribute.TYPE_LONG_TEXT); + break; + case 5: // Date/Time + atr.getMetaData().setType(TaskAttribute.TYPE_DATE); + break; + + default: + List options = customField.getOptions(); + if (options.size() > 0) { + atr.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT); + } else { + atr.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT); + } + } + atr.getMetaData().setReadOnly(false); atr.setValue(parsedText); } } else { @@ -374,11 +399,30 @@ atr.getMetaData().defaults().setLabel(bugzillaCustomField.getDescription()); atr.getMetaData().setKind(TaskAttribute.KIND_DEFAULT); - List options = bugzillaCustomField.getOptions(); - if (options.size() > 0) { - atr.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT); - } else { + switch (bugzillaCustomField.getType()) { + case 1: // Free Text atr.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT); + break; + case 2: // Drop Down + atr.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT); + break; + case 3: // Multiple-Selection Box + atr.getMetaData().setType(TaskAttribute.TYPE_MULTI_SELECT); + break; + case 4: // Large Text Box + atr.getMetaData().setType(TaskAttribute.TYPE_LONG_TEXT); + break; + case 5: // Date/Time + atr.getMetaData().setType(TaskAttribute.TYPE_DATE); + break; + + default: + List options = bugzillaCustomField.getOptions(); + if (options.size() > 0) { + atr.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT); + } else { + atr.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT); + } } atr.getMetaData().setReadOnly(false); } 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.4 diff -u -r1.4 BugzillaCustomField.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCustomField.java 13 Sep 2008 03:27:57 -0000 1.4 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCustomField.java 30 Oct 2008 21:31:55 -0000 @@ -23,7 +23,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 = 7273310489883205486L; public static final String CUSTOM_FIELD_PREFIX = "cf_"; @@ -33,9 +34,25 @@ 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() { @@ -57,4 +74,26 @@ public void addOption(String option) { this.options.add(option); } + + /* + * @since 3.0.2 + */ + public int getType() { + return type; + } + + /* + * @since 3.0.2 + */ + public String getTypeDesc() { + return typeDesc; + } + + /* + * @since 3.0.2 + */ + public boolean isEnterBug() { + return enterBug; + } + } Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java,v retrieving revision 1.15 diff -u -r1.15 BugzillaAttributeMapper.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java 4 Oct 2008 01:28:49 -0000 1.15 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttributeMapper.java 30 Oct 2008 21:31:53 -0000 @@ -41,6 +41,8 @@ private static final String deadline_format = DATE_FORMAT_3; + private static final String customAttribute_format = DATE_FORMAT_2; + /** * public for testing Bugzilla 2.18 uses DATE_FORMAT_1 but later versions use DATE_FORMAT_2 Using lowest common * denominator DATE_FORMAT_1 @@ -100,6 +102,8 @@ parsedDate = new SimpleDateFormat(attachment_creation_ts_format).parse(dateString); } else if (attributeId.equals(BugzillaAttribute.DEADLINE.getKey())) { parsedDate = new SimpleDateFormat(deadline_format).parse(dateString); + } else if (attributeId.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) { + parsedDate = new SimpleDateFormat(customAttribute_format).parse(dateString); } } catch (ParseException e) { return null; @@ -125,6 +129,8 @@ dateString = new SimpleDateFormat(attachment_creation_ts_format).format(date); } else if (attributeId.equals(BugzillaAttribute.DEADLINE.getKey())) { dateString = new SimpleDateFormat(deadline_format).format(date); + } else if (attributeId.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) { + dateString = new SimpleDateFormat(customAttribute_format).format(date); } if (dateString == null) { Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java,v retrieving revision 1.78 diff -u -r1.78 BugzillaTaskDataHandler.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java 25 Sep 2008 17:12:46 -0000 1.78 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java 30 Oct 2008 21:31:55 -0000 @@ -144,7 +144,59 @@ updateAttribute(data, BugzillaAttribute.SHORT_DESC); } }, - VERSION_CURRENT(4.5f) { + VERSION_4_5(4.5f) { + @Override + void migrate(TaskRepository repository, TaskData data) { + // migrate custom attributes + for (TaskAttribute attribute : data.getRoot().getAttributes().values()) { + if (attribute.getId().startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) { + RepositoryConfiguration configuration = BugzillaCorePlugin.getRepositoryConfiguration(repository.getRepositoryUrl()); + + BugzillaCustomField customField = null; + String actName = attribute.getId(); + for (BugzillaCustomField bugzillaCustomField : configuration.getCustomFields()) { + if (actName.equals(bugzillaCustomField.getName())) { + customField = bugzillaCustomField; + break; + } + } + if (customField != null) { + String desc = customField.getDescription(); + attribute.getMetaData().defaults().setLabel(desc).setReadOnly(false); + attribute.getMetaData().setKind(TaskAttribute.KIND_DEFAULT); + attribute.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT); + switch (customField.getType()) { + case 1: // Free Text + attribute.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT); + break; + case 2: // Drop Down + attribute.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT); + break; + case 3: // Multiple-Selection Box + attribute.getMetaData().setType(TaskAttribute.TYPE_MULTI_SELECT); + break; + case 4: // Large Text Box + attribute.getMetaData().setType(TaskAttribute.TYPE_LONG_TEXT); + break; + case 5: // Date/Time + attribute.getMetaData().setType(TaskAttribute.TYPE_DATE); + break; + + default: + List options = customField.getOptions(); + if (options.size() > 0) { + attribute.getMetaData().setType(TaskAttribute.TYPE_SINGLE_SELECT); + } else { + attribute.getMetaData().setType(TaskAttribute.TYPE_SHORT_TEXT); + } + } + attribute.getMetaData().setReadOnly(false); + } + } + } + } + }, + VERSION_CURRENT(4.6f) { @Override void migrate(TaskRepository repository, TaskData data) { data.setVersion(TaskDataVersion.VERSION_CURRENT.toString()); 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.12 diff -u -r1.12 SaxConfigurationContentHandler.java --- src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java 12 Sep 2008 04:17:45 -0000 1.12 +++ src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java 30 Oct 2008 21:31:56 -0000 @@ -85,6 +85,10 @@ 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_REQUESTABLE = "requestable"; private static final String ELEMENT_SPECIFICALLY_REQUESTABLE = "specifically_requestable"; @@ -159,6 +163,10 @@ private String currentMultiplicable; + private String currentTypeDesc = ""; + + private String currentEnterBug = ""; + private StringBuffer characters = new StringBuffer(); private String about; @@ -242,6 +250,11 @@ } else if (localName.equals(ELEMENT_FIELD)) { state = state | IN_FIELD; parseResource(attributes); + currentName = ""; + currentDescription = ""; + currentType = ""; + currentTypeDesc = ""; + currentEnterBug = ""; } else if (localName.equals(ELEMENT_FLAG_TYPES)) { state = state | IN_FLAG_TYPES; } else if (localName.equals(ELEMENT_FLAG_TYPE)) { @@ -366,7 +379,8 @@ state = state & ~IN_FIELDS; } else if (localName.equals(ELEMENT_FIELD)) { if (currentName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) { - BugzillaCustomField newField = new BugzillaCustomField(currentDescription, currentName); + BugzillaCustomField newField = new BugzillaCustomField(currentDescription, currentName, currentType, + currentTypeDesc, currentEnterBug); List customOptionList = customOption.get(currentName); if (customOptionList != null && !customOptionList.isEmpty()) { newField.setOptions(customOptionList); @@ -378,6 +392,10 @@ 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.equals(ELEMENT_REQUESTABLE)) { currentRequestable = characters.toString(); } else if (localName.equals(ELEMENT_SPECIFICALLY_REQUESTABLE)) { Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java,v retrieving revision 1.158 diff -u -r1.158 BugzillaClient.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java 3 Oct 2008 17:59:43 -0000 1.158 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java 30 Oct 2008 21:31:55 -0000 @@ -982,8 +982,13 @@ if (a.getId().equals(BugzillaAttribute.GROUP.getKey()) && a.getValue().length() > 0) { groupSecurityEnabled = true; } - - if (a.getId() != null && a.getId().compareTo("") != 0) { + if (a.getMetaData().getType().equals(TaskAttribute.TYPE_MULTI_SELECT)) { + List values = a.getValues(); + int i = 0; + for (String string : values) { + fields.put(a.getId() + i++, new NameValuePair(a.getId(), string != null ? string : "")); + } + } else if (a.getId() != null && a.getId().compareTo("") != 0) { String value = a.getValue(); if (a.getId().equals(BugzillaAttribute.DELTA_TS.getKey())) { value = stripTimeZone(value); Index: src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java,v retrieving revision 1.70 diff -u -r1.70 IBugzillaConstants.java --- src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java 12 Sep 2008 04:17:45 -0000 1.70 +++ src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java 30 Oct 2008 21:31:55 -0000 @@ -174,6 +174,8 @@ static final String TEST_BUGZILLA_31_URL = "http://mylyn.eclipse.org/bugs31"; + static final String TEST_BUGZILLA_32_URL = "http://mylyn.eclipse.org/bugs32"; + // Default values for keys static final String[] DEFAULT_STATUS_VALUES = { "Unconfirmed", "New", "Assigned", "Reopened", "Resolved", #P org.eclipse.mylyn.tasks.ui Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/DateAttributeEditor.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/DateAttributeEditor.java,v retrieving revision 1.25 diff -u -r1.25 DateAttributeEditor.java --- src/org/eclipse/mylyn/internal/tasks/ui/editors/DateAttributeEditor.java 4 Oct 2008 00:02:49 -0000 1.25 +++ src/org/eclipse/mylyn/internal/tasks/ui/editors/DateAttributeEditor.java 30 Oct 2008 21:32:00 -0000 @@ -64,9 +64,13 @@ layout.verticalSpacing = 2; layout.horizontalSpacing = 2; dateWithClearComposite.setLayout(layout); - datePicker = new DatePicker(dateWithClearComposite, SWT.FLAT, getTextValue(), false, 0); + datePicker = new DatePicker(dateWithClearComposite, SWT.FLAT, getTextValue(), showTime, 0); datePicker.setFont(EditorUtil.TEXT_FONT); - datePicker.setDateFormat(EditorUtil.getDateFormat()); + if (!showTime) { + datePicker.setDateFormat(EditorUtil.getDateFormat()); + } else { + datePicker.setDateFormat(EditorUtil.getDateTimeFormat()); + } if (getValue() != null) { Calendar cal = Calendar.getInstance(); cal.setTime(getValue()); Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttributePart.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttributePart.java,v retrieving revision 1.31 diff -u -r1.31 TaskEditorAttributePart.java --- src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttributePart.java 12 Sep 2008 04:19:25 -0000 1.31 +++ src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttributePart.java 30 Oct 2008 21:32:01 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2004, 2008 Tasktop Technologies and others. + * Copyright (c) 2004, 2008 Tasktop Technologies and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -65,7 +65,7 @@ private static final int MULTI_ROW_HEIGHT = 55; - private List attributeEditors; + protected List attributeEditors; private boolean hasIncoming; @@ -143,6 +143,7 @@ @Override public void createControl(Composite parent, final FormToolkit toolkit) { + attributeEditors = new ArrayList(); initialize(); boolean expand = getTaskData().isNew() || hasIncoming; @@ -251,8 +252,7 @@ toolBar.add(repositoryConfigRefresh); } - private void initialize() { - attributeEditors = new ArrayList(); + protected void initialize() { hasIncoming = false; Map attributes = getTaskData().getRoot().getAttributes(); @@ -264,7 +264,13 @@ AbstractAttributeEditor attributeEditor = createAttributeEditor(attribute); if (attributeEditor != null) { - attributeEditors.add(attributeEditor); + String attributeId = attribute.getId(); + if (attributeId.startsWith("cf_"/*BugzillaCustomField.CUSTOM_FIELD_PREFIX*/) + && attributeEditor instanceof DateAttributeEditor) { + ((DateAttributeEditor) attributeEditor).setShowTime(true); + } + + addAttributeEditor(attributeEditor); if (getModel().hasIncomingChanges(attribute)) { hasIncoming = true; } @@ -280,4 +286,15 @@ }); } + public boolean isHasIncoming() { + return hasIncoming; + } + + public void setHasIncoming(boolean hasIncoming) { + this.hasIncoming = hasIncoming; + } + + public void addAttributeEditor(AbstractAttributeEditor attributeEditor) { + attributeEditors.add(attributeEditor); + } } #P org.eclipse.mylyn.bugzilla.ui Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java,v retrieving revision 1.16 diff -u -r1.16 BugzillaTaskEditorPage.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java 17 Oct 2008 03:22:21 -0000 1.16 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java 30 Oct 2008 21:32:02 -0000 @@ -56,7 +56,8 @@ // remove unnecessary default editor parts for (TaskEditorPartDescriptor taskEditorPartDescriptor : descriptors) { - if (taskEditorPartDescriptor.getId().equals(ID_PART_PEOPLE)) { + if (taskEditorPartDescriptor.getId().equals(ID_PART_PEOPLE) + || taskEditorPartDescriptor.getId().equals(ID_PART_ATTRIBUTES)) { descriptors.remove(taskEditorPartDescriptor); break; } @@ -89,6 +90,14 @@ } }.setPath(PATH_PEOPLE)); + // Add the updated Bugzilla people part + descriptors.add(new TaskEditorPartDescriptor(ID_PART_ATTRIBUTES) { + @Override + public AbstractTaskEditorPart createPart() { + return new BugzillaAttributePart(); + } + }.setPath(PATH_ATTRIBUTES)); + return descriptors; } Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaAttributePart.java =================================================================== RCS file: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaAttributePart.java diff -N src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaAttributePart.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaAttributePart.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 Tasktop Technologies and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tasktop Technologies - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.internal.bugzilla.ui.editor; + +import java.util.Map; + +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField; +import org.eclipse.mylyn.internal.tasks.ui.editors.DateAttributeEditor; +import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorAttributePart; +import org.eclipse.mylyn.tasks.core.data.TaskAttribute; +import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData; +import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor; + +@SuppressWarnings("restriction") +public class BugzillaAttributePart extends TaskEditorAttributePart { + + @Override + protected void initialize() { + setHasIncoming(false); + + Map attributes = getTaskData().getRoot().getAttributes(); + for (TaskAttribute attribute : attributes.values()) { + TaskAttributeMetaData properties = attribute.getMetaData(); + if (!TaskAttribute.KIND_DEFAULT.equals(properties.getKind())) { + continue; + } + + AbstractAttributeEditor attributeEditor = createAttributeEditor(attribute); + if (attributeEditor != null) { + String attributeId = attribute.getId(); + if (attributeId.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX) + && attributeEditor instanceof DateAttributeEditor) { + ((DateAttributeEditor) attributeEditor).setShowTime(true); + } + + addAttributeEditor(attributeEditor); + if (getModel().hasIncomingChanges(attribute)) { + setHasIncoming(true); + } + } + } + } +} #P org.eclipse.mylyn.bugzilla.tests Index: src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java,v retrieving revision 1.62 diff -u -r1.62 AbstractBugzillaTest.java --- src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java 7 Oct 2008 05:09:55 -0000 1.62 +++ src/org/eclipse/mylyn/bugzilla/tests/AbstractBugzillaTest.java 30 Oct 2008 21:32:03 -0000 @@ -80,6 +80,10 @@ manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath()); } + protected void init32() { + init(IBugzillaConstants.TEST_BUGZILLA_32_URL); + } + protected void init31() { init(IBugzillaConstants.TEST_BUGZILLA_31_URL); } Index: src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java,v retrieving revision 1.39 diff -u -r1.39 AllBugzillaTests.java --- src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java 2 Oct 2008 01:36:13 -0000 1.39 +++ src/org/eclipse/mylyn/bugzilla/tests/AllBugzillaTests.java 30 Oct 2008 21:32:03 -0000 @@ -42,6 +42,7 @@ suite.addTestSuite(BugzillaProductParserTest.class); suite.addTestSuite(BugzillaSearchDialogTest.class); suite.addTestSuite(BugzillaTaskHistoryTest.class); + suite.addTestSuite(BugzillaRepository32Test.class); // $JUnit-END$ return suite; } Index: src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java =================================================================== RCS file: src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java diff -N src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepository32Test.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 Tasktop Technologies and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tasktop Technologies - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.bugzilla.tests; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.mylyn.commons.net.AuthenticationCredentials; +import org.eclipse.mylyn.commons.net.AuthenticationType; +import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; +import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; +import org.eclipse.mylyn.tasks.core.ITask; +import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState; +import org.eclipse.mylyn.tasks.core.data.TaskAttribute; +import org.eclipse.mylyn.tasks.core.data.TaskData; +import org.eclipse.mylyn.tasks.core.data.TaskMapper; + +public class BugzillaRepository32Test extends AbstractBugzillaTest { + + public void testCustomAttributes() throws Exception { + init32(); + String taskNumber = "1"; + ITask task = generateLocalTaskAndDownload(taskNumber); + assertNotNull(task); + TaskData taskData = TasksUiPlugin.getTaskDataManager().getTaskData(task); + assertNotNull(taskData); + TaskMapper mapper = new TaskMapper(taskData); + assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState()); + assertEquals(taskNumber, taskData.getTaskId()); + + SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + assertEquals(format1.parse("2008-10-04 15:01"), mapper.getCreationDate()); + + AuthenticationCredentials credentials = repository.getCredentials(AuthenticationType.REPOSITORY); + assertNotNull("credentials are null", credentials); + assertNotNull("Repositor User not set", credentials.getUserName()); + assertNotNull("no password for Repository", credentials.getPassword()); + + TaskAttribute colorAttribute = mapper.getTaskData().getRoot().getAttribute("cf_colors"); + assertNotNull("TaskAttribute Color did not exists", colorAttribute); + List theColors = colorAttribute.getValues(); + assertNotNull(theColors); + assertFalse("no colors set", theColors.isEmpty()); + + boolean red = false; + boolean green = false; + boolean yellow = false; + boolean blue = false; + + for (Object element : theColors) { + String string = (String) element; + + if (!red && string.compareTo("Red") == 0) { + red = true; + } else if (!green && string.compareTo("Green") == 0) { + green = true; + } else if (!yellow && string.compareTo("Yellow") == 0) { + yellow = true; + } else if (!blue && string.compareTo("Blue") == 0) { + blue = true; + } + } + changeCollorAndSubmit(task, taskData, colorAttribute, red, green, yellow, blue); + assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState()); + TasksUiInternal.synchronizeTask(connector, task, true, null); + TasksUiPlugin.getTaskDataManager().setTaskRead(task, true); +// task = generateLocalTaskAndDownload(taskNumber); + assertNotNull(task); + taskData = TasksUiPlugin.getTaskDataManager().getTaskData(task); + assertNotNull(taskData); + mapper = new TaskMapper(taskData); + assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState()); + + colorAttribute = mapper.getTaskData().getRoot().getAttribute("cf_colors"); + assertNotNull("TaskAttribute Color did not exists", colorAttribute); + theColors = colorAttribute.getValues(); + assertNotNull(theColors); + assertFalse("no colors set", theColors.isEmpty()); + boolean red_new = false; + boolean green_new = false; + boolean yellow_new = false; + boolean blue_new = false; + + for (Object element : theColors) { + String string = (String) element; + + if (!red_new && string.compareTo("Red") == 0) { + red_new = true; + } else if (!green_new && string.compareTo("Green") == 0) { + green_new = true; + } else if (!yellow_new && string.compareTo("Yellow") == 0) { + yellow_new = true; + } else if (!blue_new && string.compareTo("Blue") == 0) { + blue_new = true; + } + } + assertTrue("wrong change", + (!red && green && !yellow && !blue && red_new && green_new && !yellow_new && !blue_new) + || (red && green && !yellow && !blue && !red_new && green_new && !yellow_new && !blue_new)); + changeCollorAndSubmit(task, taskData, colorAttribute, red_new, green_new, yellow_new, blue_new); + assertEquals(SynchronizationState.SYNCHRONIZED, task.getSynchronizationState()); + + } + + private void changeCollorAndSubmit(ITask task, TaskData taskData, TaskAttribute colorAttribute, boolean red, + boolean green, boolean yellow, boolean blue) throws CoreException { + if (!red && green && !yellow && !blue) { + List newValue = new ArrayList(2); + newValue.add("Red"); + newValue.add("Green"); + colorAttribute.setValues(newValue); + Set changed = new HashSet(); + changed.add(colorAttribute); + // Submit changes + submit(task, taskData, changed); + } else if (red && green && !yellow && !blue) { + List newValue = new ArrayList(2); + newValue.add("Green"); + colorAttribute.setValues(newValue); + Set changed = new HashSet(); + changed.add(colorAttribute); + // Submit changes + submit(task, taskData, changed); + } + + } +}