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 (-20 / +63 lines)
Lines 344-349 Link Here
344
			try {
344
			try {
345
				getTaskEditorPage().setReflow(false);
345
				getTaskEditorPage().setReflow(false);
346
346
347
				changeExpansionStateOfSection("older", false);
348
				changeExpansionStateOfSection("recent", false);
349
347
				for (ExpandableComposite composite : commentComposites) {
350
				for (ExpandableComposite composite : commentComposites) {
348
					if (composite.isDisposed()) {
351
					if (composite.isDisposed()) {
349
						continue;
352
						continue;
Lines 368-401 Link Here
368
				EditorUtil.toggleExpandableComposite(true, section);
371
				EditorUtil.toggleExpandableComposite(true, section);
369
			}
372
			}
370
373
371
			if (subSections != null) {
374
			int state = getExpansionState();
372
				// first toggle on all subSections
375
			if (state >= 2) {
373
				if (section != null) {
376
				changeExpansionStateOfSection("older", true);
374
					EditorUtil.toggleExpandableComposite(true, section);
375
				}
376
377
				for (Section subSection : subSections) {
378
					if (subSection.isDisposed()) {
379
						continue;
380
					}
381
					EditorUtil.toggleExpandableComposite(true, subSection);
382
				}
383
			}
377
			}
384
378
			if (state >= 1) {
385
			for (ExpandableComposite composite : commentComposites) {
379
				changeExpansionStateOfSection("recent", true);
386
				if (composite.isDisposed()) {
387
					continue;
388
				}
389
				if (!composite.isExpanded()) {
390
					EditorUtil.toggleExpandableComposite(true, composite);
391
				}
392
			}
380
			}
381
			expandCurrent();
393
		} finally {
382
		} finally {
394
			getTaskEditorPage().setReflow(true);
383
			getTaskEditorPage().setReflow(true);
395
		}
384
		}
396
		getTaskEditorPage().reflow();
385
		getTaskEditorPage().reflow();
397
	}
386
	}
398
387
388
	private void changeExpansionStateOfSection(String string, boolean state) {
389
		if (getSection(string) != null) {
390
			EditorUtil.toggleExpandableComposite(state, getSection(string));
391
		}
392
393
	}
394
395
	private int getExpansionState() {
396
		Section recent = getSection("recent");
397
		if (recent != null && recent.isExpanded()) {
398
			return 2;
399
		}
400
		if (currentExpanded()) {
401
			return 1;
402
		}
403
		return 0;
404
	}
405
406
	private boolean currentExpanded() {
407
		for (ExpandableComposite composite : commentComposites) {
408
			if (composite.isDisposed()) {
409
				return false;
410
			}
411
			if (!composite.isExpanded()) {
412
				return false;
413
			}
414
		}
415
		return true;
416
	}
417
418
	private Section getSection(String string) {
419
		for (Section subSection : subSections) {
420
			if (subSection.isDisposed()) {
421
				continue;
422
			} else {
423
				if (subSection.getText().toLowerCase().contains(string)) {
424
					return subSection;
425
				}
426
			}
427
		}
428
		return null;
429
	}
430
431
	private void expandCurrent() {
432
		for (ExpandableComposite composite : commentComposites) {
433
			if (composite.isDisposed()) {
434
				continue;
435
			}
436
			if (!composite.isExpanded()) {
437
				EditorUtil.toggleExpandableComposite(true, composite);
438
			}
439
		}
440
	}
441
399
//	private static void toggleChildren(Composite composite, boolean expended) {
442
//	private static void toggleChildren(Composite composite, boolean expended) {
400
//		for (Control child : composite.getChildren()) {
443
//		for (Control child : composite.getChildren()) {
401
//			if (child instanceof ExpandableComposite && !child.isDisposed()) {
444
//			if (child instanceof ExpandableComposite && !child.isDisposed()) {

Return to bug 248057