Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/SortCriterion.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java14
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties1
4 files changed, 20 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java
index 45353e1ac..96554e519 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java
@@ -55,6 +55,8 @@ public class Messages extends NLS {
public static String SortKindEntry_Task_ID;
+ public static String SortKindEntry_Due_Date;
+
public static String SaveAttachmentsAction_directoryDoesntExist;
public static String SaveAttachmentsAction_directoryDoesntExist0;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/SortCriterion.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/SortCriterion.java
index b1a06d162..43a5f638d 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/SortCriterion.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/SortCriterion.java
@@ -22,7 +22,7 @@ import org.eclipse.ui.IMemento;
public class SortCriterion {
public enum SortKey {
- NONE, DATE_CREATED, PRIORITY, RANK, SUMMARY, TASK_ID, TASK_TYPE;
+ NONE, DATE_CREATED, PRIORITY, RANK, SUMMARY, TASK_ID, TASK_TYPE, DUE_DATE;
public static SortKey valueOfLabel(String label) {
for (SortKey value : values()) {
@@ -49,6 +49,8 @@ public class SortCriterion {
return Messages.SortKindEntry_Task_ID;
case TASK_TYPE:
return Messages.SortCriterion_Type;
+ case DUE_DATE:
+ return Messages.SortKindEntry_Due_Date;
default:
return null;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java
index 9cde4c63a..6f8b810bc 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java
@@ -94,6 +94,9 @@ public class TaskComparator implements Comparator<ITask> {
case TASK_TYPE:
result = compare(element1.getTaskKind(), element2.getTaskKind(), key.getDirection());
break;
+ case DUE_DATE:
+ result = sortByDueDate(element1, element2, key.getDirection());
+ break;
default: // NONE
return 0;
}
@@ -142,6 +145,17 @@ public class TaskComparator implements Comparator<ITask> {
return sortDirection * date1.compareTo(date2);
}
+ private int sortByDueDate(ITask element1, ITask element2, int sortDirection) {
+ Date date1 = element1.getDueDate();
+ Date date2 = element2.getDueDate();
+ if (date1 == null) {
+ return (date2 != null) ? sortDirection : 0;
+ } else if (date2 == null) {
+ return -sortDirection;
+ }
+ return sortDirection * date1.compareTo(date2);
+ }
+
private <T> int compare(Comparable<T> key1, T key2, int sortDirection) {
if (key1 == null) {
return (key2 != null) ? sortDirection : 0;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties
index c2dbce97a..e885e4d6a 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties
@@ -25,6 +25,7 @@ SortKindEntry_Priority=Priority
SortKindEntry_Rank=Rank
SortKindEntry_Summary=Summary
SortKindEntry_Task_ID=Task ID
+SortKindEntry_Due_Date=Due Date
SaveAttachmentsAction_directoryDoesntExist=Directory doesn't exist
SaveAttachmentsAction_directoryDoesntExist0=Directory {0} doesn't exist.

Back to the top