Skip to main content
summaryrefslogtreecommitdiffstats
blob: d9bdbecb421c038e5b08564a00ae363db7479ce4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*******************************************************************************
 * Copyright (c) 2004 - 2005 University Of British Columbia and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     University Of British Columbia - initial API and implementation
 *******************************************************************************/

package org.eclipse.mylar.tasklist.internal.planner.ui;

import org.eclipse.jface.viewers.Viewer;
import org.eclipse.mylar.tasklist.ITask;

/**
 * @author Mik Kersten
 */
public class TaskPlanSorter extends TaskActivitySorter {

//	 {".", "Description", "Priority", "Estimated Time", "Reminder Date"};
	public final static int PRIORITY = 1;
	public final static int DESCRIPTION = 2;
	public final static int DURATION = 3;
	public final static int ESTIMATE = 4;
	public final static int REMINDER = 5;
	public static final int ICON = 0;

	private int criteria;

	public TaskPlanSorter(int criteria) {
		super(criteria);
		this.criteria = criteria;
	}

	@Override
	public int compare(Viewer viewer, Object obj1, Object obj2) {
		ITask t1 = (ITask) obj1;
		ITask t2 = (ITask) obj2;

		switch (criteria) {
			case PRIORITY:
				return comparePriority(t1, t2);
			case DESCRIPTION:
				return compareDescription(t1, t2);
			case DURATION:
				return compareDuration(t1, t2);
			case ESTIMATE:
				return compareEstimated(t1, t2);
			case REMINDER:
				return compareReminder(t1, t2);
			default:
				return 0;
		}
	}

	private int compareReminder(ITask task1, ITask task2) {
		if (task2.getReminderDate() == null) return -1;
		if (task1.getReminderDate() == null) return 1;
		if (task1.getReminderDate() == null && task2.getReminderDate() == null) return 0;
		return task2.getReminderDate().compareTo(task1.getReminderDate());
	}

//	protected int compareEstimated(ITask task1, ITask task2) {
//	if (task1.getEstimateTimeHours() > task2.getEstimateTimeHours()) {
//		return 1;
//	} else {
//		return -1;
//	}
	
//	private int compareDescription(ITask task1, ITask task2) {
//		return task1.getDescription(false).compareTo(task2.getDescription(false));
//	}
//	
//	private int comparePriority(ITask task1, ITask task2) {
//		return task1.getPriority().compareTo(task2.getPriority());
//	}
//	


}

Back to the top