Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 339171 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/tasks/ui/notifications/Messages.java (+6 lines)
Lines 27-36 Link Here
27
27
28
	public static String TaskDataDiff_more_;
28
	public static String TaskDataDiff_more_;
29
29
30
	public static String TaskDiffUtil_Added_to;
31
30
	public static String TaskDiffUtil_attachment;
32
	public static String TaskDiffUtil_attachment;
31
33
34
	public static String TaskDiffUtil_CC;
35
32
	public static String TaskDiffUtil_Comment_by_X;
36
	public static String TaskDiffUtil_Comment_by_X;
33
37
38
	public static String TaskDiffUtil_Removed_from;
39
34
	public static String TaskDiffUtil_Unknown;
40
	public static String TaskDiffUtil_Unknown;
35
41
36
	public static String TaskListNotificationPopup_Mark_Task_Read;
42
	public static String TaskListNotificationPopup_Mark_Task_Read;
(-)src/org/eclipse/mylyn/internal/tasks/ui/notifications/TaskDiffUtil.java (-4 / +73 lines)
Lines 12-17 Link Here
12
package org.eclipse.mylyn.internal.tasks.ui.notifications;
12
package org.eclipse.mylyn.internal.tasks.ui.notifications;
13
13
14
import java.text.MessageFormat;
14
import java.text.MessageFormat;
15
import java.util.ArrayList;
15
import java.util.Iterator;
16
import java.util.Iterator;
16
import java.util.List;
17
import java.util.List;
17
18
Lines 20-25 Link Here
20
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
21
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
21
import org.eclipse.mylyn.tasks.core.ITaskComment;
22
import org.eclipse.mylyn.tasks.core.ITaskComment;
22
import org.eclipse.mylyn.tasks.core.data.ITaskAttributeDiff;
23
import org.eclipse.mylyn.tasks.core.data.ITaskAttributeDiff;
24
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
23
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.graphics.Drawable;
26
import org.eclipse.swt.graphics.Drawable;
25
import org.eclipse.swt.graphics.GC;
27
import org.eclipse.swt.graphics.GC;
Lines 30-35 Link Here
30
 */
32
 */
31
public class TaskDiffUtil {
33
public class TaskDiffUtil {
32
34
35
	private static final int MAX_LENGTH = 68;
36
37
	private static final int ONE_SIDE_MAX_LENGTH = 28;
38
33
	private static final int MAX_CHANGED_ATTRIBUTES = 2;
39
	private static final int MAX_CHANGED_ATTRIBUTES = 2;
34
40
35
	// could use the ellipsis glyph on some platforms "\u2026"
41
	// could use the ellipsis glyph on some platforms "\u2026"
Lines 56-65 Link Here
56
				}
62
				}
57
			}
63
			}
58
64
59
			sb.append(TaskDiffUtil.trim(TaskDiffUtil.commentToString(comment), 60));
65
			String moreComments = ""; //$NON-NLS-1$
60
			if (newCommentCount > 1) {
66
			if (newCommentCount > 1) {
61
				sb.append(" (" + (newCommentCount - 1) + Messages.TaskDataDiff_more_); //$NON-NLS-1$
67
				moreComments = " (" + (newCommentCount - 1) + Messages.TaskDataDiff_more_; //$NON-NLS-1$
62
			}
68
			}
69
			sb.append(TaskDiffUtil.trim(TaskDiffUtil.commentToString(comment), MAX_LENGTH - moreComments.length())
70
					+ moreComments);
63
			sep = "\n"; //$NON-NLS-1$
71
			sep = "\n"; //$NON-NLS-1$
64
		}
72
		}
65
		// append changed attributes		
73
		// append changed attributes		
Lines 72-89 Link Here
72
				sb.append(" "); //$NON-NLS-1$
80
				sb.append(" "); //$NON-NLS-1$
73
				sb.append(label);
81
				sb.append(label);
74
				sb.append(" "); //$NON-NLS-1$
82
				sb.append(" "); //$NON-NLS-1$
75
				sb.append(TaskDiffUtil.trim(TaskDiffUtil.listToString(attributeDiff.getRemovedValues()), 28));
83
				String removedValues = TaskDiffUtil.listToString(attributeDiff.getRemovedValues());
84
				String addedValues = TaskDiffUtil.listToString(attributeDiff.getAddedValues());
85
				int removedExtraSpace = 0, addedExtraSpace = 0;
86
				if (removedValues.length() < ONE_SIDE_MAX_LENGTH) {
87
					addedExtraSpace = ONE_SIDE_MAX_LENGTH - removedValues.length();
88
				}
89
				if (addedValues.length() < ONE_SIDE_MAX_LENGTH) {
90
					removedExtraSpace = ONE_SIDE_MAX_LENGTH - addedValues.length();
91
				}
92
				sb.append(TaskDiffUtil.trim(removedValues, ONE_SIDE_MAX_LENGTH + removedExtraSpace));
76
				sb.append(" -> "); //$NON-NLS-1$
93
				sb.append(" -> "); //$NON-NLS-1$
77
				sb.append(TaskDiffUtil.trim(TaskDiffUtil.listToString(attributeDiff.getAddedValues()), 28));
94
				sb.append(TaskDiffUtil.trim(addedValues, ONE_SIDE_MAX_LENGTH + addedExtraSpace));
78
				if (++n == MAX_CHANGED_ATTRIBUTES) {
95
				if (++n == MAX_CHANGED_ATTRIBUTES) {
79
					break;
96
					break;
80
				}
97
				}
