### 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.36 diff -u -r1.36 SaxMultiBugReportContentHandler.java --- src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java 18 Jun 2008 02:14:08 -0000 1.36 +++ src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java 10 Sep 2008 21:20:48 -0000 @@ -186,7 +186,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 { @@ -371,11 +396,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.2 diff -u -r1.2 BugzillaCustomField.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCustomField.java 7 May 2008 18:30:55 -0000 1.2 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCustomField.java 10 Sep 2008 21:20:47 -0000 @@ -20,7 +20,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_"; @@ -30,9 +31,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() { @@ -54,4 +71,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/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.74 diff -u -r1.74 BugzillaTaskDataHandler.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java 12 Aug 2008 01:46:45 -0000 1.74 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java 10 Sep 2008 21:20:47 -0000 @@ -140,7 +140,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()); @@ -442,4 +494,8 @@ return new BugzillaAttributeMapper(taskRepository); } + public static void setVersionToTaskDataVersion(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.11 diff -u -r1.11 SaxConfigurationContentHandler.java --- src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java 12 May 2008 17:49:38 -0000 1.11 +++ src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java 10 Sep 2008 21:20:48 -0000 @@ -82,6 +82,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"; @@ -156,6 +160,10 @@ private String currentMultiplicable; + private String currentTypeDesc = ""; + + private String currentEnterBug = ""; + private StringBuffer characters = new StringBuffer(); private String about; @@ -239,6 +247,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)) { @@ -363,7 +376,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); @@ -375,6 +389,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)) {