Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-04-22 17:30:50 +0000
committerspingel2008-04-22 17:30:50 +0000
commitae2e34b131c32dd17d759e026aba8628b5b773b1 (patch)
tree54db04af27ef61dc2e92cf8247a5b916d8675fcc /org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal
parent59debca3c9f2305263fdefc222c8b6a8d97d7bcd (diff)
downloadorg.eclipse.mylyn.tasks-ae2e34b131c32dd17d759e026aba8628b5b773b1.tar.gz
org.eclipse.mylyn.tasks-ae2e34b131c32dd17d759e026aba8628b5b773b1.tar.xz
org.eclipse.mylyn.tasks-ae2e34b131c32dd17d759e026aba8628b5b773b1.zip
NEW - bug 226822: [api] generalize task data
https://bugs.eclipse.org/bugs/show_bug.cgi?id=226822
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/AttachmentUtil.java12
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractTaskEditorPage.java11
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractTaskEditorPart.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentSizeFormatter.java16
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider2.java176
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java41
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java26
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java81
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorDescriptionPart.java3
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java8
10 files changed, 290 insertions, 86 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/AttachmentUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/AttachmentUtil.java
index 9d570be7c..175695395 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/AttachmentUtil.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/AttachmentUtil.java
@@ -31,6 +31,7 @@ import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.AbstractTask.RepositoryTaskSyncState;
+import org.eclipse.mylyn.tasks.core.data.TaskAttachment;
/**
* @author Steffen Pingel
@@ -52,8 +53,7 @@ public class AttachmentUtil {
public static boolean attachContext(AbstractAttachmentHandler attachmentHandler, TaskRepository repository,
AbstractTask task, String longComment, IProgressMonitor monitor) throws CoreException {
ContextCore.getContextManager().saveContext(task.getHandleIdentifier());
- final File sourceContextFile = ContextCore.getContextManager().getFileForContext(
- task.getHandleIdentifier());
+ final File sourceContextFile = ContextCore.getContextManager().getFileForContext(task.getHandleIdentifier());
RepositoryTaskSyncState previousState = task.getSynchronizationState();
@@ -116,6 +116,11 @@ public class AttachmentUtil {
|| CONTEXT_DESCRIPTION_LEGACY.equals(attachment.getDescription());
}
+ public static boolean isContext(TaskAttachment attachment) {
+ return CONTEXT_DESCRIPTION.equals(attachment.getDescription())
+ || CONTEXT_DESCRIPTION_LEGACY.equals(attachment.getDescription());
+ }
+
/**
* Retrieves a context stored in <code>attachment</code> from <code>task</code>.
*
@@ -125,8 +130,7 @@ public class AttachmentUtil {
AbstractTask task, RepositoryAttachment attachment, String destinationPath, IProgressMonitor monitor)
throws CoreException {
- File destinationContextFile = ContextCore.getContextManager().getFileForContext(
- task.getHandleIdentifier());
+ File destinationContextFile = ContextCore.getContextManager().getFileForContext(task.getHandleIdentifier());
// TODO: add functionality for not overwriting previous context
if (destinationContextFile.exists()) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractTaskEditorPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractTaskEditorPage.java
index 3c1049a1d..7ebccdb75 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractTaskEditorPage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractTaskEditorPage.java
@@ -172,8 +172,6 @@ public abstract class AbstractTaskEditorPage extends FormPage {
private final List<IRepositoryTaskAttributeListener> attributesListeners = new ArrayList<IRepositoryTaskAttributeListener>();
- private Section attributesSection;
-
private Action clearOutgoingAction;
private Color colorIncoming;
@@ -328,10 +326,10 @@ public abstract class AbstractTaskEditorPage extends FormPage {
initializePart(composite, attachmentPart);
}
- private void createAttributeSection() {
+ private void createAttributeSection(Composite composite) {
TaskEditorAttributePart attributePart = new TaskEditorAttributePart();
attributePart.setExpandOnCreation(expandedStateAttributes);
- initializePart(attributesSection, attributePart);
+ initializePart(composite, attributePart);
}
private void createCommentSection(Composite composite) {
@@ -421,7 +419,7 @@ public abstract class AbstractTaskEditorPage extends FormPage {
private void createSections() {
createSummarySection(editorComposite);
- createAttributeSection();
+ createAttributeSection(editorComposite);
if (needsAttachments()) {
createAttachmentSection(editorComposite);
@@ -709,7 +707,8 @@ public abstract class AbstractTaskEditorPage extends FormPage {
@Override
public boolean isDirty() {
- return getAttributeManager().isDirty() || (getManagedForm() != null && getManagedForm().isDirty());
+ return (getAttributeManager() != null && getAttributeManager().isDirty())
+ || (getManagedForm() != null && getManagedForm().isDirty());
}
@Override
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractTaskEditorPart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractTaskEditorPart.java
index 6eb324a87..61c52d502 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractTaskEditorPart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AbstractTaskEditorPart.java
@@ -31,8 +31,6 @@ public abstract class AbstractTaskEditorPart extends AbstractFormPart {
// XXX why is this required?
protected static final Font TEXT_FONT = JFaceResources.getDefaultFont();
- private TaskData taskData;
-
private Control control;
private AbstractTaskEditorPage taskEditorPage;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentSizeFormatter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentSizeFormatter.java
index d8473e3eb..2b681651a 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentSizeFormatter.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentSizeFormatter.java
@@ -33,6 +33,7 @@ import java.util.Locale;
*
* @author Willian Mitsuda
* @author Frank Becker
+ * @author Steffen Pingel
*/
public class AttachmentSizeFormatter {
@@ -56,41 +57,40 @@ public class AttachmentSizeFormatter {
}
public String format(String sizeInBytes) {
- // Ensures it can be converted to an int
if (sizeInBytes == null) {
return UNKNOWN_SIZE;
}
- int size = 0;
try {
- size = Integer.parseInt(sizeInBytes);
+ return format(Long.parseLong(sizeInBytes));
} catch (NumberFormatException e) {
return UNKNOWN_SIZE;
}
+ }
- // Discover the magnitude
+ public String format(long size) {
if (size < 0) {
return UNKNOWN_SIZE;
}
if (size < 1024) {
- // Format as byte
+ // format as byte
if (size == 1) {
return "1 byte";
}
DecimalFormat fmt = new DecimalFormat("0 bytes");
return fmt.format(size);
} else if (size >= 1024 && size <= 1048575) {
- // Format as KB
+ // format as KB
double formattedValue = size / 1024.0;
decimalFormat.applyPattern("0.00 KB");
return decimalFormat.format(formattedValue);
} else if (size >= 1048576 && size <= 1073741823) {
- // Format as MB
+ // format as MB
double formattedValue = size / 1048576.0;
decimalFormat.applyPattern("0.00 MB");
return decimalFormat.format(formattedValue);
}
- // Format as GB
+ // format as GB
double formattedValue = size / 1073741824.0;
decimalFormat.applyPattern("0.00 GB");
return decimalFormat.format(formattedValue);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider2.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider2.java
new file mode 100644
index 000000000..7a39eacc2
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/AttachmentTableLabelProvider2.java
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Mylyn project committers 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
+ *******************************************************************************/
+
+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.tasks.ui.AttachmentUtil;
+import org.eclipse.mylyn.internal.tasks.ui.TaskListColorsAndFonts;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
+import org.eclipse.mylyn.tasks.core.data.TaskAttachment;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.WorkbenchImages;
+import org.eclipse.ui.themes.IThemeManager;
+
+/**
+ * @author Mik Kersten
+ * @author Steffen Pingel
+ */
+public class AttachmentTableLabelProvider2 extends ColumnLabelProvider {
+
+ private final AttachmentSizeFormatter sizeFormatter = AttachmentSizeFormatter.getInstance();
+
+ private final IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
+
+ private static final String[] IMAGE_EXTENSIONS = { "jpg", "gif", "png", "tiff", "tif", "bmp" };
+
+ private final AttributeEditorToolkit attributeToolkit;
+
+ public AttachmentTableLabelProvider2(AttributeEditorToolkit attributeToolkit) {
+ this.attributeToolkit = attributeToolkit;
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ TaskAttachment attachment = (TaskAttachment) element;
+ if (columnIndex == 0) {
+ if (AttachmentUtil.isContext(attachment)) {
+ return TasksUiImages.getImage(TasksUiImages.CONTEXT_TRANSFER);
+ } else if (attachment.isPatch()) {
+ return TasksUiImages.getImage(TasksUiImages.ATTACHMENT_PATCH);
+ } else {
+ String filename = attachment.getSource().getName();
+ if (filename != null) {
+ int dotIndex = filename.lastIndexOf('.');
+ if (dotIndex != -1) {
+ String fileType = filename.substring(dotIndex + 1);
+ for (String element2 : IMAGE_EXTENSIONS) {
+ if (element2.equalsIgnoreCase(fileType)) {
+ return TasksUiImages.getImage(TasksUiImages.IMAGE_FILE);
+ }
+ }
+ }
+ }
+ return WorkbenchImages.getImage(ISharedImages.IMG_OBJ_FILE);
+ }
+ } else {
+ }
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ TaskAttachment attachment = (TaskAttachment) element;
+ switch (columnIndex) {
+ case 0:
+ if (AttachmentUtil.isContext(attachment)) {
+ return " Task Context";
+ } else if (attachment.isPatch()) {
+ return " Patch";
+ } else {
+ return " " + attachment.getSource().getName();
+ }
+ case 1:
+ return attachment.getDescription();
+ case 2:
+// if (attachment.isPatch()) {
+// return "patch";
+// } else {
+ return attachment.getContentType();
+// }
+ case 3:
+ return sizeFormatter.format(attachment.getSource().getLength());
+ case 4:
+ return (attachment.getAuthor() != null) ? attachment.getAuthor().toString() : "";
+ case 5:
+ return attributeToolkit.formatDate(attachment.getCreationDate());
+ }
+ return "unrecognized column";
+ }
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ // ignore
+ }
+
+ @Override
+ public void dispose() {
+ // ignore
+ }
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ // ignore
+ return false;
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ // ignore
+ }
+
+ public Color getForeground(Object element, int columnIndex) {
+ TaskAttachment att = (TaskAttachment) element;
+ if (att.isDeprecated()) {
+ return themeManager.getCurrentTheme().getColorRegistry().get(TaskListColorsAndFonts.THEME_COLOR_COMPLETED);
+ }
+ return super.getForeground(element);
+ }
+
+ public Color getBackground(Object element, int columnIndex) {
+ return super.getBackground(element);
+ }
+
+ public Font getFont(Object element, int columnIndex) {
+ return super.getFont(element);
+ }
+
+ @Override
+ public String getToolTipText(Object element) {
+ TaskAttachment attachment = (TaskAttachment) element;
+ return "File: " + attachment.getSource().getName();
+ /*"\nFilename\t\t" + attachment.getAttributeValue("filename")
+ +"ID\t\t\t" + attachment.getAttributeValue("attachid")
+ + "\nDate\t\t\t" + attachment.getAttributeValue("date")
+ + "\nDescription\t" + attachment.getAttributeValue("desc")
+ + "\nCreator\t\t" + attachment.getCreator()
+ + "\nType\t\t\t" + attachment.getAttributeValue("type")
+ + "\nURL\t\t\t" + attachment.getAttributeValue("task.common.attachment.url");*/
+ }
+
+ @Override
+ public Point getToolTipShift(Object object) {
+ return new Point(5, 5);
+ }
+
+ @Override
+ public int getToolTipDisplayDelayTime(Object object) {
+ return 200;
+ }
+
+ @Override
+ public int getToolTipTimeDisplayed(Object object) {
+ return 5000;
+ }
+
+ @Override
+ public void update(ViewerCell cell) {
+ Object element = cell.getElement();
+ cell.setText(getColumnText(element, cell.getColumnIndex()));
+ Image image = getColumnImage(element, cell.getColumnIndex());
+ cell.setImage(image);
+ cell.setBackground(getBackground(element));
+ cell.setForeground(getForeground(element));
+ cell.setFont(getFont(element));
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java
index 3f1dffbb0..266f617fe 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java
@@ -202,7 +202,7 @@ public class TaskEditorActionPart extends AbstractTaskEditorPart {
public void createControl(Composite parent, FormToolkit toolkit) {
Section section = createSection(parent, toolkit, true);
- Composite buttonComposite = toolkit.createComposite(parent);
+ Composite buttonComposite = toolkit.createComposite(section);
GridLayout buttonLayout = new GridLayout();
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(buttonComposite);
buttonLayout.numColumns = 4;
@@ -215,6 +215,7 @@ public class TaskEditorActionPart extends AbstractTaskEditorPart {
createRadioButtons(buttonComposite, toolkit);
createActionButtons(buttonComposite, toolkit);
+ section.setClient(buttonComposite);
setSection(toolkit, section);
}
@@ -237,27 +238,29 @@ public class TaskEditorActionPart extends AbstractTaskEditorPart {
private void createRadioButtons(Composite buttonComposite, FormToolkit toolkit) {
TaskAttribute container = getTaskData().getMappedAttribute(TaskAttribute.CONTAINER_OPERATIONS);
- Map<String, TaskAttribute> attributes = container.getAttributes();
- for (TaskAttribute attribute : attributes.values()) {
- TaskOperation operation = getTaskData().getAttributeMapper().getTaskOperation(attribute);
- if (operation != null) {
- Button button = toolkit.createButton(buttonComposite, operation.getLabel(), SWT.RADIO);
- button.setData(operation);
- GridData radioData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- TaskAttribute associatedAttribute = getTaskData().getAttributeMapper().getAssoctiatedAttribute(
- attribute);
- if (associatedAttribute != null) {
- radioData.horizontalSpan = 1;
- addAttribute(buttonComposite, toolkit, associatedAttribute, button);
- } else {
- radioData.horizontalSpan = 4;
+ if (container != null) {
+ Map<String, TaskAttribute> attributes = container.getAttributes();
+ operationButtons = new ArrayList<Button>();
+ for (TaskAttribute attribute : attributes.values()) {
+ TaskOperation operation = getTaskData().getAttributeMapper().getTaskOperation(attribute);
+ if (operation != null) {
+ Button button = toolkit.createButton(buttonComposite, operation.getLabel(), SWT.RADIO);
+ button.setData(operation);
+ GridData radioData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ TaskAttribute associatedAttribute = getTaskData().getAttributeMapper().getAssoctiatedAttribute(
+ attribute);
+ if (associatedAttribute != null) {
+ radioData.horizontalSpan = 1;
+ addAttribute(buttonComposite, toolkit, associatedAttribute, button);
+ } else {
+ radioData.horizontalSpan = 4;
+ }
+ button.setLayoutData(radioData);
+ button.addSelectionListener(new RadioButtonListener());
+ operationButtons.add(button);
}
- button.setLayoutData(radioData);
- button.addSelectionListener(new RadioButtonListener());
- operationButtons.add(button);
}
}
-
toolkit.paintBordersFor(buttonComposite);
}
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 1ffabc5ad..e846851f2 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
@@ -9,14 +9,13 @@
package org.eclipse.mylyn.internal.tasks.ui.editors;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
@@ -26,8 +25,8 @@ import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.internal.tasks.ui.actions.AbstractTaskEditorAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.AttachAction;
import org.eclipse.mylyn.internal.tasks.ui.actions.AttachScreenshotAction;
-import org.eclipse.mylyn.tasks.core.TaskScheme;
import org.eclipse.mylyn.tasks.core.data.TaskAttachment;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -39,7 +38,6 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.internal.WorkbenchImages;
@@ -82,7 +80,7 @@ public class TaskEditorAttachmentPart extends AbstractTaskEditorPart {
private TableViewer attachmentsTableViewer;
- private List<TaskAttachment> attachments;
+ private List<TaskAttribute> attachments;
private boolean hasIncoming;
@@ -129,10 +127,14 @@ public class TaskEditorAttachmentPart extends AbstractTaskEditorPart {
}
});
- attachmentsTableViewer.setContentProvider(new AttachmentsTableContentProvider2(attachments));
+ List<TaskAttachment> attachmentList = new ArrayList<TaskAttachment>(attachments.size());
+ for (TaskAttribute attribute : attachments) {
+ attachmentList.add(getTaskData().getAttributeMapper().getTaskAttachment(attribute));
+ }
+ attachmentsTableViewer.setContentProvider(new AttachmentsTableContentProvider2(attachmentList));
- attachmentsTableViewer.setLabelProvider(new AttachmentTableLabelProvider(null, new LabelProvider(),
- PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
+ attachmentsTableViewer.setLabelProvider(new AttachmentTableLabelProvider2(
+ getTaskEditorPage().getAttributeEditorToolkit()));
attachmentsTableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
@@ -373,8 +375,12 @@ public class TaskEditorAttachmentPart extends AbstractTaskEditorPart {
}
private void initialize() {
- TaskScheme scheme = new TaskScheme(getTaskData());
- attachments = new ArrayList<TaskAttachment>(Arrays.asList(scheme.getAttachments()));
+ TaskAttribute container = getTaskData().getMappedAttribute(TaskAttribute.CONTAINER_ATTACHMENTS);
+ if (container != null) {
+ attachments = new ArrayList<TaskAttribute>(container.getAttributes().values());
+ } else {
+ attachments = Collections.emptyList();
+ }
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java
index a1e04193c..9c8221437 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java
@@ -9,6 +9,7 @@
package org.eclipse.mylyn.internal.tasks.ui.editors;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.jface.action.Action;
@@ -20,6 +21,7 @@ import org.eclipse.mylyn.internal.tasks.core.CommentQuoter;
import org.eclipse.mylyn.internal.tasks.ui.TaskListColorsAndFonts;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.RepositoryPerson;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskComment;
import org.eclipse.swt.SWT;
@@ -60,7 +62,7 @@ public class TaskEditorCommentPart extends AbstractTaskEditorPart {
private List<ExpandableComposite> commentComposites;
- private ArrayList<TaskAttribute> comments;
+ private List<TaskAttribute> comments;
private boolean hasIncoming;
@@ -70,13 +72,16 @@ public class TaskEditorCommentPart extends AbstractTaskEditorPart {
private void initialize() {
TaskAttribute container = getTaskData().getMappedAttribute(TaskAttribute.CONTAINER_COMMENTS);
- comments = new ArrayList<TaskAttribute>(container.getAttributes().values());
-
- for (TaskAttribute commentAttribute : comments) {
- if (getAttributeManager().hasIncomingChanges(commentAttribute)) {
- hasIncoming = true;
- break;
+ if (container != null) {
+ comments = new ArrayList<TaskAttribute>(container.getAttributes().values());
+ for (TaskAttribute commentAttribute : comments) {
+ if (getAttributeManager().hasIncomingChanges(commentAttribute)) {
+ hasIncoming = true;
+ break;
+ }
}
+ } else {
+ comments = Collections.emptyList();
}
}
@@ -112,33 +117,7 @@ public class TaskEditorCommentPart extends AbstractTaskEditorPart {
toolbarComp.setLayout(rowLayout);
toolbarComp.setBackground(null);
- ImageHyperlink formHyperlink = toolkit.createImageHyperlink(toolbarComp, SWT.NONE);
- formHyperlink.setBackground(null);
- formHyperlink.setFont(expandableComposite.getFont());
- formHyperlink.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- if (taskComment.getAuthor() != null
- && taskComment.getAuthor().getPersonId().equalsIgnoreCase(
- getTaskEditorPage().getTaskRepository().getUserName())) {
- formHyperlink.setImage(TasksUiImages.getImage(TasksUiImages.PERSON_ME_NARROW));
- } else {
- formHyperlink.setImage(TasksUiImages.getImage(TasksUiImages.PERSON_NARROW));
- }
-
- String authorName;
- String tooltipText;
- if (taskComment.getAuthor().getName() != null) {
- authorName = taskComment.getAuthor().getName();
- tooltipText = taskComment.getAuthor().getPersonId();
- } else {
- authorName = taskComment.getAuthor().getPersonId();
- tooltipText = null;
- }
-
- formHyperlink.setText(taskComment.getNumber() + ": " + authorName + ", "
- + getTaskEditorPage().getAttributeEditorToolkit().formatDate(taskComment.getCreationDate()));
- formHyperlink.setToolTipText(tooltipText);
- formHyperlink.setEnabled(true);
- formHyperlink.setUnderlined(false);
+ ImageHyperlink formHyperlink = createTitleHyperLink(toolkit, toolbarComp, taskComment);
final Composite toolbarButtonComp = toolkit.createComposite(toolbarComp);
RowLayout buttonCompLayout = new RowLayout();
@@ -235,6 +214,40 @@ public class TaskEditorCommentPart extends AbstractTaskEditorPart {
setSection(toolkit, section);
}
+ private ImageHyperlink createTitleHyperLink(final FormToolkit toolkit, final Composite toolbarComp,
+ final TaskComment taskComment) {
+ ImageHyperlink formHyperlink = toolkit.createImageHyperlink(toolbarComp, SWT.NONE);
+ formHyperlink.setBackground(null);
+ //formHyperlink.setFont(expandableComposite.getFont());
+ formHyperlink.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
+ RepositoryPerson author = taskComment.getAuthor();
+ if (author != null
+ && author.getPersonId().equalsIgnoreCase(getTaskEditorPage().getTaskRepository().getUserName())) {
+ formHyperlink.setImage(TasksUiImages.getImage(TasksUiImages.PERSON_ME_NARROW));
+ } else {
+ formHyperlink.setImage(TasksUiImages.getImage(TasksUiImages.PERSON_NARROW));
+ }
+ StringBuilder sb = new StringBuilder();
+ sb.append(taskComment.getNumber());
+ sb.append(": ");
+ if (author != null) {
+ if (author.getName() != null) {
+ sb.append(author.getName());
+ formHyperlink.setToolTipText(author.getPersonId());
+ } else {
+ sb.append(author.getPersonId());
+ }
+ }
+ if (taskComment.getCreationDate() != null) {
+ sb.append(", ");
+ sb.append(getTaskEditorPage().getAttributeEditorToolkit().formatDate(taskComment.getCreationDate()));
+ }
+ formHyperlink.setText(sb.toString());
+ formHyperlink.setEnabled(true);
+ formHyperlink.setUnderlined(false);
+ return formHyperlink;
+ }
+
private RepositoryTextViewer createViewer(Composite parent, FormToolkit toolkit, String text) {
TaskRepository taskRepository = getTaskEditorPage().getTaskRepository();
RepositoryTextViewer viewer = new RepositoryTextViewer(taskRepository, parent, SWT.FLAT | SWT.WRAP | SWT.MULTI);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorDescriptionPart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorDescriptionPart.java
index b359e90af..87d7caf31 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorDescriptionPart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorDescriptionPart.java
@@ -108,8 +108,7 @@ public class TaskEditorDescriptionPart extends TaskEditorRichTextPart {
public void createControl(Composite parent, FormToolkit toolkit) {
super.createControl(parent, toolkit);
- Composite composite = (Composite) getControl();
- addDuplicateDetection(composite, toolkit);
+ addDuplicateDetection(getComposite(), toolkit);
}
@Override
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java
index 424d41c95..d1720515c 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java
@@ -28,6 +28,8 @@ public class TaskEditorRichTextPart extends AbstractTaskEditorPart {
private final TaskAttribute attribute;
+ private Composite composite;
+
// /**
// * A listener for selection of the textbox where a new comment is entered in.
// */
@@ -70,11 +72,15 @@ public class TaskEditorRichTextPart extends AbstractTaskEditorPart {
return editor;
}
+ protected Composite getComposite() {
+ return composite;
+ }
+
@Override
public void createControl(Composite parent, FormToolkit toolkit) {
Section section = createSection(parent, toolkit, true);
- final Composite composite = toolkit.createComposite(parent);
+ composite = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
composite.setLayout(layout);

Back to the top