Bug 208363 - Second level Priority sort by id/summary
Summary: Second level Priority sort by id/summary
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: dev   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 2.2   Edit
Assignee: George Lindholm CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2007-11-01 03:27 EDT by George Lindholm CLA
Modified: 2007-12-10 21:52 EST (History)
1 user (show)

See Also:


Attachments
Use summary code to sort tasks if the priorities are equal (1.77 KB, patch)
2007-11-01 03:42 EDT, George Lindholm CLA
no flags Details | Diff
mylyn/context/zip (1.12 KB, application/octet-stream)
2007-11-01 03:42 EDT, George Lindholm CLA
no flags Details
Improved patch (11.94 KB, patch)
2007-11-15 21:52 EST, George Lindholm CLA
no flags Details | Diff
mylyn/context/zip (17.45 KB, application/octet-stream)
2007-11-15 21:52 EST, George Lindholm CLA
no flags Details
updated patch (18.20 KB, text/plain)
2007-11-21 03:20 EST, Robert Elves CLA
no flags Details
Proper sorting (215 bytes, patch)
2007-11-21 16:30 EST, George Lindholm CLA
no flags Details | Diff
mylyn/context/zip (24.18 KB, application/octet-stream)
2007-11-21 16:30 EST, George Lindholm CLA
no flags Details
Patch, again (23.31 KB, patch)
2007-11-24 17:13 EST, George Lindholm CLA
no flags Details | Diff
mylyn/context/zip (24.35 KB, application/octet-stream)
2007-11-24 17:14 EST, George Lindholm CLA
no flags Details
NPE fix (24.00 KB, patch)
2007-11-25 19:08 EST, George Lindholm CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description George Lindholm CLA 2007-11-01 03:27:13 EDT
Since the current web connector doesn't allow one to map the task priority to Mylyns internal priority code, all tasks
end up with the default P3 priority. Since the Priority sort is only for the first level, it means that the tasks end
up being show in pretty much random order. It would be nice if the tasks were sorted on a second level by the
id/summary.
Comment 1 George Lindholm CLA 2007-11-01 03:42:26 EDT
Created attachment 81834 [details]
Use summary code to sort tasks if the priorities are equal

Why the element2.getSummary() call?
Comment 2 George Lindholm CLA 2007-11-01 03:42:28 EDT
Created attachment 81835 [details]
mylyn/context/zip
Comment 3 Eugene Kuleshov CLA 2007-11-01 13:28:20 EDT
George, can you please update your patch and include extended test cases into org.eclipse.mylyn.tasks.tests.TableSorterTest ?

Also, if you are interested, it may worth to look at some optimizations. For example, getSortableSummaryFromElement() combine task key and summary for the AbstractTask, and then that string is split back into key and summary by TaskKeyComparator, which I think adds significant amount of computation for large task list.
Comment 4 George Lindholm CLA 2007-11-01 13:43:00 EDT
Eugene, I did look at at TableSorterTest and noted that it was only concerned about the whether the two
elements compared properly. It doesn't currently care how the elements are sorted. 

I'll try and come up with a sort sequence test case.

I'll see how I can optimize the code as well.
Comment 5 George Lindholm CLA 2007-11-15 21:52:41 EST
Created attachment 83022 [details]
Improved patch

Added JUnit test. Sped up performance by by-passing the string building/splitting

I created the ITaskListView interface so I could fake out TaskListView for the JUnit test
Comment 6 George Lindholm CLA 2007-11-15 21:52:42 EST
Created attachment 83023 [details]
mylyn/context/zip
Comment 7 Mik Kersten CLA 2007-11-16 19:57:54 EST
Rob: please review.
Comment 8 Robert Elves CLA 2007-11-19 13:46:55 EST
I'll review this Tuesday George.
Comment 9 Robert Elves CLA 2007-11-21 03:20:56 EST
Created attachment 83408 [details]
updated patch

George, I've clean up the api slightly so that sorting direction/column are held by the TaskListTableSorter.  It is all working nicely with the exception that perhaps in your optimization of TaskKeyComparator, when it gets to the sorting by summary it isn't working as it did previously.  With your patch applied I'm now seeing   4: foo,   44:foo2,  5: bar, 55:bar2.  This should sort as 4:foo, 5:bar, 44:foo2, 55:bar2.
Comment 10 George Lindholm CLA 2007-11-21 16:30:00 EST
Created attachment 83476 [details]
Proper sorting

