Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2011-09-02 18:24:47 +0000
committerFrank Becker2011-09-02 18:24:47 +0000
commit035d2db70818b997d109059f0ff6fca1487b44de (patch)
tree7211b35da8938499840e92969a338cccf6f87792
parent218ff6409520a1e0f1101e7b2e0511fac4b4214e (diff)
downloadorg.eclipse.mylyn.tasks-035d2db70818b997d109059f0ff6fca1487b44de.tar.gz
org.eclipse.mylyn.tasks-035d2db70818b997d109059f0ff6fca1487b44de.tar.xz
org.eclipse.mylyn.tasks-035d2db70818b997d109059f0ff6fca1487b44de.zip
Revert "ASSIGNED - bug 305169: Use different color for attachments marked with iplog flag https://bugs.eclipse.org/bugs/show_bug.cgi?id=305169"
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/AttachmentColumnFlags.java64
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorAttachmentPart.java30
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java17
-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/AttachmentColumnCreated.java37
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnCreator.java67
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnDefinition.java87
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnDescription.java36
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnID.java50
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnName.java59
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnSize.java43
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider.java88
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java55
13 files changed, 121 insertions, 524 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/AttachmentColumnFlags.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/AttachmentColumnFlags.java
deleted file mode 100644
index 1635a0c1a..000000000
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/AttachmentColumnFlags.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.editor;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnDefinition;
-import org.eclipse.mylyn.tasks.core.ITaskAttachment;
-import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
-import org.eclipse.swt.SWT;
-
-public class AttachmentColumnFlags extends AttachmentColumnDefinition {
- public AttachmentColumnFlags(int index) {
- super(index, 100, "Flag", SWT.LEFT, false, SWT.NONE);
- }
-
- @Override
- public String getColumnText(ITaskAttachment attachment, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- return getAttachmentFlags(attachment);
- }
-
- @Override
- public int compare(TableViewer viewer, ITaskAttachment attachment1, ITaskAttachment attachment2, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- String key1 = getAttachmentFlags(attachment1);
- String key2 = getAttachmentFlags(attachment2);
- return compare(key1, key2);
- }
-
- static String getAttachmentFlags(ITaskAttachment attachment) {
- TaskAttribute attribute = attachment.getTaskAttribute();
- String result = ""; //$NON-NLS-1$
- for (TaskAttribute attachmentAttribute : attribute.getAttributes().values()) {
- String atribID = attachmentAttribute.getId();
- if (!atribID.startsWith(BugzillaAttribute.KIND_FLAG)) {
- continue;
- }
- TaskAttribute state = attachmentAttribute.getAttribute("state"); //$NON-NLS-1$
- if (state != null) {
- if (" ".equals(state.getValue())) { //$NON-NLS-1$
- continue;
- }
- if (!"".equals(result)) { //$NON-NLS-1$
- result += ", "; //$NON-NLS-1$
- }
- result += state.getMetaData().getLabel() + state.getValue();
- }
- }
-
- return result;
- }
-
-}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorAttachmentPart.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorAttachmentPart.java
deleted file mode 100644
index 82f251b34..000000000
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorAttachmentPart.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.editor;
-
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnCreated;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnCreator;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnDefinition;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnDescription;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnID;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnName;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnSize;
-import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorAttachmentPart;
-
-public class BugzillaTaskEditorAttachmentPart extends TaskEditorAttachmentPart {
- @Override
- public AttachmentColumnDefinition[] getColumnDefinitions() {
- return new AttachmentColumnDefinition[] { new AttachmentColumnName(0), new AttachmentColumnDescription(1),
- new AttachmentColumnSize(2), new AttachmentColumnCreator(3), new AttachmentColumnCreated(4),
- new AttachmentColumnID(5), new AttachmentColumnFlags(6) };
- }
-}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
index 4e3d8e008..5ac2e55e2 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
@@ -99,7 +99,6 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
Set<TaskEditorPartDescriptor> descriptors = super.createPartDescriptors();
boolean hasPartComments = false;
boolean hasPartNewComment = false;
- boolean hasPartAttachments = false;
// remove unnecessary default editor parts
for (TaskEditorPartDescriptor taskEditorPartDescriptor : descriptors) {
if (taskEditorPartDescriptor.getId().equals(ID_PART_PEOPLE)) {
@@ -121,13 +120,6 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
break;
}
}
- for (TaskEditorPartDescriptor taskEditorPartDescriptor : descriptors) {
- if (taskEditorPartDescriptor.getId().equals(ID_PART_ATTACHMENTS)) {
- descriptors.remove(taskEditorPartDescriptor);
- hasPartAttachments = true;
- break;
- }
- }
// Add Bugzilla Planning part
try {
@@ -165,14 +157,7 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
return new BugzillaTaskEditorCommentPart();
}
}.setPath(PATH_COMMENTS));
- }
- if (hasPartAttachments) {
- descriptors.add(new TaskEditorPartDescriptor(ID_PART_ATTACHMENTS) {
- @Override
- public AbstractTaskEditorPart createPart() {
- return new BugzillaTaskEditorAttachmentPart();
- }
- }.setPath(PATH_ATTACHMENTS));
+
}
} catch (CoreException e) {
// ignore
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 b2bda831d..5226c6e24 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
@@ -14,13 +14,6 @@ package org.eclipse.mylyn.tasks.tests.ui.editor;
import junit.framework.TestCase;
import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnCreated;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnCreator;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnDefinition;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnDescription;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnID;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnName;
-import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentColumnSize;
import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentTableLabelProvider;
import org.eclipse.mylyn.tasks.tests.TaskTestUtil;
@@ -29,13 +22,10 @@ import org.eclipse.mylyn.tasks.tests.TaskTestUtil;
* @author Steffen Pingel
*/
public class AttachmentTableLabelProviderTest extends TestCase {
- private static AttachmentColumnDefinition[] columnDefinitions = { new AttachmentColumnName(0),
- new AttachmentColumnDescription(1), new AttachmentColumnSize(2), new AttachmentColumnCreator(3),
- new AttachmentColumnCreated(4), new AttachmentColumnID(5) };
public void testGetAttachmentId() {
TaskAttachment attachment = TaskTestUtil.createMockTaskAttachment("1");
- AttachmentTableLabelProvider labelProvider = new AttachmentTableLabelProvider(null, null, columnDefinitions);
+ AttachmentTableLabelProvider labelProvider = new AttachmentTableLabelProvider(null, null);
attachment.setUrl(null);
assertEquals("", labelProvider.getColumnText(attachment, 5));
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnCreated.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnCreated.java
deleted file mode 100644
index 08e747f39..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnCreated.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.tasks.ui.editors;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.mylyn.tasks.core.ITaskAttachment;
-import org.eclipse.swt.SWT;
-
-public class AttachmentColumnCreated extends AttachmentColumnDefinition {
-
- public AttachmentColumnCreated(int index) {
- super(index, 100, "Created", SWT.LEFT, true, SWT.DOWN);
- }
-
- @Override
- public String getColumnText(ITaskAttachment attachment, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- return (attachment.getCreationDate() != null) ? EditorUtil.formatDateTime(attachment.getCreationDate()) : ""; //$NON-NLS-1$
- }
-
- @Override
- public int compare(TableViewer viewer, ITaskAttachment attachment1, ITaskAttachment attachment2, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- return compare(attachment1.getCreationDate(), attachment2.getCreationDate());
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnCreator.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnCreator.java
deleted file mode 100644
index fd1f6c7c3..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnCreator.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.tasks.ui.editors;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImageManger;
-import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
-import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
-import org.eclipse.mylyn.tasks.core.ITaskAttachment;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-
-public class AttachmentColumnCreator extends AttachmentColumnDefinition {
- private final CommonImageManger imageManager = new CommonImageManger();
-
- public AttachmentColumnCreator(int index) {
- super(index, 100, "Creator", SWT.LEFT, false, SWT.NONE);
- }
-
- @Override
- public Image getColumnImage(ITaskAttachment attachment, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- if (attachment.getAuthor() != null) {
- return getAuthorImage(attachment.getAuthor(), attachment.getTaskRepository());
- }
- return null;
- }
-
- /**
- * Get author image for a specified repository person and task repository
- *
- * @param person
- * @param repository
- * @return author image
- */
- protected Image getAuthorImage(IRepositoryPerson person, TaskRepository repository) {
- if (repository != null && person != null && person.getPersonId().equals(repository.getUserName())) {
- return imageManager.getImage(CommonImages.PERSON_ME);
- } else {
- return imageManager.getImage(CommonImages.PERSON);
- }
- }
-
- @Override
- public String getColumnText(ITaskAttachment attachment, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- return (attachment.getAuthor() != null) ? attachment.getAuthor().toString() : ""; //$NON-NLS-1$
- }
-
- @Override
- public int compare(TableViewer viewer, ITaskAttachment attachment1, ITaskAttachment attachment2, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- return compare(attachment1.getAuthor().toString(), attachment2.getAuthor().toString());
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnDefinition.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnDefinition.java
deleted file mode 100644
index 7c3d75a51..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnDefinition.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.tasks.ui.editors;
-
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.mylyn.tasks.core.ITaskAttachment;
-import org.eclipse.swt.graphics.Image;
-
-public abstract class AttachmentColumnDefinition {
-
- protected <T> int compare(Comparable<T> key1, T key2) {
- if (key1 == null) {
- return (key2 != null) ? 1 : 0;
- } else if (key2 == null) {
- return -1;
- }
- return key1.compareTo(key2);
- }
-
- private final int index;
-
- private final int width;
-
- private final String label;
-
- private final int alignment;
-
- private final boolean sortColumn;
-
- private final int sortDirection;
-
- public AttachmentColumnDefinition(int index, int width, String label, int alignment, boolean sortColumn,
- int sortDirection) {
- super();
- this.index = index;
- this.width = width;
- this.label = label;
- this.alignment = alignment;
- this.sortColumn = sortColumn;
- this.sortDirection = sortDirection;
- }
-
- public int getIndex() {
- return index;
- }
-
- public int getWidth() {
- return width;
- }
-
- public String getLabel() {
- return label;
- }
-
- public int getAlignment() {
- return alignment;
- }
-
- public boolean isSortColumn() {
- return sortColumn;
- }
-
- public int getSortDirection() {
- return sortDirection;
- }
-
- public Image getColumnImage(ITaskAttachment attachment, int columnIndex) {
- return null;
- }
-
- public String getColumnText(ITaskAttachment attachment, int columnIndex) {
- return ""; //$NON-NLS-1$
- }
-
- public abstract int compare(TableViewer viewer, ITaskAttachment attachment1, ITaskAttachment attachment2,
- int columnIndex);
-
-}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnDescription.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnDescription.java
deleted file mode 100644
index 2512e6f4e..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnDescription.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.tasks.ui.editors;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.mylyn.tasks.core.ITaskAttachment;
-import org.eclipse.swt.SWT;
-
-public class AttachmentColumnDescription extends AttachmentColumnDefinition {
- public AttachmentColumnDescription(int index) {
- super(index, 150, "Description", SWT.LEFT, false, SWT.NONE);
- }
-
- @Override
- public String getColumnText(ITaskAttachment attachment, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- return attachment.getDescription();
- }
-
- @Override
- public int compare(TableViewer viewer, ITaskAttachment attachment1, ITaskAttachment attachment2, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- return compare(attachment1.getDescription(), attachment2.getDescription());
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnID.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnID.java
deleted file mode 100644
index 003baa641..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnID.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.tasks.ui.editors;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.mylyn.internal.tasks.ui.views.TaskKeyComparator;
-import org.eclipse.mylyn.tasks.core.ITaskAttachment;
-import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
-import org.eclipse.swt.SWT;
-
-public class AttachmentColumnID extends AttachmentColumnDefinition {
- TaskKeyComparator keyComparator = new TaskKeyComparator();
-
- public AttachmentColumnID(int index) {
- super(index, 0, "ID", SWT.LEFT, false, SWT.NONE);
- }
-
- @Override
- public String getColumnText(ITaskAttachment attachment, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- return getAttachmentId(attachment);
- }
-
- @Override
- public int compare(TableViewer viewer, ITaskAttachment attachment1, ITaskAttachment attachment2, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- String key1 = getAttachmentId(attachment1);
- String key2 = getAttachmentId(attachment2);
- return keyComparator.compare2(key1, key2);
- }
-
- static String getAttachmentId(ITaskAttachment attachment) {
- TaskAttribute attribute = attachment.getTaskAttribute();
- if (attribute != null) {
- return attribute.getValue();
- }
- return ""; //$NON-NLS-1$
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnName.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnName.java
deleted file mode 100644
index b07673a84..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnName.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.tasks.ui.editors;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImageManger;
-import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
-import org.eclipse.mylyn.tasks.core.ITaskAttachment;
-import org.eclipse.mylyn.tasks.ui.TasksUiImages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-
-public class AttachmentColumnName extends AttachmentColumnDefinition {
- private final CommonImageManger imageManager = new CommonImageManger();
-
- public AttachmentColumnName(int index) {
- super(index, 130, "Name", SWT.LEFT, false, SWT.NONE);
- }
-
- @Override
- public Image getColumnImage(ITaskAttachment attachment, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- if (AttachmentUtil.isContext(attachment)) {
- return imageManager.getImage(TasksUiImages.CONTEXT_TRANSFER);
- } else if (attachment.isPatch()) {
- return imageManager.getImage(TasksUiImages.TASK_ATTACHMENT_PATCH);
- } else {
- return imageManager.getFileImage(attachment.getFileName());
- }
- }
-
- @Override
- public String getColumnText(ITaskAttachment attachment, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- if (AttachmentUtil.isContext(attachment)) {
- return "Task Context";
- } else if (attachment.isPatch()) {
- return "Patch";
- } else {
- return " " + attachment.getFileName(); //$NON-NLS-1$
- }
- }
-
- @Override
- public int compare(TableViewer viewer, ITaskAttachment attachment1, ITaskAttachment attachment2, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- return compare(attachment1.getFileName(), attachment2.getFileName());
- }
-}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnSize.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnSize.java
deleted file mode 100644
index 374aa5106..000000000
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentColumnSize.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.tasks.ui.editors;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.mylyn.tasks.core.ITaskAttachment;
-import org.eclipse.swt.SWT;
-
-public class AttachmentColumnSize extends AttachmentColumnDefinition {
- private final AttachmentSizeFormatter sizeFormatter = AttachmentSizeFormatter.getInstance();
-
- public AttachmentColumnSize(int index) {
- super(index, 70, "Size", SWT.RIGHT, false, SWT.NONE);
- }
-
- @Override
- public String getColumnText(ITaskAttachment attachment, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- Long length = attachment.getLength();
- if (length < 0) {
- return "-"; //$NON-NLS-1$
- }
- return sizeFormatter.format(length);
-
- }
-
- @Override
- public int compare(TableViewer viewer, ITaskAttachment attachment1, ITaskAttachment attachment2, int columnIndex) {
- Assert.isTrue(columnIndex == getIndex());
- return compare(attachment1.getLength(), attachment2.getLength());
- }
-
-}
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 b2b3149d7..a4c2d7e2a 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
@@ -16,9 +16,15 @@ package org.eclipse.mylyn.internal.tasks.ui.editors;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImageManger;
+import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonThemes;
+import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
+import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
+import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorToolkit;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
@@ -33,27 +39,92 @@ import org.eclipse.ui.themes.IThemeManager;
*/
public class AttachmentTableLabelProvider extends ColumnLabelProvider {
+ private final AttachmentSizeFormatter sizeFormatter = AttachmentSizeFormatter.getInstance();
+
private final TaskDataModel model;
private final AttributeEditorToolkit attributeEditorToolkit;
- private final AttachmentColumnDefinition[] definitions;
+ private final CommonImageManger imageManager;
- public AttachmentTableLabelProvider(TaskDataModel model, AttributeEditorToolkit attributeEditorToolkit,
- AttachmentColumnDefinition[] definitions) {
+ public AttachmentTableLabelProvider(TaskDataModel model, AttributeEditorToolkit attributeEditorToolkit) {
this.model = model;
this.attributeEditorToolkit = attributeEditorToolkit;
- this.definitions = definitions;
+ this.imageManager = new CommonImageManger();
}
public Image getColumnImage(Object element, int columnIndex) {
ITaskAttachment attachment = (ITaskAttachment) element;
- return definitions[columnIndex].getColumnImage(attachment, columnIndex);
+ if (columnIndex == 0) {
+ if (AttachmentUtil.isContext(attachment)) {
+ return imageManager.getImage(TasksUiImages.CONTEXT_TRANSFER);
+ } else if (attachment.isPatch()) {
+ return imageManager.getImage(TasksUiImages.TASK_ATTACHMENT_PATCH);
+ } else {
+ return imageManager.getFileImage(attachment.getFileName());
+ }
+ } else if (columnIndex == 3 && attachment.getAuthor() != null) {
+ return getAuthorImage(attachment.getAuthor(), attachment.getTaskRepository());
+ }
+ return null;
+ }
+
+ /**
+ * Get author image for a specified repository person and task repository
+ *
+ * @param person
+ * @param repository
+ * @return author image
+ */
+ protected Image getAuthorImage(IRepositoryPerson person, TaskRepository repository) {
+ if (repository != null && person != null && person.getPersonId().equals(repository.getUserName())) {
+ return imageManager.getImage(CommonImages.PERSON_ME);
+ } else {
+ return imageManager.getImage(CommonImages.PERSON);
+ }
}
public String getColumnText(Object element, int columnIndex) {
ITaskAttachment attachment = (ITaskAttachment) element;
- return definitions[columnIndex].getColumnText(attachment, columnIndex);
+ switch (columnIndex) {
+ case 0:
+ if (AttachmentUtil.isContext(attachment)) {
+ return Messages.AttachmentTableLabelProvider_Task_Context;
+ } else if (attachment.isPatch()) {
+ return Messages.AttachmentTableLabelProvider_Patch;
+ } else {
+ return " " + attachment.getFileName(); //$NON-NLS-1$
+ }
+ case 1:
+ return attachment.getDescription();
+ case 2:
+ Long length = attachment.getLength();
+ if (length < 0) {
+ return "-"; //$NON-NLS-1$
+ }
+ return sizeFormatter.format(length);
+ case 3:
+ return (attachment.getAuthor() != null) ? attachment.getAuthor().toString() : ""; //$NON-NLS-1$
+ case 4:
+ return (attachment.getCreationDate() != null)
+ ? EditorUtil.formatDateTime(attachment.getCreationDate())
+ : ""; //$NON-NLS-1$
+ case 5:
+ // FIXME add id to ITaskAttachment
+ return getAttachmentId(attachment);
+ }
+ return "unrecognized column"; //$NON-NLS-1$
+ }
+
+ static String getAttachmentId(ITaskAttachment attachment) {
+ String a = attachment.getUrl();
+ if (a != null) {
+ int i = a.indexOf("?id="); //$NON-NLS-1$
+ if (i != -1) {
+ return a.substring(i + 4);
+ }
+ }
+ return ""; //$NON-NLS-1$
}
@Override
@@ -62,6 +133,11 @@ public class AttachmentTableLabelProvider extends ColumnLabelProvider {
}
@Override
+ public void dispose() {
+ imageManager.dispose();
+ }
+
+ @Override
public boolean isLabelProperty(Object element, String property) {
// ignore
return false;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java
index b98028d12..dbeb1053b 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java
@@ -41,6 +41,7 @@ import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.commands.OpenTaskAttachmentHandler;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiMenus;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskKeyComparator;
import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.Mode;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
@@ -72,27 +73,47 @@ import org.eclipse.ui.forms.widgets.Section;
* @author Steffen Pingel
*/
public class TaskEditorAttachmentPart extends AbstractTaskEditorPart {
- public AttachmentColumnDefinition[] columnDefinitions;
-
- public AttachmentColumnDefinition[] getColumnDefinitions() {
- return new AttachmentColumnDefinition[] { new AttachmentColumnName(0), new AttachmentColumnDescription(1),
- new AttachmentColumnSize(2), new AttachmentColumnCreator(3), new AttachmentColumnCreated(4),
- new AttachmentColumnID(5) };
- }
private class AttachmentTableSorter extends TableSorter {
+ TaskKeyComparator keyComparator = new TaskKeyComparator();
+
@Override
public int compare(TableViewer viewer, Object e1, Object e2, int columnIndex) {
ITaskAttachment attachment1 = (ITaskAttachment) e1;
ITaskAttachment attachment2 = (ITaskAttachment) e2;
- return columnDefinitions[columnIndex].compare(viewer, attachment1, attachment2, columnIndex);
+ switch (columnIndex) {
+ case 0:
+ return compare(attachment1.getFileName(), attachment2.getFileName());
+ case 1:
+ String description1 = attachment1.getDescription();
+ String description2 = attachment2.getDescription();
+ return compare(description1, description2);
+ case 2:
+ return compare(attachment1.getLength(), attachment2.getLength());
+ case 3:
+ return compare(attachment1.getAuthor().toString(), attachment2.getAuthor().toString());
+ case 4:
+ return compare(attachment1.getCreationDate(), attachment2.getCreationDate());
+ case 5:
+ String key1 = AttachmentTableLabelProvider.getAttachmentId(attachment1);
+ String key2 = AttachmentTableLabelProvider.getAttachmentId(attachment2);
+ return keyComparator.compare2(key1, key2);
+ }
+ return super.compare(viewer, e1, e2, columnIndex);
}
}
private static final String ID_POPUP_MENU = "org.eclipse.mylyn.tasks.ui.editor.menu.attachments"; //$NON-NLS-1$
+ private final String[] attachmentsColumns = { Messages.TaskEditorAttachmentPart_Name,
+ Messages.TaskEditorAttachmentPart_Description, /*"Type", */Messages.TaskEditorAttachmentPart_Size,
+ Messages.TaskEditorAttachmentPart_Creator, Messages.TaskEditorAttachmentPart_Created,
+ Messages.TaskEditorAttachmentPart_ID };
+
+ private final int[] attachmentsColumnWidths = { 130, 150, /*100,*/70, 100, 100, 0 };
+
private List<TaskAttribute> attachments;
private boolean hasIncoming;
@@ -105,7 +126,6 @@ public class TaskEditorAttachmentPart extends AbstractTaskEditorPart {
public TaskEditorAttachmentPart() {
setPartName(Messages.TaskEditorAttachmentPart_Attachments);
- columnDefinitions = getColumnDefinitions();
}
private void createAttachmentTable(FormToolkit toolkit, final Composite attachmentsComposite) {
@@ -120,19 +140,18 @@ public class TaskEditorAttachmentPart extends AbstractTaskEditorPart {
.applyTo(attachmentsTable);
attachmentsTable.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
- String[] attachmentsColumns = new String[columnDefinitions.length];
- for (int i = 0; i < columnDefinitions.length; i++) {
+ for (int i = 0; i < attachmentsColumns.length; i++) {
TableColumn column = new TableColumn(attachmentsTable, SWT.LEFT, i);
- column.setText(columnDefinitions[i].getLabel());
- attachmentsColumns[i] = columnDefinitions[i].getLabel();
- column.setWidth(columnDefinitions[i].getWidth());
- column.setAlignment(columnDefinitions[i].getAlignment());
+ column.setText(attachmentsColumns[i]);
+ column.setWidth(attachmentsColumnWidths[i]);
column.setMoveable(true);
- if (columnDefinitions[i].isSortColumn()) {
+ if (i == 4) {
attachmentsTable.setSortColumn(column);
- attachmentsTable.setSortDirection(columnDefinitions[i].getSortDirection());
+ attachmentsTable.setSortDirection(SWT.DOWN);
}
}
+ // size column
+ attachmentsTable.getColumn(2).setAlignment(SWT.RIGHT);
TableViewer attachmentsViewer = new TableViewer(attachmentsTable);
attachmentsViewer.setUseHashlookup(true);
@@ -150,7 +169,7 @@ public class TaskEditorAttachmentPart extends AbstractTaskEditorPart {
}
attachmentsViewer.setContentProvider(new ArrayContentProvider());
attachmentsViewer.setLabelProvider(new AttachmentTableLabelProvider(getModel(),
- getTaskEditorPage().getAttributeEditorToolkit(), columnDefinitions));
+ getTaskEditorPage().getAttributeEditorToolkit()));
attachmentsViewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
openAttachments(event);

Back to the top