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

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorCommentPart.java (-5 / +48 lines)
Lines 13-19 Link Here
13
package org.eclipse.mylyn.internal.tasks.ui.editors;
13
package org.eclipse.mylyn.internal.tasks.ui.editors;
14
14
15
import java.util.ArrayList;
15
import java.util.ArrayList;
16
import java.util.HashMap;
16
import java.util.List;
17
import java.util.List;
18
import java.util.Map;
17
19
18
import org.eclipse.jface.action.Action;
20
import org.eclipse.jface.action.Action;
19
import org.eclipse.jface.action.ToolBarManager;
21
import org.eclipse.jface.action.ToolBarManager;
Lines 73-78 Link Here
73
75
74
	private boolean expandAllInProgress;
76
	private boolean expandAllInProgress;
75
77
78
	private final Map<Section, CommentGroup> subToCommentGroup = new HashMap<Section, CommentGroup>();
79
76
	public TaskEditorCommentPart() {
80
	public TaskEditorCommentPart() {
77
		setPartName("Comments");
81
		setPartName("Comments");
78
	}
82
	}
Lines 153-158 Link Here
153
				});
157
				});
154
			}
158
			}
155
		}
159
		}
160
156
		setSection(toolkit, section);
161
		setSection(toolkit, section);
157
	}
162
	}
158
163
Lines 179-184 Link Here
179
			// last group is not rendered as subsection
184
			// last group is not rendered as subsection
180
			CommentGroup lastGroup = commentGroups.get(commentGroups.size() - 1);
185
			CommentGroup lastGroup = commentGroups.get(commentGroups.size() - 1);
181
			addComments(toolkit, composite, lastGroup.getCommentAttributes());
186
			addComments(toolkit, composite, lastGroup.getCommentAttributes());
187
182
		}
188
		}
183
	}
189
	}
184
190
Lines 376-399 Link Here
376
			expandAllInProgress = true;
382
			expandAllInProgress = true;
377
			getTaskEditorPage().setReflow(false);
383
			getTaskEditorPage().setReflow(false);
378
384
385
			boolean sectionExpanded = false;
386
			if (section != null && section.isExpanded()) {
387
				sectionExpanded = true;
388
			}
389
390
			// first toggle on whole section
379
			if (section != null) {
391
			if (section != null) {
380
				EditorUtil.toggleExpandableComposite(true, section);
392
				EditorUtil.toggleExpandableComposite(true, section);
381
			}
393
			}
382
394
383
			if (subSections != null) {
395
			if (subSections != null) {
384
				// first toggle on all subSections
396
				int numberOfSectionsExpanded = getNumberOfExpandedSections(sectionExpanded);
385
				if (section != null) {
386
					EditorUtil.toggleExpandableComposite(true, section);
387
				}
388
397
398
				//add to the number of expanded sections by 1, from the bottom up
399
				int count = subSections.size();
389
				for (Section subSection : subSections) {
400
				for (Section subSection : subSections) {
390
					if (subSection.isDisposed()) {
401
					if (subSection.isDisposed()) {
402
						count--;
391
						continue;
403
						continue;
392
					}
404
					}
393
					EditorUtil.toggleExpandableComposite(true, subSection);
405
					if (count - numberOfSectionsExpanded < 1) {
406
						EditorUtil.toggleExpandableComposite(true, subSection);
407
					} else {
408
						EditorUtil.toggleExpandableComposite(false, subSection);
409
					}
410
					count--;
394
				}
411
				}
395
			}
412
			}
396
413
414
			//expand all of the individual comments 			
397
			for (ExpandableComposite composite : commentComposites) {
415
			for (ExpandableComposite composite : commentComposites) {
398
				if (composite.isDisposed()) {
416
				if (composite.isDisposed()) {
399
					continue;
417
					continue;
Lines 402-407 Link Here
402
					EditorUtil.toggleExpandableComposite(true, composite);
420
					EditorUtil.toggleExpandableComposite(true, composite);
403
				}
421
				}
404
			}
422
			}
423
405
		} finally {
424
		} finally {
406
			expandAllInProgress = false;
425
			expandAllInProgress = false;
407
			getTaskEditorPage().setReflow(true);
426
			getTaskEditorPage().setReflow(true);
Lines 420-425 Link Here
420
//		}
439
//		}
421
//	}
440
//	}
422
441
442
	private int getNumberOfExpandedSections(boolean parentSectionExpanded) {
443
		if (!parentSectionExpanded) {
444
			return 0;
445
		}
446
		int count = 0;
447
		if (subSections != null) {
448
			for (Section subSection : subSections) {
449
				if (subSection.isExpanded()) {
450
					count++;
451
				}
452
			}
453
		}
454
		if (commentComposites != null) {
455
			if (commentComposites.size() > 0) {
456
				if (commentComposites.get(commentComposites.size() - 1).isExpanded()) {
457
					count++;
458
				}
459
			}
460
		}
461
		return count;
462
	}
463
423
	private TaskComment convertToTaskComment(TaskDataModel taskDataModel, TaskAttribute commentAttribute) {
464
	private TaskComment convertToTaskComment(TaskDataModel taskDataModel, TaskAttribute commentAttribute) {
424
		TaskComment taskComment = new TaskComment(taskDataModel.getTaskRepository(), taskDataModel.getTask(),
465
		TaskComment taskComment = new TaskComment(taskDataModel.getTaskRepository(), taskDataModel.getTask(),
425
				commentAttribute);
466
				commentAttribute);
Lines 517-522 Link Here
517
		}
558
		}
518
559
519
		subSections.add(groupSection);
560
		subSections.add(groupSection);
561
		//necessary for expansion
562
		subToCommentGroup.put(groupSection, commentGroup);
520
	}
563
	}
521
564
522
	private void expandSubSection(final FormToolkit toolkit, CommentGroup commentGroup, Section subSection) {
565
	private void expandSubSection(final FormToolkit toolkit, CommentGroup commentGroup, Section subSection) {

Return to bug 248057