Sigh, this ended up being ugly. I misunderstood the
PATTERN used to split up the task string. 

I'm not too happy with what I ended up doing to support the "XXX-NN", plus I ended up
changing the compare() signature.
Comment 11 George Lindholm CLA 2007-11-21 16:30:03 EST
Created attachment 83477 [details]
mylyn/context/zip
Comment 12 Robert Elves CLA 2007-11-24 12:28:31 EST
George, your last patch doesn't contain code but rather the comment text? Might be a bugzilla bug? Anyway, if you don't mind could you try re-attaching your patch?
Comment 13 George Lindholm CLA 2007-11-24 17:13:58 EST
Created attachment 83706 [details]
Patch, again

See if it gets through the system this time.
Comment 14 George Lindholm CLA 2007-11-24 17:14:00 EST
Created attachment 83707 [details]
mylyn/context/zip
Comment 15 Robert Elves CLA 2007-11-25 02:50:16 EST
This is looking great so far.  Just one outstanding issue related to sorting of LocalTasks.  I can create an npe if sorting a few local tasks by priority:

	public void testLocalTaskSort() {
		final TaskListTableSorter sorter = new TaskListTableSorter(TaskListView.getFromActivePerspective());
		AbstractTask task1 = new LocalTask("1", "task1");
		AbstractTask task2 = new LocalTask("2", "task2");
		AbstractTask task3 = new LocalTask("3", "task3");
		AbstractTask[] tasks = { task1, task2, task3 };
		sorter.sort(new EmptyViewer(), tasks);
	}

We'll need to guard against nulls within the comparator.  Once we have this covered by unit tests I think we're done here!

java.lang.NullPointerException
at org.eclipse.mylyn.internal.tasks.ui.views.TaskKeyComparator.compare(TaskKeyComparator.java:32)
at org.eclipse.mylyn.internal.context.ui.TaskListInterestSorter.compareKeys(TaskListInterestSorter.java:189)
at org.eclipse.mylyn.internal.context.ui.TaskListInterestSorter.comparePrioritiesAndKeys(TaskListInterestSorter.java:181)
at org.eclipse.mylyn.internal.context.ui.TaskListInterestSorter.compare(TaskListInterestSorter.java:113)
at org.eclipse.jface.viewers.ViewerComparator$1.compare(ViewerComparator.java:187)
at java.util.Arrays.mergeSort(Arrays.java:1270)
at java.util.Arrays.sort(Arrays.java:1210)
Comment 16 George Lindholm CLA 2007-11-25 19:08:22 EST
Created attachment 83728 [details]
NPE fix

Don't try to compare using a null task value
Comment 17 Robert Elves CLA 2007-11-26 14:34:29 EST
Great! Patch applied, ip log update. Flagged as noteworthy since this is such a nice yet subtle feature.
Comment 18 Robert Elves CLA 2007-11-26 14:35:02 EST
Marking resolved.
Comment 19 Mik Kersten CLA 2007-11-26 21:15:38 EST
Rob: how is this going to be explicit in the UI?  Don't we need to change the "Sort by -> Priority" label to be "Sort by -> Priority then Summary"?  Either that or we can add a rule to each manual sorter that it defaults to Summary if it finds two equal entries.  I suggest the latter.
Comment 20 Eugene Kuleshov CLA 2007-11-26 21:34:42 EST
+1 for using summary as second level sorting without cluttering sorting description
Comment 21 Robert Elves CLA 2007-11-26 22:01:36 EST
 (In reply to comment #19)
> Rob: how is this going to be explicit in the UI?  Don't we need to change the
> "Sort by -> Priority" label to be "Sort by -> Priority then Summary"?  Either
> that or we can add a rule to each manual sorter that it defaults to Summary if
> it finds two equal entries.  I suggest the latter.
I like the default to summary option.  At some point we could investigate using a dialog where sort order can be configured but I think that might be over kill at this point.
Comment 22 Mik Kersten CLA 2007-12-10 21:52:43 EST
Sounds fine.