Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2017-03-24 13:07:15 -0400
committerSam Davis2017-03-24 13:19:51 -0400
commitb81cfc5248c1ef87bd858b537ce8176328521bd7 (patch)
tree55e022caeb5cb94532d7e7a3878e1e2f8d9b74ff
parent3fe7bc9a97e262ff1553d376491e48681cc5c189 (diff)
downloadorg.eclipse.mylyn.tasks-b81cfc5248c1ef87bd858b537ce8176328521bd7.tar.gz
org.eclipse.mylyn.tasks-b81cfc5248c1ef87bd858b537ce8176328521bd7.tar.xz
org.eclipse.mylyn.tasks-b81cfc5248c1ef87bd858b537ce8176328521bd7.zip
514190: NPE expanding attachments section
Change-Id: I29a3b560bd04e7a7fcb2f53d379a8546c44423e9 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=514190
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/AttachmentTableLabelProviderTest.java12
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider.java6
2 files changed, 16 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/AttachmentTableLabelProviderTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/AttachmentTableLabelProviderTest.java
index 7497e955b..60affa198 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/AttachmentTableLabelProviderTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/AttachmentTableLabelProviderTest.java
@@ -11,6 +11,7 @@
package org.eclipse.mylyn.tasks.tests.ui.editor;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentTableLabelProvider;
import org.eclipse.mylyn.tasks.tests.TaskTestUtil;
@@ -43,4 +44,15 @@ public class AttachmentTableLabelProviderTest extends TestCase {
assertEquals("myid", labelProvider.buildTextFromEventIndex(5, attachment).getString());
}
+ public void testGetAttachmentDescription() throws Exception {
+ TaskAttachment attachment = TaskTestUtil.createMockTaskAttachment("1");
+ attachment.setDescription(null);
+ AttachmentTableLabelProvider labelProvider = new AttachmentTableLabelProvider();
+ StyledString styledString = labelProvider.buildTextFromEventIndex(1, attachment);
+ assertEquals("", styledString.getString());
+
+ attachment.setDescription("test");
+ styledString = labelProvider.buildTextFromEventIndex(1, attachment);
+ assertEquals("test", styledString.getString());
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider.java
index d667a8a41..46cea11a6 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider.java
@@ -131,10 +131,12 @@ public class AttachmentTableLabelProvider extends StyledCellLabelProvider {
}
break;
case 1:
- text.append(attachment.getDescription());
+ if (attachment.getDescription() != null) {
+ text.append(attachment.getDescription());
+ }
break;
case 2:
- Long length = attachment.getLength();
+ long length = attachment.getLength();
if (length < 0) {
text.append("-"); //$NON-NLS-1$
}

Back to the top