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

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleTaskEditorCommentPart.java (-6 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
* Copyright (c) 2004, 2008 Tasktop Technologies and others.
2
 * Copyright (c) 2004, 2008 Tasktop Technologies and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 63-69 Link Here
63
63
64
	private void createCommentSubsections(final FormToolkit toolkit, final Composite composite,
64
	private void createCommentSubsections(final FormToolkit toolkit, final Composite composite,
65
			List<TaskAttribute> comments) {
65
			List<TaskAttribute> comments) {
66
		List<CommentGroup> commentGroups = getCommentGroupStrategy().groupCommentsFromModel(getModel());
66
		List<CommentGroup> commentGroups = getCommentGroupStrategy().groupComments(comments,
67
				getModel().getTaskRepository(), getModel().getTask(), getModel());
67
68
68
		// if there is only one subsection, then don't show it
69
		// if there is only one subsection, then don't show it
69
		if (commentGroups.size() == 1) {
70
		if (commentGroups.size() == 1) {
Lines 162-172 Link Here
162
				EditorUtil.toggleExpandableComposite(true, section);
163
				EditorUtil.toggleExpandableComposite(true, section);
163
			}
164
			}
164
165
165
			for (Section subSection : subSections) {
166
			if (subSections != null) {
166
				if (subSection.isDisposed()) {
167
				for (Section subSection : subSections) {
167
					continue;
168
					if (subSection.isDisposed()) {
169
						continue;
170
					}
171
					EditorUtil.toggleExpandableComposite(true, subSection);
168
				}
172
				}
169
				EditorUtil.toggleExpandableComposite(true, subSection);
170
			}
173
			}
171
		} finally {
174
		} finally {
172
			getTaskEditorPage().setReflow(true);
175
			getTaskEditorPage().setReflow(true);
(-)src/org/eclipse/mylyn/internal/sandbox/ui/editors/CommentGroupStrategy.java (-18 / +20 lines)
Lines 16-21 Link Here
16
16
17
import org.eclipse.mylyn.internal.tasks.core.TaskComment;
17
import org.eclipse.mylyn.internal.tasks.core.TaskComment;
18
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
18
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
19
import org.eclipse.mylyn.tasks.core.ITask;
20
import org.eclipse.mylyn.tasks.core.TaskRepository;
19
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
21
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
20
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
22
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
21
23
Lines 24-40 Link Here
24
 */
26
 */
25
public class CommentGroupStrategy {
27
public class CommentGroupStrategy {
26
	public class CommentGroup {
28
	public class CommentGroup {
27
		private final List<TaskAttribute> commentAttributes;
29
		private final List<TaskAttribute> comments;
28
30
29
		private final String groupName;
31
		private final String groupName;
30
32
31
		CommentGroup(String groupName, List<TaskAttribute> commentAttributes) {
33
		CommentGroup(String groupName, List<TaskAttribute> comments) {
32
			this.groupName = groupName;
34
			this.groupName = groupName;
33
			this.commentAttributes = commentAttributes;
35
			this.comments = comments;
34
		}
36
		}
35
37
36
		public List<TaskAttribute> getCommentAttributes() {
38
		public List<TaskAttribute> getCommentAttributes() {
37
			return commentAttributes;
39
			return comments;
38
		}
40
		}
39
41
40
		public String getGroupName() {
42
		public String getGroupName() {
Lines 42-51 Link Here
42
		}
44
		}
43
	}
45
	}
44
46
45
	private TaskComment convertToTaskComment(TaskDataModel taskDataModel, TaskAttribute commentAttribute) {
47
	private TaskComment convertToTaskComment(TaskRepository taskRepository, ITask task, TaskAttribute commentAttribute) {
46
		TaskComment taskComment = new TaskComment(taskDataModel.getTaskRepository(), taskDataModel.getTask(),
48
		TaskComment taskComment = new TaskComment(taskRepository, task, commentAttribute);
47
				commentAttribute);
49
		commentAttribute.getTaskData().getAttributeMapper().updateTaskComment(taskComment, commentAttribute);
48
		taskDataModel.getTaskData().getAttributeMapper().updateTaskComment(taskComment, commentAttribute);
49
50
50
		return taskComment;
51
		return taskComment;
51
	}
52
	}
Lines 57-82 Link Here
57
	 *            extracts groups of comment for the model
58
	 *            extracts groups of comment for the model
58
	 * @return list of comment groups. Groups will be ignored if there are no comments under them.
59
	 * @return list of comment groups. Groups will be ignored if there are no comments under them.
59
	 */
60
	 */
60
	public List<CommentGroup> groupCommentsFromModel(TaskDataModel taskDataModel) {
61
	public List<CommentGroup> groupComments(List<TaskAttribute> comments, TaskRepository taskRepository, ITask task,
61
		List<TaskAttribute> taskAttributes = taskDataModel.getTaskData().getAttributeMapper().getAttributesByType(
62
			TaskDataModel taskDataModel) {
62
				taskDataModel.getTaskData(), TaskAttribute.TYPE_COMMENT);
63
		List<CommentGroup> commentGroups = new ArrayList<CommentGroup>();
63
		List<CommentGroup> commentGroups = new ArrayList<CommentGroup>();
64
		List<TaskAttribute> comments = new ArrayList<TaskAttribute>();
65
64
66
		int currentFromIndex = -1;
65
		int currentFromIndex = -1;
67
		String currentPersonId = taskDataModel.getTaskRepository().getUserName();
66
		String currentPersonId = taskRepository.getUserName();
68
67
69
		// current
68
		// current
70
		List<TaskAttribute> current = new ArrayList<TaskAttribute>();
69
		List<TaskAttribute> current = new ArrayList<TaskAttribute>();
71
70
72
		// update task comment and get current group index
71
		// update task comment and get current group index
73
		for (int i = 0; i < taskAttributes.size(); i++) {
72
		for (int i = 0; i < comments.size(); i++) {
74
			TaskAttribute commentAttribute = taskAttributes.get(i);
73
			TaskAttribute commentAttribute = comments.get(i);
75
			final TaskComment taskComment = convertToTaskComment(taskDataModel, commentAttribute);
74
			final TaskComment taskComment = convertToTaskComment(taskRepository, task, commentAttribute);
76
			comments.add(commentAttribute);
77
75
78
			// add all incoming changes
76
			// add all incoming changes
79
			if (taskDataModel.hasIncomingChanges(taskComment.getTaskAttribute())) {
77
			if (hasIncomingChanges(taskDataModel, commentAttribute)) {
80
				current.add(commentAttribute);
78
				current.add(commentAttribute);
81
			}
79
			}
82
80
Lines 122-125 Link Here
122
120
123
		return commentGroups;
121
		return commentGroups;
124
	}
122
	}
123
124
	protected boolean hasIncomingChanges(TaskDataModel taskDataModel, TaskAttribute commentAttribute) {
125
		return taskDataModel.hasIncomingChanges(commentAttribute);
126
	}
125
}
127
}

Return to bug 247745