81
				sep = "\n"; //$NON-NLS-1$
98
				sep = "\n"; //$NON-NLS-1$
82
			}
99
			}
83
		}
100
		}
101
		if (n++ < MAX_CHANGED_ATTRIBUTES) {
102
			TaskAttribute newCCAttribute = diff.getNewTaskData().getRoot().getMappedAttribute(TaskAttribute.USER_CC);
103
			TaskAttribute oldCCAttribute = null;
104
			if (diff.getOldTaskData() != null) {
105
				oldCCAttribute = diff.getOldTaskData().getRoot().getMappedAttribute(TaskAttribute.USER_CC);
106
			}
107
			if (newCCAttribute != null || oldCCAttribute != null) {
108
				TaskAttributeDiff attributeDiff = new TaskAttributeDiff(oldCCAttribute, newCCAttribute);
109
				String label = attributeDiff.getLabel();
110
				if (label == null || label.length() == 0) {
111
					label = Messages.TaskDiffUtil_CC;
112
				}
113
				String removed = valuesToString(stripDomains(attributeDiff.getRemovedValues()),
114
						Messages.TaskDiffUtil_Removed_from, label);
115
				if (removed.length() > 0) {
116
					sb.append(sep);
117
					sb.append(trim(removed, MAX_LENGTH));
118
					sep = "\n"; //$NON-NLS-1$
119
				}
120
				String added = valuesToString(stripDomains(attributeDiff.getAddedValues()),
121
						Messages.TaskDiffUtil_Added_to, label);
122
				if (added.length() > 0) {
123
					sb.append(sep);
124
					sb.append(trim(added, MAX_LENGTH));
125
					sep = "\n"; //$NON-NLS-1$
126
				}
127
			}
128
		}
84
		return sb.toString();
129
		return sb.toString();
85
	}
130
	}
86
131
132
	public static String valuesToString(List<String> values, String changeDescription, String label) {
133
		StringBuilder sb = new StringBuilder();
134
		if (!values.isEmpty()) {
135
			sb.append(" "); //$NON-NLS-1$
136
			sb.append(changeDescription);
137
			sb.append(label);
138
			sb.append(" "); //$NON-NLS-1$
139
			sb.append(TaskDiffUtil.listToString(values));
140
		}
141
		return sb.toString();
142
	}
143
144
	public static List<String> stripDomains(List<String> emails) {
145
		List<String> result = new ArrayList<String>();
146
		for (String s : emails) {
147
			int at = s.lastIndexOf('@');
148
			if (at != -1) {
149
				s = s.substring(0, at);
150
			}
151
			result.add(s);
152
		}
153
		return result;
154
	}
155
87
	public static String commentToString(ITaskComment comment) {
156
	public static String commentToString(ITaskComment comment) {
88
		StringBuilder sb = new StringBuilder();
157
		StringBuilder sb = new StringBuilder();
89
		sb.append(MessageFormat.format(Messages.TaskDiffUtil_Comment_by_X, personToString(comment.getAuthor())));
158
		sb.append(MessageFormat.format(Messages.TaskDiffUtil_Comment_by_X, personToString(comment.getAuthor())));
(-)src/org/eclipse/mylyn/internal/tasks/ui/notifications/messages.properties (+3 lines)
Lines 10-17 Link Here
10
###############################################################################
10
###############################################################################
11
TaskDataDiff_more_=\ more)
11
TaskDataDiff_more_=\ more)
12
12
13
TaskDiffUtil_Added_to=Added to 
13
TaskDiffUtil_attachment=\ attachment: 
14
TaskDiffUtil_attachment=\ attachment: 
15
TaskDiffUtil_CC=CC
14
TaskDiffUtil_Comment_by_X=Comment by {0}
16
TaskDiffUtil_Comment_by_X=Comment by {0}
17
TaskDiffUtil_Removed_from=Removed from 
15
TaskDiffUtil_Unknown=Unknown
18
TaskDiffUtil_Unknown=Unknown
16
19
17
TaskListNotificationPopup_Mark_Task_Read=Mark Task Read
20
TaskListNotificationPopup_Mark_Task_Read=Mark Task Read
(-)src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java (-2 / +2 lines)
Lines 292-298 Link Here
292
		return null;
292
		return null;
293
	}
293
	}
294
294
295
	private String getIncommingText(IRepositoryElement element) {
295
	private String getIncomingText(IRepositoryElement element) {
296
		if (element instanceof ITask) {
296
		if (element instanceof ITask) {
297
			ITask task = (ITask) element;
297
			ITask task = (ITask) element;
298
			if (task.getSynchronizationState().isIncoming()) {
298
			if (task.getSynchronizationState().isIncoming()) {
Lines 482-488 Link Here
482
			addIconAndLabel(composite, CommonImages.getImage(CommonImages.CALENDAR), activityText);
482
			addIconAndLabel(composite, CommonImages.getImage(CommonImages.CALENDAR), activityText);
483
		}
483
		}
484
484
485
		String incommingText = getIncommingText(currentTipElement);
485
		String incommingText = getIncomingText(currentTipElement);
486
		if (incommingText != null) {
486
		if (incommingText != null) {
487
			Image image = CommonImages.getImage(CommonImages.OVERLAY_SYNC_INCOMMING);
487
			Image image = CommonImages.getImage(CommonImages.OVERLAY_SYNC_INCOMMING);
488
			if (currentTipElement instanceof ITask) {
488
			if (currentTipElement instanceof ITask) {

Return to bug 339171