diff options
author | Frank Becker | 2011-09-01 18:07:26 +0000 |
---|---|---|
committer | Frank Becker | 2011-09-01 18:07:26 +0000 |
commit | 218ff6409520a1e0f1101e7b2e0511fac4b4214e (patch) | |
tree | 4b442a9f896c135e13962dad90f5fe92415c6ecb /org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor | |
parent | 655b1a2ddfbec8862f644336f942373ee658fed8 (diff) | |
download | org.eclipse.mylyn.tasks-218ff6409520a1e0f1101e7b2e0511fac4b4214e.tar.gz org.eclipse.mylyn.tasks-218ff6409520a1e0f1101e7b2e0511fac4b4214e.tar.xz org.eclipse.mylyn.tasks-218ff6409520a1e0f1101e7b2e0511fac4b4214e.zip |
ASSIGNED - bug 305169: Use different color for attachments marked with
iplog flag
https://bugs.eclipse.org/bugs/show_bug.cgi?id=305169
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor')
3 files changed, 110 insertions, 1 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 new file mode 100644 index 000000000..1635a0c1a --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/AttachmentColumnFlags.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * 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 new file mode 100644 index 000000000..82f251b34 --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorAttachmentPart.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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 5ac2e55e2..4e3d8e008 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,6 +99,7 @@ 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)) { @@ -120,6 +121,13 @@ 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 { @@ -157,7 +165,14 @@ 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 |