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 166406 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationReminder.java (+4 lines)
Lines 39-44 Link Here
39
	public String getDescription() {
39
	public String getDescription() {
40
		return null;
40
		return null;
41
	}
41
	}
42
	
43
	public String getDetails() {
44
		return null;
45
	}
42
46
43
	public String getLabel() {
47
	public String getLabel() {
44
		if (labelProvider.getText(task).length() > 40) {
48
		if (labelProvider.getText(task).length() > 40) {
(-)src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationIncoming.java (+11 lines)
Lines 29-39 Link Here
29
29
30
	private String description = null;
30
	private String description = null;
31
31
32
	private String details = null;
33
	
32
	private DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(new TaskElementLabelProvider(true),
34
	private DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(new TaskElementLabelProvider(true),
33
			PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator());
35
			PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator());
34
36
35
	private Date date;
37
	private Date date;
36
38
39
37
	public TaskListNotificationIncoming(AbstractTask task) {
40
	public TaskListNotificationIncoming(AbstractTask task) {
38
		this.task = task;
41
		this.task = task;
39
	}
42
	}
Lines 49-54 Link Here
49
	public void setDescription(String description) {
52
	public void setDescription(String description) {
50
		this.description = description;
53
		this.description = description;
51
	}
54
	}
55
	
56
	public String getDetails() {
57
		return details;
58
	}
59
	
60
	public void setDetails(String details) {
61
		this.details = details;
62
	}
52
63
53
	public void openTask() {
64
	public void openTask() {
54
65
(-)src/org/eclipse/mylyn/internal/tasks/ui/ITaskListNotification.java (+2 lines)
Lines 24-29 Link Here
24
24
25
	public String getDescription();
25
	public String getDescription();
26
26
27
	public String getDetails();
28
	
27
	public String getLabel();
29
	public String getLabel();
28
30
29
	public Image getNotificationIcon();
31
	public Image getNotificationIcon();
(-)src/org/eclipse/mylyn/internal/tasks/ui/TaskListNotificationQueryIncoming.java (+4 lines)
Lines 40-45 Link Here
40
		return hit.getSummary();
40
		return hit.getSummary();
41
	}
41
	}
42
42
43
	public String getDetails() {
44
		return null;
45
	}
46
	
43
	public String getLabel() {
47
	public String getLabel() {
44
		if (labelProvider.getText(hit).length() > 40) {
48
		if (labelProvider.getText(hit).length() > 40) {
45
			String truncated = labelProvider.getText(hit).substring(0, 35);
49
			String truncated = labelProvider.getText(hit).substring(0, 35);
(-)src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java (-22 / +64 lines)
Lines 821-840 Link Here
821
	}
821
	}
822
822
823
	public static TaskListNotificationIncoming getIncommingNotification(AbstractRepositoryConnector connector,
823
	public static TaskListNotificationIncoming getIncommingNotification(AbstractRepositoryConnector connector,
824
			AbstractTask repositoryTask) {
824
			AbstractTask task) {
825
825
826
		TaskListNotificationIncoming notification = new TaskListNotificationIncoming(repositoryTask);
826
		TaskListNotificationIncoming notification = new TaskListNotificationIncoming(task);
827
		RepositoryTaskData newTaskData = getTaskDataManager().getNewTaskData(repositoryTask.getRepositoryUrl(),
827
		RepositoryTaskData newTaskData = getTaskDataManager().getNewTaskData(task.getRepositoryUrl(), task.getTaskId());
828
				repositoryTask.getTaskId());
828
		RepositoryTaskData oldTaskData = getTaskDataManager().getOldTaskData(task.getRepositoryUrl(), task.getTaskId());
829
		RepositoryTaskData oldTaskData = getTaskDataManager().getOldTaskData(repositoryTask.getRepositoryUrl(),
830
				repositoryTask.getTaskId());
831
829
832
		if (newTaskData != null && oldTaskData != null) {
830
		if (newTaskData != null && oldTaskData != null) {
833
831
834
			String descriptionText = getChangedDescription(newTaskData, oldTaskData);
832
			notification.setDescription(getChangedDescription(newTaskData, oldTaskData));
835
			if (descriptionText != null) {
833
			notification.setDetails(getChangedAttributes(newTaskData, oldTaskData));
836
				notification.setDescription(descriptionText);
837
			}
838
834
839
			if (connector != null) {
835
			if (connector != null) {
840
				AbstractTaskDataHandler offlineHandler = connector.getTaskDataHandler();
836
				AbstractTaskDataHandler offlineHandler = connector.getTaskDataHandler();
Lines 852-858 Link Here
852
	}
848
	}
853
849
854
	private static String getChangedDescription(RepositoryTaskData newTaskData, RepositoryTaskData oldTaskData) {
850
	private static String getChangedDescription(RepositoryTaskData newTaskData, RepositoryTaskData oldTaskData) {
855
856
		String descriptionText = "";
851
		String descriptionText = "";
857
852
858
		if (newTaskData.getComments().size() > oldTaskData.getComments().size()) {
853
		if (newTaskData.getComments().size() > oldTaskData.getComments().size()) {
Lines 870-898 Link Here
870
			}
865
			}
871
		}
866
		}
872
867
873
		boolean attributeChanged = false;
868
		if (descriptionText.equals("")) {
869
			String attributes = getChangedAttributes(newTaskData, oldTaskData);
870
			if(!attributes.equals("")) {
871
				descriptionText += "Attributes changed";
872
			}
873
		}
874
		
875
		return descriptionText;
876
	}
874
877
878
	private static String getChangedAttributes(RepositoryTaskData newTaskData, RepositoryTaskData oldTaskData) {
879
		List<Change> changes = new ArrayList<Change>();
875
		for (RepositoryTaskAttribute newAttribute : newTaskData.getAttributes()) {
880
		for (RepositoryTaskAttribute newAttribute : newTaskData.getAttributes()) {
881
			List<String> newValues = newAttribute.getValues();
876
			RepositoryTaskAttribute oldAttribute = oldTaskData.getAttribute(newAttribute.getId());
882
			RepositoryTaskAttribute oldAttribute = oldTaskData.getAttribute(newAttribute.getId());
877
			if (oldAttribute == null) {
883
			if (oldAttribute == null) {
878
				attributeChanged = true;
884
				changes.add(getDiff(newAttribute.getName(), null, newValues));
879
				break;
885
				break;
880
			}
886
			}
881
			if (oldAttribute.getValue() != null && !oldAttribute.getValue().equals(newAttribute.getValue())) {
887
			List<String> oldValues = oldAttribute.getValues();
882
				attributeChanged = true;
888
			if (!oldValues.equals(newValues)) {
883
				break;
889
				changes.add(getDiff(newAttribute.getName(), oldValues, newValues));
884
			} else if (oldAttribute.getValues() != null && !oldAttribute.getValues().equals(newAttribute.getValues())) {
885
				attributeChanged = true;
886
				break;
890
				break;
887
			}
891
			}
888
		}
892
		}
893
		if (changes.isEmpty()) {
894
			return "";
895
		}
896
897
		String details = "";
898
		String sep = "";
899
		for (Change c : changes) {
900
			details += sep;
901
			if (!c.removed.isEmpty()) {
902
				details += "- " + c.field + " " + c.removed;
903
				sep = "\n";
904
			}
905
			if (!c.added.isEmpty()) {
906
				details += sep;
907
				details += "+ " + c.field + " " + c.added;
908
				sep = "\n";
909
			}
910
		}
911
		return details;
912
	}
889
913
890
		if (attributeChanged) {
914
	private static Change getDiff(String field, List<String> oldValues, List<String> newValues) {
891
			if (descriptionText.equals("")) {
915
		Change c = new Change(field, newValues); 
892
				descriptionText += "Attributes changed";
916
		if(oldValues!=null) {
917
			for (String value : oldValues) {
918
				if(c.added.contains(value)) {
919
					c.added.remove(value);
920
				} else {
921
					c.removed.add(value);
922
				}
893
			}
923
			}
894
		}
924
		}
895
		return descriptionText;
925
		return c;
896
	}
926
	}
897
927
928
	static class Change {
929
		final String field;
930
		final List<String> added;
931
		final List<String> removed = new ArrayList<String>();
932
933
		public Change(String field, List<String> newValues) {
934
			this.field = field;
935
			this.added = new ArrayList<String>(newValues);
936
		}
937
		
938
	}
939
	
898
}
940
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTipHandler.java (-1 / +9 lines)
Lines 181-192 Link Here
181
				if (connector != null) {
181
				if (connector != null) {
182
					ITaskListNotification notification = TasksUiPlugin.getIncommingNotification(connector, task);
182
					ITaskListNotification notification = TasksUiPlugin.getIncommingNotification(connector, task);
183
					if (notification != null) {
183
					if (notification != null) {
184
						String res = null;
184
						if (notification.getDescription() != null) {
185
						if (notification.getDescription() != null) {
185
							String descriptionText = notification.getDescription();
186
							String descriptionText = notification.getDescription();
186
							if (descriptionText != null && descriptionText.length() > 0) {
187
							if (descriptionText != null && descriptionText.length() > 0) {
187
								return descriptionText;
188
								res = descriptionText;
188
							}
189
							}
189
						}
190
						}
191
						if(notification.getDetails() !=null) {
192
							String details = notification.getDetails();
193
							if (details != null && details.length() > 0) {
194
								res = res==null ? details : res + "\n" + details;
195
							}
196
						}
197
						return res;
190
					}
198
					}
191
				}
199
				}
192
			}
200
			}

Return to bug 166406