Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-07-30 18:16:53 -0400
committerspingel2010-07-30 18:16:53 -0400
commitd2472afcae41daa0dec791440c255e19910233c6 (patch)
treecfbe72b0e5d637cb776f0d004844179b56230a69
parent038356266290d026205bedfd80b0169f2edb0d8f (diff)
downloadorg.eclipse.mylyn.tasks-d2472afcae41daa0dec791440c255e19910233c6.tar.gz
org.eclipse.mylyn.tasks-d2472afcae41daa0dec791440c255e19910233c6.tar.xz
org.eclipse.mylyn.tasks-d2472afcae41daa0dec791440c255e19910233c6.zip
NEW - bug 192485: add sort by last modified date to Task List
https://bugs.eclipse.org/bugs/show_bug.cgi?id=192485
-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.java16
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties1
4 files changed, 16 insertions, 7 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 96554e519..7b98b0e65 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
@@ -41,6 +41,8 @@ public class Messages extends NLS {
public static String ImportExportUtil_Tasks_and_queries_Filter0;
+ public static String SortCriterion_Modification_Date;
+
public static String SortCriterion_Type;
public static String SortKindEntry_Date_Created;
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 43a5f638d..0752ce2a3 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, DUE_DATE;
+ NONE, DATE_CREATED, PRIORITY, RANK, SUMMARY, TASK_ID, TASK_TYPE, DUE_DATE, MODIFICATION_DATE;
public static SortKey valueOfLabel(String label) {
for (SortKey value : values()) {
@@ -51,6 +51,8 @@ public class SortCriterion {
return Messages.SortCriterion_Type;
case DUE_DATE:
return Messages.SortKindEntry_Due_Date;
+ case MODIFICATION_DATE:
+ return Messages.SortCriterion_Modification_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 8d980d1e2..f27548950 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
@@ -98,6 +98,9 @@ public class TaskComparator implements Comparator<ITask> {
case DUE_DATE:
result = sortByDueDate(element1, element2, key.getDirection());
break;
+ case MODIFICATION_DATE:
+ result = sortByModificationDate(element1, element2, key.getDirection());
+ break;
default: // NONE
return 0;
}
@@ -149,12 +152,13 @@ public class TaskComparator implements Comparator<ITask> {
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);
+ return compare(date1, date2, sortDirection);
+ }
+
+ private int sortByModificationDate(ITask element1, ITask element2, int sortDirection) {
+ Date date1 = element1.getModificationDate();
+ Date date2 = element2.getModificationDate();
+ return compare(date1, date2, sortDirection);
}
private <T> int compare(Comparable<T> key1, T key2, int sortDirection) {
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 e885e4d6a..864a839ce 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
@@ -18,6 +18,7 @@ CopyAttachmentToClipboardJob_Copying_Attachment_to_Clipboard=Copying Attachment
DownloadAttachmentJob_Copy_Attachment_to_Clipboard=Copy Attachment to Clipboard
DownloadAttachmentJob_Downloading_Attachment=Downloading Attachment
ImportExportUtil_Tasks_and_queries_Filter0=Mylyn Tasks and Queries (*{0})
+SortCriterion_Modification_Date=Modification Date
SortCriterion_Type=Type
SortKindEntry_Date_Created=Date Created
SortKindEntry_None=None

Back to the top