### Eclipse Workspace Patch 1.0 #P org.eclipse.mylyn.bugzilla.core Index: src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentMapper.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentMapper.java,v retrieving revision 1.2 diff -u -r1.2 BugzillaAttachmentMapper.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentMapper.java 24 Jul 2009 12:07:14 -0000 1.2 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaAttachmentMapper.java 24 Jan 2010 14:29:39 -0000 @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 Tasktop Technologies and others. + * Copyright (c) 2009 Frank Becker 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 + * Frank Becker - initial API and implementation *******************************************************************************/ package org.eclipse.mylyn.internal.bugzilla.core; @@ -15,6 +15,7 @@ import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper; import org.eclipse.mylyn.tasks.core.data.TaskAttribute; import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper; +import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData; import org.eclipse.mylyn.tasks.core.data.TaskData; /** @@ -33,19 +34,83 @@ @Override public void applyTo(TaskAttribute taskAttribute) { - // ignore - super.applyTo(taskAttribute); - Assert.isNotNull(taskAttribute); TaskData taskData = taskAttribute.getTaskData(); TaskAttributeMapper mapper = taskData.getAttributeMapper(); - + taskAttribute.getMetaData().defaults().setType(TaskAttribute.TYPE_ATTACHMENT); + if (getAttachmentId() != null) { + mapper.setValue(taskAttribute, getAttachmentId()); + } + if (getAuthor() != null) { + TaskAttribute child = taskAttribute.createMappedAttribute(TaskAttribute.ATTACHMENT_AUTHOR); + TaskAttributeMetaData defaults = child.getMetaData().defaults(); + defaults.setType(TaskAttribute.TYPE_PERSON); + defaults.setLabel(Messages.BugzillaAttachmentMapper_Author); + mapper.setRepositoryPerson(child, getAuthor()); + } + if (getContentType() != null) { + TaskAttribute child = taskAttribute.createMappedAttribute(TaskAttribute.ATTACHMENT_CONTENT_TYPE); + TaskAttributeMetaData defaults = child.getMetaData().defaults(); + defaults.setType(TaskAttribute.TYPE_SHORT_TEXT); + defaults.setLabel(Messages.BugzillaAttachmentMapper_Content_Type); + mapper.setValue(child, getContentType()); + } + if (getCreationDate() != null) { + TaskAttribute child = taskAttribute.createMappedAttribute(TaskAttribute.ATTACHMENT_DATE); + TaskAttributeMetaData defaults = child.getMetaData().defaults(); + defaults.setType(TaskAttribute.TYPE_DATE); + defaults.setLabel(Messages.BugzillaAttachmentMapper_Creation_Date); + mapper.setDateValue(child, getCreationDate()); + } + if (getDescription() != null) { + TaskAttribute child = taskAttribute.createMappedAttribute(TaskAttribute.ATTACHMENT_DESCRIPTION); + TaskAttributeMetaData defaults = child.getMetaData().defaults(); + defaults.setType(TaskAttribute.TYPE_SHORT_TEXT); + defaults.setLabel(Messages.BugzillaAttachmentMapper_Description); + mapper.setValue(child, getDescription()); + } + if (getFileName() != null) { + TaskAttribute child = taskAttribute.createMappedAttribute(TaskAttribute.ATTACHMENT_FILENAME); + TaskAttributeMetaData defaults = child.getMetaData().defaults(); + defaults.setType(TaskAttribute.TYPE_SHORT_TEXT); + defaults.setLabel(Messages.BugzillaAttachmentMapper_Filename); + mapper.setValue(child, getFileName()); + } + if (isDeprecated() != null) { + TaskAttribute child = taskAttribute.createMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED); + TaskAttributeMetaData defaults = child.getMetaData().defaults(); + defaults.setType(TaskAttribute.TYPE_BOOLEAN); + defaults.setLabel(Messages.BugzillaAttachmentMapper_obsolete); + mapper.setBooleanValue(child, isDeprecated()); + } + if (isPatch() != null) { + TaskAttribute child = taskAttribute.createMappedAttribute(TaskAttribute.ATTACHMENT_IS_PATCH); + TaskAttributeMetaData defaults = child.getMetaData().defaults(); + defaults.setType(TaskAttribute.TYPE_BOOLEAN); + defaults.setLabel(Messages.BugzillaAttachmentMapper_patch); + mapper.setBooleanValue(child, isPatch()); + } + if (getLength() != null) { + TaskAttribute child = taskAttribute.createMappedAttribute(TaskAttribute.ATTACHMENT_SIZE); + TaskAttributeMetaData defaults = child.getMetaData().defaults(); + defaults.setType(TaskAttribute.TYPE_SHORT_TEXT); + defaults.setLabel(Messages.BugzillaAttachmentMapper_Size); + mapper.setLongValue(child, getLength()); + } + if (getUrl() != null) { + TaskAttribute child = taskAttribute.createMappedAttribute(TaskAttribute.ATTACHMENT_URL); + TaskAttributeMetaData defaults = child.getMetaData().defaults(); + defaults.setType(TaskAttribute.TYPE_URL); + defaults.setLabel(Messages.BugzillaAttachmentMapper_URL); + mapper.setValue(child, getUrl()); + } if (getToken() != null) { TaskAttribute child = taskAttribute.createMappedAttribute(BugzillaAttribute.TOKEN.getKey()); - child.getMetaData().defaults().setType(TaskAttribute.TYPE_SHORT_TEXT); + TaskAttributeMetaData defaults = child.getMetaData().defaults(); + defaults.setType(TaskAttribute.TYPE_SHORT_TEXT); + defaults.setLabel(Messages.BugzillaAttachmentMapper_Token); mapper.setValue(child, getToken()); } - } public static BugzillaAttachmentMapper createFrom(TaskAttribute taskAttribute) { @@ -98,5 +163,4 @@ } return attachment; } - } 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.211 diff -u -r1.211 BugzillaClient.java --- src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java 19 Jan 2010 22:40:36 -0000 1.211 +++ src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java 24 Jan 2010 14:29:40 -0000 @@ -889,9 +889,9 @@ Collection attributes = taskAttribute.getAttributes().values(); Iterator itr = attributes.iterator(); while (itr.hasNext()) { - TaskAttribute a = itr.next(); - String id = a.getId(); - String value = a.getValue(); + TaskAttribute attrib = itr.next(); + String id = attrib.getId(); + String value = attrib.getValue(); if (id.equals(TaskAttribute.ATTACHMENT_AUTHOR) || id.equals("date") || id.equals("size") //$NON-NLS-1$ //$NON-NLS-2$ || id.equals(TaskAttribute.ATTACHMENT_URL)) { continue; @@ -910,7 +910,36 @@ if (id.equals(TaskAttribute.ATTACHMENT_IS_PATCH)) { id = "ispatch"; //$NON-NLS-1$ } - formData.add(new NameValuePair(id, value)); + if (id.startsWith("task.common.kind.flag_type")) { //$NON-NLS-1$ + TaskAttribute requestee = attrib.getAttribute("requestee"); //$NON-NLS-1$ + TaskAttribute state = attrib.getAttribute("state"); //$NON-NLS-1$ + String requesteeName = "requestee_type-" + id.substring(26); //$NON-NLS-1$ + String requesteeValue = requestee.getValue(); + value = state.getValue(); + if (value.equals(" ")) { //$NON-NLS-1$ + value = "X"; //$NON-NLS-1$ + } + if (value.equals("?")) { //$NON-NLS-1$ + formData.add(new NameValuePair(requesteeName, requesteeValue)); + } + id = "flag_type-" + id.substring(26); //$NON-NLS-1$ + } else if (id.startsWith("task.common.kind.flag")) { //$NON-NLS-1$ + TaskAttribute requestee = attrib.getAttribute("requestee"); //$NON-NLS-1$ + TaskAttribute state = attrib.getAttribute("state"); //$NON-NLS-1$ + String requesteeName = "requestee-" + id.substring(21); //$NON-NLS-1$ + String requesteeValue = requestee.getValue(); + value = state.getValue(); + if (value.equals(" ") | value.equals("")) { //$NON-NLS-1$//$NON-NLS-2$ + value = "X"; //$NON-NLS-1$ + } + if (value.equals("?")) { //$NON-NLS-1$ + formData.add(new NameValuePair(requesteeName, requesteeValue)); + } + id = "flag-" + id.substring(21); //$NON-NLS-1$ + } + if (!value.equals("")) { //$NON-NLS-1$ + formData.add(new NameValuePair(id, value)); + } } GzipPostMethod method = null; InputStream input = null; Index: src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java,v retrieving revision 1.10 diff -u -r1.10 Messages.java --- src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java 17 Sep 2009 02:16:05 -0000 1.10 +++ src/org/eclipse/mylyn/internal/bugzilla/core/Messages.java 24 Jan 2010 14:29:40 -0000 @@ -177,6 +177,26 @@ public static String BugzillaAttribute_Worked; + public static String BugzillaAttachmentMapper_Author; + + public static String BugzillaAttachmentMapper_Content_Type; + + public static String BugzillaAttachmentMapper_Creation_Date; + + public static String BugzillaAttachmentMapper_Description; + + public static String BugzillaAttachmentMapper_Filename; + + public static String BugzillaAttachmentMapper_obsolete; + + public static String BugzillaAttachmentMapper_patch; + + public static String BugzillaAttachmentMapper_Size; + + public static String BugzillaAttachmentMapper_Token; + + public static String BugzillaAttachmentMapper_URL; + public static String BugzillaClient_could_not_post_form_null_returned; public static String BugzillaClient_description_required_when_submitting_attachments; Index: src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java,v retrieving revision 1.48 diff -u -r1.48 RepositoryConfiguration.java --- src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java 21 Dec 2009 21:52:42 -0000 1.48 +++ src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java 24 Jan 2010 14:29:40 -0000 @@ -375,6 +375,8 @@ if (localuser) { removeDomain(taskData); } + addMissingAttachmentFlags(taskData, connector); + updateAttachmentOptions(taskData); } } @@ -731,6 +733,99 @@ return encoding; } + public void updateAttachmentOptions(TaskData existingReport) { + for (TaskAttribute attribute : new HashSet(existingReport.getRoot().getAttributes().values())) { + + if (!attribute.getId().startsWith("task.common.attachment")) { //$NON-NLS-1$ + continue; + } + + for (TaskAttribute attachmentAttribute : attribute.getAttributes().values()) { + if (!attachmentAttribute.getId().startsWith("task.common.kind.flag")) { //$NON-NLS-1$ + continue; + } + + TaskAttribute state = attachmentAttribute.getAttribute("state"); //$NON-NLS-1$ + attachmentAttribute.clearOptions(); + + String nameValue = state.getMetaData().getLabel(); + state.putOption("", ""); //$NON-NLS-1$ //$NON-NLS-2$ + for (BugzillaFlag bugzillaFlag : flags) { + if (nameValue.equals(bugzillaFlag.getName()) && bugzillaFlag.getType().equals("attachment")) { //$NON-NLS-1$ + if ("attachment".equals(bugzillaFlag.getType())) { //$NON-NLS-1$ + if (bugzillaFlag.isRequestable()) { + state.putOption("?", "?"); //$NON-NLS-1$ //$NON-NLS-2$ + } + break; + } + } + } + state.putOption("-", "-"); //$NON-NLS-1$ //$NON-NLS-2$ + state.putOption("+", "+"); //$NON-NLS-1$ //$NON-NLS-2$ + String flagNameValue = state.getMetaData().getLabel(); + for (BugzillaFlag bugzillaFlag : flags) { + if (flagNameValue.equals(bugzillaFlag.getName()) && bugzillaFlag.getType().equals("attachment")) { //$NON-NLS-1$ + TaskAttribute requestee = attachmentAttribute.getAttribute("requestee"); //$NON-NLS-1$ + if (requestee == null) { + requestee = attachmentAttribute.createMappedAttribute("requestee"); //$NON-NLS-1$ + requestee.getMetaData().defaults().setType(TaskAttribute.TYPE_SHORT_TEXT); + requestee.setValue(""); //$NON-NLS-1$ + } + requestee.getMetaData().setReadOnly(!bugzillaFlag.isSpecifically_requestable()); + } + } + + } + } + } + + private void addMissingAttachmentFlags(TaskData taskData, BugzillaRepositoryConnector connector) { + List existingFlags = new ArrayList(); + List flags = getFlags(); + for (TaskAttribute attribute : new HashSet(taskData.getRoot().getAttributes().values())) { + + if (!attribute.getId().startsWith("task.common.attachment")) { //$NON-NLS-1$ + continue; + } + existingFlags.clear(); + for (TaskAttribute attachmentAttribute : attribute.getAttributes().values()) { + if (!attachmentAttribute.getId().startsWith("task.common.kind.flag")) { //$NON-NLS-1$ + continue; + } + TaskAttribute state = attachmentAttribute.getAttribute("state"); //$NON-NLS-1$ + if (state != null) { + String nameValue = state.getMetaData().getLabel(); + if (!existingFlags.contains(nameValue)) { + existingFlags.add(nameValue); + } + } + } + TaskAttribute productAttribute = taskData.getRoot().getMappedAttribute(BugzillaAttribute.PRODUCT.getKey()); + TaskAttribute componentAttribute = taskData.getRoot().getMappedAttribute( + BugzillaAttribute.COMPONENT.getKey()); + for (BugzillaFlag bugzillaFlag : flags) { + if (!bugzillaFlag.getType().equals("attachment")) { //$NON-NLS-1$ + continue; + } + if (!bugzillaFlag.isUsedIn(productAttribute.getValue(), componentAttribute.getValue())) { + continue; + } + if (existingFlags.contains(bugzillaFlag.getName()) && !bugzillaFlag.isMultiplicable()) { + continue; + } + BugzillaFlagMapper mapper = new BugzillaFlagMapper(connector); + mapper.setRequestee(""); //$NON-NLS-1$ + mapper.setSetter(""); //$NON-NLS-1$ + mapper.setState(" "); //$NON-NLS-1$ + mapper.setFlagId(bugzillaFlag.getName()); + mapper.setNumber(0); + mapper.setDescription(bugzillaFlag.getDescription()); + TaskAttribute newattribute = attribute.createAttribute("task.common.kind.flag_type" + bugzillaFlag.getFlagId()); //$NON-NLS-1$ + mapper.applyTo(newattribute); + } + } + } + public void setETagValue(String eTagValue) { this.eTagValue = eTagValue; } 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.52 diff -u -r1.52 SaxMultiBugReportContentHandler.java --- src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java 13 Oct 2009 00:57:57 -0000 1.52 +++ src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java 24 Jan 2010 14:29:40 -0000 @@ -18,7 +18,6 @@ import java.util.Map; import org.eclipse.mylyn.tasks.core.IRepositoryPerson; -import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper; import org.eclipse.mylyn.tasks.core.data.TaskAttribute; import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper; import org.eclipse.mylyn.tasks.core.data.TaskCommentMapper; @@ -521,7 +520,7 @@ List taskAttachments = repositoryTaskData.getAttributeMapper().getAttributesByType( repositoryTaskData, TaskAttribute.TYPE_ATTACHMENT); for (TaskAttribute attachment : taskAttachments) { - TaskAttachmentMapper attachmentMapper = TaskAttachmentMapper.createFrom(attachment); + BugzillaAttachmentMapper attachmentMapper = BugzillaAttachmentMapper.createFrom(attachment); TaskCommentMapper taskComment = attachIdToComment.get(attachmentMapper.getAttachmentId()); if (taskComment != null) { attachmentMapper.setAuthor(taskComment.getAuthor()); Index: src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties,v retrieving revision 1.14 diff -u -r1.14 messages.properties --- src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties 17 Sep 2009 02:16:05 -0000 1.14 +++ src/org/eclipse/mylyn/internal/bugzilla/core/messages.properties 24 Jan 2010 14:29:40 -0000 @@ -84,6 +84,18 @@ BugzillaAttribute_who=who BugzillaAttribute_who_name=who_name BugzillaAttribute_Worked=Worked: + +BugzillaAttachmentMapper_Author=Attachment Author: +BugzillaAttachmentMapper_Content_Type=Content Type: +BugzillaAttachmentMapper_Creation_Date=Creation Date: +BugzillaAttachmentMapper_Description=Description: +BugzillaAttachmentMapper_Filename=Filename: +BugzillaAttachmentMapper_obsolete=obsolete +BugzillaAttachmentMapper_patch=patch +BugzillaAttachmentMapper_Size=Size in Bytes: +BugzillaAttachmentMapper_Token=Token: +BugzillaAttachmentMapper_URL=URL: + BugzillaClient_could_not_post_form_null_returned=Could not post form, client returned null method. BugzillaClient_description_required_when_submitting_attachments=A description is required when submitting attachments. #P org.eclipse.mylyn.bugzilla.tests Index: src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java,v retrieving revision 1.4 diff -u -r1.4 BugzillaAttachmentHandlerTest.java --- src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java 22 Jan 2010 02:21:35 -0000 1.4 +++ src/org/eclipse/mylyn/bugzilla/tests/BugzillaAttachmentHandlerTest.java 24 Jan 2010 14:29:42 -0000 @@ -58,6 +58,173 @@ super.tearDown(); } + public void testUpdateAttachmentFlags() throws Exception { + TaskData taskData = BugzillaFixture.current().createTask(PrivilegeLevel.USER, "update of Attachment Flags", + "description for testUpdateAttachmentFlags"); + assertNotNull(taskData); + int numAttached = taskData.getAttributeMapper() + .getAttributesByType(taskData, TaskAttribute.TYPE_ATTACHMENT) + .size(); + assertEquals(0, numAttached); + assertNotNull(repository.getCredentials(AuthenticationType.REPOSITORY)); + assertNotNull(repository.getCredentials(AuthenticationType.REPOSITORY).getUserName()); + assertNotNull(repository.getCredentials(AuthenticationType.REPOSITORY).getPassword()); + BugzillaClient client = connector.getClientManager().getClient(repository, new NullProgressMonitor()); + + TaskAttribute attrAttachment = taskData.getAttributeMapper().createTaskAttachment(taskData); + TaskAttachmentMapper attachmentMapper = TaskAttachmentMapper.createFrom(attrAttachment); + /* Test uploading a proper file */ + String fileName = "test-attach-1.txt"; + File attachFile = new File(fileName); + attachFile.createNewFile(); + BufferedWriter write = new BufferedWriter(new FileWriter(attachFile)); + write.write("test file from " + System.currentTimeMillis()); + write.close(); + + FileTaskAttachmentSource attachment = new FileTaskAttachmentSource(attachFile); + attachment.setContentType("text/plain"); + attachment.setDescription("Description"); + attachment.setName("My Attachment 1"); + + try { + client.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment, + new NullProgressMonitor()); + } catch (Exception e) { + fail("never reach this!"); + } + taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client); + assertNotNull(taskData); + numAttached = taskData.getAttributeMapper().getAttributesByType(taskData, TaskAttribute.TYPE_ATTACHMENT).size(); + assertEquals(1, numAttached); + TaskAttribute attachmentAttribute = taskData.getAttributeMapper().getAttributesByType(taskData, + TaskAttribute.TYPE_ATTACHMENT).get(0); + int flagCount = 0; + int flagCountUnused = 0; + TaskAttribute attachmentFlag1 = null; + TaskAttribute attachmentFlag2 = null; + for (TaskAttribute attribute : attachmentAttribute.getAttributes().values()) { + if (!attribute.getId().startsWith("task.common.kind.flag")) { //$NON-NLS-1$ + continue; + } + flagCount++; + if (attribute.getId().startsWith("task.common.kind.flag_type")) { //$NON-NLS-1$ + flagCountUnused++; + TaskAttribute stateAttribute = taskData.getAttributeMapper().getAssoctiatedAttribute(attribute); + if (stateAttribute.getMetaData().getLabel().equals("AttachmentFlag1")) { + attachmentFlag1 = attribute; + } + if (stateAttribute.getMetaData().getLabel().equals("AttachmentFlag2")) { + attachmentFlag2 = attribute; + } + } + } + assertEquals(2, flagCount); + assertEquals(2, flagCountUnused); + assertNotNull(attachmentFlag1); + assertNotNull(attachmentFlag2); + TaskAttribute stateAttribute1 = taskData.getAttributeMapper().getAssoctiatedAttribute(attachmentFlag1); + stateAttribute1.setValue("?"); + TaskAttribute requestee = attachmentFlag1.getAttribute("requestee"); //$NON-NLS-1$ + requestee.setValue("guest@mylyn.eclipse.org"); + client.postUpdateAttachment(attachmentAttribute, "update", null); + taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client); + assertNotNull(taskData); + attachmentAttribute = taskData.getAttributeMapper() + .getAttributesByType(taskData, TaskAttribute.TYPE_ATTACHMENT) + .get(0); + assertNotNull(attachmentAttribute); + flagCount = 0; + flagCountUnused = 0; + attachmentFlag1 = null; + attachmentFlag2 = null; + TaskAttribute attachmentFlag1used = null; + TaskAttribute attachmentFlag2used = null; + + for (TaskAttribute attribute : attachmentAttribute.getAttributes().values()) { + if (!attribute.getId().startsWith("task.common.kind.flag")) { //$NON-NLS-1$ + continue; + } + flagCount++; + if (attribute.getId().startsWith("task.common.kind.flag_type")) { //$NON-NLS-1$ + flagCountUnused++; + TaskAttribute stateAttribute = taskData.getAttributeMapper().getAssoctiatedAttribute(attribute); + if (stateAttribute.getMetaData().getLabel().equals("AttachmentFlag1")) { + attachmentFlag1 = attribute; + } + if (stateAttribute.getMetaData().getLabel().equals("AttachmentFlag2")) { + attachmentFlag2 = attribute; + } + } else { + TaskAttribute stateAttribute = taskData.getAttributeMapper().getAssoctiatedAttribute(attribute); + if (stateAttribute.getMetaData().getLabel().equals("AttachmentFlag1")) { + attachmentFlag1used = attribute; + } + if (stateAttribute.getMetaData().getLabel().equals("AttachmentFlag2")) { + attachmentFlag2used = attribute; + } + } + + } + assertEquals(3, flagCount); + assertEquals(2, flagCountUnused); + assertNotNull(attachmentFlag1); + assertNotNull(attachmentFlag2); + assertNotNull(attachmentFlag1used); + assertNull(attachmentFlag2used); + TaskAttribute stateAttribute1used = taskData.getAttributeMapper().getAssoctiatedAttribute(attachmentFlag1used); + TaskAttribute requesteeused = attachmentFlag1used.getAttribute("requestee"); //$NON-NLS-1$ + assertNotNull(stateAttribute1used); + assertNotNull(requesteeused); + assertEquals("?", stateAttribute1used.getValue()); + assertEquals("guest@mylyn.eclipse.org", requesteeused.getValue()); + stateAttribute1used.setValue(" "); + client.postUpdateAttachment(attachmentAttribute, "update", null); + taskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client); + assertNotNull(taskData); + attachmentAttribute = taskData.getAttributeMapper() + .getAttributesByType(taskData, TaskAttribute.TYPE_ATTACHMENT) + .get(0); + assertNotNull(attachmentAttribute); + flagCount = 0; + flagCountUnused = 0; + attachmentFlag1 = null; + attachmentFlag2 = null; + attachmentFlag1used = null; + attachmentFlag2used = null; + + for (TaskAttribute attribute : attachmentAttribute.getAttributes().values()) { + if (!attribute.getId().startsWith("task.common.kind.flag")) { //$NON-NLS-1$ + continue; + } + flagCount++; + if (attribute.getId().startsWith("task.common.kind.flag_type")) { //$NON-NLS-1$ + flagCountUnused++; + TaskAttribute stateAttribute = taskData.getAttributeMapper().getAssoctiatedAttribute(attribute); + if (stateAttribute.getMetaData().getLabel().equals("AttachmentFlag1")) { + attachmentFlag1 = attribute; + } + if (stateAttribute.getMetaData().getLabel().equals("AttachmentFlag2")) { + attachmentFlag2 = attribute; + } + } else { + TaskAttribute stateAttribute = taskData.getAttributeMapper().getAssoctiatedAttribute(attribute); + if (stateAttribute.getMetaData().getLabel().equals("AttachmentFlag1")) { + attachmentFlag1used = attribute; + } + if (stateAttribute.getMetaData().getLabel().equals("AttachmentFlag2")) { + attachmentFlag2used = attribute; + } + } + + } + assertEquals(2, flagCount); + assertEquals(2, flagCountUnused); + assertNotNull(attachmentFlag1); + assertNotNull(attachmentFlag2); + assertNull(attachmentFlag1used); + assertNull(attachmentFlag2used); + } + public void testAttachToExistingReport() throws Exception { TaskData taskData = BugzillaFixture.current().createTask(PrivilegeLevel.USER, null, null); assertNotNull(taskData); #P org.eclipse.mylyn.bugzilla.ui Index: plugin.xml =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/plugin.xml,v retrieving revision 1.108 diff -u -r1.108 plugin.xml --- plugin.xml 15 Nov 2009 00:38:05 -0000 1.108 +++ plugin.xml 24 Jan 2010 14:29:43 -0000 @@ -96,7 +96,7 @@ menubarPath="org.eclipse.mylyn.bugzilla.ui.attachments.mark/markadditions" tooltip="Mark attachment as not obsolete"> - + + attachmentList = sructuredSelection.toList(); + if (attachmentList != null && attachmentList.size() == 1) { + action.setEnabled(true); + } else { + action.setEnabled(false); + } + } +} Index: src/org/eclipse/mylyn/internal/bugzilla/ui/action/ChangeAttachmentJob.java =================================================================== RCS file: src/org/eclipse/mylyn/internal/bugzilla/ui/action/ChangeAttachmentJob.java diff -N src/org/eclipse/mylyn/internal/bugzilla/ui/action/ChangeAttachmentJob.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/action/ChangeAttachmentJob.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,130 @@ +/******************************************************************************* + * Copyright (c) 2009 Frank Becker 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: + * Frank Becker - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.internal.bugzilla.ui.action; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.mylyn.commons.core.StatusHandler; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler; +import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage; +import org.eclipse.mylyn.internal.provisional.commons.ui.CommonFormUtil; +import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants; +import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; +import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; +import org.eclipse.mylyn.tasks.core.ITask; +import org.eclipse.mylyn.tasks.core.ITaskAttachment; +import org.eclipse.mylyn.tasks.ui.TasksUi; +import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage; +import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.forms.editor.IFormPage; +import org.eclipse.ui.forms.widgets.Section; + +/** + * @author Frank Becker + */ +@SuppressWarnings("restriction") +public class ChangeAttachmentJob extends Job { + + private final ITaskAttachment attachment; + + private final TaskEditor editor; + + private IStatus error; + + public ChangeAttachmentJob(ITaskAttachment attachment, TaskEditor editor) { + super(Messages.UpdateAttachmentJob_update_attachment); + this.attachment = attachment; + this.editor = editor; + } + + public IStatus getError() { + return error; + } + + @Override + protected IStatus run(IProgressMonitor monitor) { + final ITask task; + task = editor.getTaskEditorInput().getTask(); + + if (!task.getConnectorKind().equals(BugzillaCorePlugin.CONNECTOR_KIND)) { + return Status.OK_STATUS; + } + AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector( + task.getConnectorKind()); + monitor.beginTask(Messages.UpdateAttachmentJob_update_attachments, 20); + try { + ((BugzillaTaskDataHandler) connector.getTaskDataHandler()).postUpdateAttachment( + attachment.getTaskRepository(), attachment.getTaskAttribute(), "update", monitor); //$NON-NLS-1$ + monitor.worked(10); + + if (attachment != null) { + if (connector != null) { + TasksUiInternal.synchronizeTask(connector, task, true, new JobChangeAdapter() { + @Override + public void done(IJobChangeEvent event) { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + try { + if (editor != null) { + editor.refreshPages(); + editor.getEditorSite().getPage().activate(editor); + IFormPage formPage = editor.getActivePageInstance(); + if (formPage instanceof BugzillaTaskEditorPage) { + BugzillaTaskEditorPage bugzillaPage = (BugzillaTaskEditorPage) formPage; + Control control = bugzillaPage.getPart( + AbstractTaskEditorPage.ID_PART_ATTACHMENTS).getControl(); + if (control instanceof Section) { + Section section = (Section) control; + CommonFormUtil.setExpanded(section, true); + } + } + + } + } finally { + if (editor != null) { + editor.showBusy(false); + } + } + } + }); + } + }); + } + monitor.worked(10); + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + if (editor != null) { + editor.showBusy(true); + } + } + }); + } + } catch (OperationCanceledException e) { + return Status.CANCEL_STATUS; + } catch (CoreException e) { + StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, + "Update of an Attachment failed", e)); //$NON-NLS-1$ + } finally { + monitor.done(); + } + return Status.OK_STATUS; + } +} Index: src/org/eclipse/mylyn/internal/bugzilla/ui/action/Messages.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/Messages.java,v retrieving revision 1.4 diff -u -r1.4 Messages.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/action/Messages.java 24 Jul 2009 12:08:07 -0000 1.4 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/action/Messages.java 24 Jan 2010 14:29:44 -0000 @@ -29,4 +29,5 @@ public static String UpdateAttachmentJob_update_attachment; + public static String BugzillaAttachmentUpdateAction_Comment; } Index: src/org/eclipse/mylyn/internal/bugzilla/ui/action/messages.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/messages.properties,v retrieving revision 1.4 diff -u -r1.4 messages.properties --- src/org/eclipse/mylyn/internal/bugzilla/ui/action/messages.properties 24 Jul 2009 12:08:07 -0000 1.4 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/action/messages.properties 24 Jan 2010 14:29:44 -0000 @@ -10,3 +10,4 @@ ############################################################################### UpdateAttachmentJob_update_attachment=Update attachment UpdateAttachmentJob_update_attachments=Update attachments +BugzillaAttachmentUpdateAction_Comment=Comment: Index: src/org/eclipse/mylyn/internal/bugzilla/ui/dialogs/BugzillaAttachmentDialog.java =================================================================== RCS file: src/org/eclipse/mylyn/internal/bugzilla/ui/dialogs/BugzillaAttachmentDialog.java diff -N src/org/eclipse/mylyn/internal/bugzilla/ui/dialogs/BugzillaAttachmentDialog.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/dialogs/BugzillaAttachmentDialog.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,289 @@ +/******************************************************************************* + * Copyright (c) 2009 Frank Becker 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: + * Frank Becker - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.internal.bugzilla.ui.dialogs; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; +import org.eclipse.mylyn.internal.bugzilla.ui.tasklist.Messages; +import org.eclipse.mylyn.tasks.core.data.TaskAttribute; +import org.eclipse.mylyn.tasks.core.data.TaskDataModel; +import org.eclipse.mylyn.tasks.core.data.TaskDataModelEvent; +import org.eclipse.mylyn.tasks.core.data.TaskDataModelListener; +import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor; +import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.dialogs.SelectionDialog; +import org.eclipse.ui.forms.events.ExpansionAdapter; +import org.eclipse.ui.forms.events.ExpansionEvent; +import org.eclipse.ui.forms.widgets.ExpandableComposite; +import org.eclipse.ui.forms.widgets.FormToolkit; + +/** + * @author Frank Becker + */ +public class BugzillaAttachmentDialog extends SelectionDialog { + + private final FormToolkit toolkit; + + private Composite scrollComposite; + + private ExpandableComposite flagExpandComposite = null; + + private final TaskAttribute attachment; + + private final Shell parentShell; + + private final boolean readOnly; + + private final AttributeEditorFactory attributeEditorFactory; + + private static final int LABEL_WIDTH = 120; + + private static final int COLUMN_GAP = 5; + + private static final int MULTI_ROW_HEIGHT = 55; + + private static final int COLUMN_WIDTH = 200; + + private static final int MULTI_COLUMN_WIDTH = COLUMN_WIDTH + 5 + COLUMN_GAP + LABEL_WIDTH + 5 + COLUMN_WIDTH; + + private AbstractAttributeEditor commentEditor; + + private final TaskDataModel model; + + private boolean changed = false; + + public BugzillaAttachmentDialog(Shell parentShell, TaskDataModel model, AttributeEditorFactory factory, + TaskAttribute attachment, boolean readonly) { + super(parentShell); + this.attachment = attachment; + this.parentShell = parentShell; + this.readOnly = readonly; + attributeEditorFactory = factory; + this.model = model; + model.addModelListener(new TaskDataModelListener() { + + @Override + public void attributeChanged(TaskDataModelEvent event) { + if (!changed) { + changed = true; + getOkButton().setEnabled(changed); + + } + } + + }); + toolkit = new FormToolkit(Display.getCurrent()); + this.setTitle(readonly ? Messages.BugzillaAttachmentDialog_DetailTitle + : Messages.BugzillaAttachmentDialog_DetailTitle); + } + + @Override + protected Control createDialogArea(Composite parent) { + int currentColumn = 1; + int columnCount = 4; + Composite composite = (Composite) super.createDialogArea(parent); + + initializeDialogUnits(composite); + + Composite attributeArea = new Composite(composite, SWT.FLAT); + GridLayout layout = new GridLayout(4, false); + attributeArea.setLayout(layout); + createAttributeEditors(currentColumn, columnCount, attributeArea); + createCommentEditor(currentColumn, columnCount, attributeArea); + Composite advancedComposite = createFlagSection(attributeArea); + createFlagEditors(columnCount, advancedComposite); + createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_URL), currentColumn, columnCount, + advancedComposite); + Dialog.applyDialogFont(composite); + return composite; + } + + private void createAttributeEditor(TaskAttribute attribute, int currentColumn, int columnCount, + Composite attributeArea) { + String type = attribute.getMetaData().getType(); + if (type != null) { + AbstractAttributeEditor editor = attributeEditorFactory.createEditor(type, attribute); + if (attribute.getId().equals(BugzillaAttribute.TOKEN.getKey()) + || attribute.getId().equals("size") || attribute.getId().equals(TaskAttribute.ATTACHMENT_URL)) { //$NON-NLS-1$ + editor.setReadOnly(true); + } else { + editor.setReadOnly(readOnly); + } + if (editor.hasLabel()) { + editor.createLabelControl(attributeArea, toolkit); + Label label = editor.getLabelControl(); + label.setBackground(attributeArea.getBackground()); + String labelString = editor.getLabel(); + if (labelString != null && !labelString.equals("")) { //$NON-NLS-1$ + GridData gd = GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).hint(LABEL_WIDTH, + SWT.DEFAULT).create(); + if (currentColumn > 1) { + gd.horizontalIndent = COLUMN_GAP; + gd.widthHint = LABEL_WIDTH + COLUMN_GAP; + } + label.setLayoutData(gd); + currentColumn++; + } + } + editor.createControl(attributeArea, toolkit); + GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false); + if (type.equals(TaskAttribute.TYPE_BOOLEAN) || type.equals(TaskAttribute.TYPE_SHORT_TEXT) + || type.equals(TaskAttribute.TYPE_URL)) { + gd.horizontalSpan = 3; + } else { + gd.horizontalSpan = 1; + } + editor.getControl().setLayoutData(gd); + editor.getControl().setBackground(parentShell.getBackground()); + currentColumn += gd.horizontalSpan; + currentColumn %= columnCount; + } + } + + private void createAttributeEditors(int currentColumn, int columnCount, Composite attributeArea) { + createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_DESCRIPTION), currentColumn, + columnCount, attributeArea); + createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_FILENAME), currentColumn, + columnCount, attributeArea); + createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_SIZE), currentColumn, columnCount, + attributeArea); + createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_CONTENT_TYPE), currentColumn, + columnCount, attributeArea); + createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_PATCH), currentColumn, + columnCount, attributeArea); + createAttributeEditor(attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED), currentColumn, + columnCount, attributeArea); + } + + private void createFlagEditors(int columnCount, Composite advancedComposite) { + int currentFlagColumn = 1; + + for (TaskAttribute attribute : attachment.getAttributes().values()) { + if (!attribute.getId().startsWith("task.common.kind.flag")) { //$NON-NLS-1$ + continue; + } + String type = attribute.getMetaData().getType(); + if (type != null) { + AbstractAttributeEditor editor = attributeEditorFactory.createEditor(type, attribute); + editor.setReadOnly(readOnly); + + if (editor.hasLabel()) { + editor.createLabelControl(advancedComposite, toolkit); + Label label = editor.getLabelControl(); + label.setBackground(advancedComposite.getBackground()); + GridData gd = GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).hint(LABEL_WIDTH, + SWT.DEFAULT).create(); + if (currentFlagColumn > 1) { + gd.horizontalIndent = COLUMN_GAP; + gd.widthHint = LABEL_WIDTH + COLUMN_GAP; + } + label.setLayoutData(gd); + currentFlagColumn++; + } + editor.createControl(advancedComposite, toolkit); + GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false); + gd.widthHint = 150;//COLUMN_WIDTH; + gd.horizontalSpan = 3; + editor.getControl().setLayoutData(gd); + currentFlagColumn += gd.horizontalSpan; + currentFlagColumn %= columnCount; + editor.getControl().setBackground(parentShell.getBackground()); + } + } + } + + private void createCommentEditor(int currentColumn, int columnCount, Composite attributeArea) { + TaskAttribute commentAttribute = attachment.getAttribute("comment"); //$NON-NLS-1$ + if (commentAttribute == null || readOnly) { + return; + } + String type = commentAttribute.getMetaData().getType(); + if (type != null) { + commentEditor = attributeEditorFactory.createEditor(type, commentAttribute); + String labelString = commentEditor.getLabel(); + if (commentEditor.hasLabel()) { + commentEditor.createLabelControl(attributeArea, toolkit); + if (!labelString.equals("")) { //$NON-NLS-1$ + Label label = commentEditor.getLabelControl(); + label.setBackground(attributeArea.getBackground()); + GridData gd = GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.TOP).hint(LABEL_WIDTH, + SWT.DEFAULT).create(); + if (currentColumn > 1) { + gd.horizontalIndent = COLUMN_GAP; + gd.widthHint = LABEL_WIDTH + COLUMN_GAP; + } + label.setLayoutData(gd); + } + } + commentEditor.createControl(attributeArea, toolkit); + commentEditor.getControl().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); + GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false); + gd.heightHint = MULTI_ROW_HEIGHT; + gd.widthHint = MULTI_COLUMN_WIDTH; + gd.horizontalSpan = 2;//columnCount - currentColumn + 1; + commentEditor.getControl().setLayoutData(gd); + toolkit.paintBordersFor(attributeArea); + } + } + + private Composite createFlagSection(Composite container) { + flagExpandComposite = toolkit.createExpandableComposite(container, ExpandableComposite.COMPACT + | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR); + flagExpandComposite.setFont(container.getFont()); + flagExpandComposite.setBackground(container.getBackground()); + flagExpandComposite.setText(Messages.BugzillaTaskAttachmentPage_Advanced); + GridLayout gLayout = new GridLayout(4, false); + gLayout.horizontalSpacing = 0; + gLayout.marginWidth = 0; + flagExpandComposite.setLayout(new GridLayout(4, false)); + GridData g = new GridData(GridData.FILL_HORIZONTAL); + g.horizontalSpan = 4; + flagExpandComposite.setLayoutData(g); + flagExpandComposite.addExpansionListener(new ExpansionAdapter() { + @Override + public void expansionStateChanged(ExpansionEvent e) { + parentShell.getDisplay().getActiveShell().pack(); + } + }); + + scrollComposite = new Composite(flagExpandComposite, SWT.NONE); + GridLayout gLayout2 = new GridLayout(4, false); + gLayout2.horizontalSpacing = 0; + scrollComposite.setLayout(gLayout2); + flagExpandComposite.setClient(scrollComposite); + return scrollComposite; + } + + @Override + protected void okPressed() { + commentEditor.getControl().forceFocus(); + super.okPressed(); + } + + @Override + protected Control createButtonBar(Composite parent) { + Control control = super.createButtonBar(parent); + getOkButton().setText(Messages.BugzillaAttachmentDialog_OK_ButtonText); + getOkButton().setEnabled(changed); + return control; + } + +} \ No newline at end of file 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.42 diff -u -r1.42 BugzillaTaskEditorPage.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java 9 Jan 2010 21:07:53 -0000 1.42 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java 24 Jan 2010 14:29:46 -0000 @@ -139,7 +139,7 @@ } else if (IBugzillaConstants.EDITOR_TYPE_VOTES.equals(type)) { editor = new BugzillaVotesEditor(getModel(), taskAttribute); } else if (IBugzillaConstants.EDITOR_TYPE_FLAG.equals(type)) { - editor = new FlagAttributeEditor(getModel(), taskAttribute); + editor = new FlagAttributeEditor(getModel(), taskAttribute, 78); } else { editor = super.createEditor(type, taskAttribute); if (TaskAttribute.TYPE_BOOLEAN.equals(type)) { Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java,v retrieving revision 1.7 diff -u -r1.7 FlagAttributeEditor.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java 8 Oct 2009 05:22:11 -0000 1.7 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/FlagAttributeEditor.java 24 Jan 2010 14:29:46 -0000 @@ -20,8 +20,6 @@ import org.eclipse.mylyn.tasks.ui.editors.LayoutHint.RowSpan; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; @@ -41,17 +39,20 @@ private Text requesteeText; - public FlagAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) { + private final int requesteeTextHint; + + public FlagAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute, int requesteeTextHint) { super(manager, taskAttribute); setLayoutHint(new LayoutHint(RowSpan.SINGLE, ColumnSpan.SINGLE)); if (taskAttribute.getAttribute("state") != null) { //$NON-NLS-1$ setReadOnly(taskAttribute.getAttribute("state").getMetaData().isReadOnly()); //$NON-NLS-1$ } + this.requesteeTextHint = requesteeTextHint; } @Override public void createControl(Composite parent, FormToolkit toolkit) { - Composite composite = toolkit.createComposite(parent); + final Composite composite = toolkit.createComposite(parent); GridLayout layout = new GridLayout(3, false); layout.marginWidth = 1; composite.setLayout(layout); @@ -60,10 +61,21 @@ toolkit.adapt(text, false, false); text.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE); text.setText(getValueLabel()); + text.setBackground(parent.getBackground()); + text.setEditable(false); String tooltip = getTaskAttribute().getMetaData().getLabel(); if (tooltip != null) { text.setToolTipText(tooltip); } + TaskAttribute requestee = getTaskAttribute().getAttribute("requestee"); //$NON-NLS-1$ + if (!"".equals(requestee.getValue())) { //$NON-NLS-1$ + text = new Text(composite, SWT.FLAT | SWT.READ_ONLY); + toolkit.adapt(text, false, false); + text.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE); + text.setText(requestee.getValue()); + text.setBackground(parent.getBackground()); + text.setEditable(false); + } } else { combo = new CCombo(composite, SWT.FLAT | SWT.READ_ONLY); toolkit.adapt(combo, false, false); @@ -106,17 +118,8 @@ requesteeText = toolkit.createText(composite, requestee.getValue()); requesteeText.setEnabled("?".equals(getValueLabel())); //$NON-NLS-1$ GridData requesteeData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - requesteeData.widthHint = 78; + requesteeData.widthHint = requesteeTextHint; requesteeText.setLayoutData(requesteeData); - requesteeText.addFocusListener(new FocusListener() { - - public void focusGained(FocusEvent e) { - } - - public void focusLost(FocusEvent e) { - setRequestee(requesteeText.getText()); - } - }); } } toolkit.paintBordersFor(composite); @@ -149,8 +152,10 @@ public void setRequestee(String value) { TaskAttribute requestee = getTaskAttribute().getAttribute("requestee"); //$NON-NLS-1$ if (requestee != null) { - getAttributeMapper().setValue(getTaskAttribute().getAttribute("requestee"), value); //$NON-NLS-1$ - attributeChanged(); + if (!requestee.getValue().equals(value)) { + getAttributeMapper().setValue(requestee, value); + attributeChanged(); + } } } Index: src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskAttachmentPage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskAttachmentPage.java,v retrieving revision 1.6 diff -u -r1.6 BugzillaTaskAttachmentPage.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskAttachmentPage.java 21 Dec 2009 21:35:50 -0000 1.6 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaTaskAttachmentPage.java 24 Jan 2010 14:29:46 -0000 @@ -160,7 +160,7 @@ | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR); flagExpandComposite.setFont(container.getFont()); flagExpandComposite.setBackground(container.getBackground()); - flagExpandComposite.setText(Messages.BugzillaTaskAttachmentPage_flags); + flagExpandComposite.setText(Messages.BugzillaTaskAttachmentPage_Advanced); flagExpandComposite.setLayout(new GridLayout(3, false)); GridData g = new GridData(GridData.FILL_HORIZONTAL); g.horizontalSpan = 3; Index: src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/Messages.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/Messages.java,v retrieving revision 1.4 diff -u -r1.4 Messages.java --- src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/Messages.java 24 Jul 2009 12:08:07 -0000 1.4 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/Messages.java 24 Jan 2010 14:29:46 -0000 @@ -79,5 +79,10 @@ public static String BugzillaRepositorySettingsPage_Validating_server_settings; - public static String BugzillaTaskAttachmentPage_flags; + public static String BugzillaTaskAttachmentPage_Advanced; + + public static String BugzillaAttachmentDialog_DetailTitle; + + public static String BugzillaAttachmentDialog_OK_ButtonText; + } Index: src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/messages.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/messages.properties,v retrieving revision 1.4 diff -u -r1.4 messages.properties --- src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/messages.properties 24 Jul 2009 12:08:07 -0000 1.4 +++ src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/messages.properties 24 Jan 2010 14:29:46 -0000 @@ -38,4 +38,6 @@ BugzillaRepositorySettingsPage_Server_URL_is_invalid=Server URL is invalid. BugzillaRepositorySettingsPage_supports_bugzilla_X=Supports Bugzilla {0} BugzillaRepositorySettingsPage_Validating_server_settings=Validating server settings -BugzillaTaskAttachmentPage_flags=Flags +BugzillaTaskAttachmentPage_Advanced=Advanced +BugzillaAttachmentDialog_DetailTitle=Attachment Details +BugzillaAttachmentDialog_OK_ButtonText=Update