Bug 197166 - [Repo View] Ascending/descending sorting order in the repo view
Summary: [Repo View] Ascending/descending sorting order in the repo view
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: CVS (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P5 normal (vote)
Target Milestone: 3.4 M1   Edit
Assignee: Tomasz Zarna CLA
QA Contact:
URL:
Whiteboard: hasPatch
Keywords: contributed
Depends on: 197165
Blocks:
  Show dependency tree
 
Reported: 2007-07-19 12:12 EDT by Szymon Brandys CLA
Modified: 2007-08-07 12:26 EDT (History)
1 user (show)

See Also:


Attachments
Patch (11.16 KB, patch)
2007-07-27 12:14 EDT, Tomasz Zarna CLA
no flags Details | Diff
mylyn/context/zip (40.70 KB, application/octet-stream)
2007-07-27 12:15 EDT, Tomasz Zarna CLA
no flags Details
Patch v2 (11.33 KB, patch)
2007-07-30 12:18 EDT, Tomasz Zarna CLA
no flags Details | Diff
Patch v3 (14.90 KB, patch)
2007-07-31 08:48 EDT, Tomasz Zarna CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Szymon Brandys CLA 2007-07-19 12:12:28 EDT
We should consider adding the ascending check box to sorting order menu in the repo view.
Comment 1 Michael Valenta CLA 2007-07-19 13:43:52 EDT
For consistency, we should consider adding the same option to the Change Set model in the Synchronize view.
Comment 2 Tomasz Zarna CLA 2007-07-26 07:12:02 EDT
 (In reply to comment #1)
> For consistency, we should consider adding the same option to the Change Set
> model in the Synchronize view.

I reported bug 197944 to address this.
Comment 3 Tomasz Zarna CLA 2007-07-27 12:14:52 EDT
Created attachment 74806 [details]
Patch

Szymon, could you take a look at the patch?
Comment 4 Tomasz Zarna CLA 2007-07-27 12:15:02 EDT
Created attachment 74807 [details]
mylyn/context/zip
Comment 5 Michael Valenta CLA 2007-07-30 09:43:43 EDT
Szymon, please have a look at the attached patch.
Comment 6 Tomasz Zarna CLA 2007-07-30 12:18:39 EDT
Created attachment 74945 [details]
Patch v2

I made some changes in the patch as we discussed:
* renamed switchOrder to getReversedComparator in RepositoryComparator class
* redid part of RepositoryComparator#compare method for RepositoryRoot -- the switch/case statement. It works the same way, but I hope that the code looks cleaner now
Comment 7 Michael Valenta CLA 2007-07-30 15:44:07 EDT
I have one question. What's that advantage of encoding the the ascending/descending flag and the order flag in the same int? Given that there is never more than a few comparators around at a time, I don't know if the space savings is worth the complication this introduces in the code (i.e. it always takes a while to digest the math involved when reading the code). If you feel strongly about encoding the order and direction in the same flag, I would like to see it encapsulated in getters and setters for the two flags and not in the method that uses the flags (i.e. not in the compare method). The readability of the code can also be increased by using bit flags and masks instead of the sign (although this is more of an issue if want to include additional flags in the future).
Comment 8 Tomasz Zarna CLA 2007-07-31 08:48:45 EDT
Created attachment 75028 [details]
Patch v3

I've introduced a separate flag for the sorting order, as a consequence of that I hope the code gained on readability. I've also made some code formating, added getters and setters. Please let me know if you still think it's not enough or find any other kludges.
Comment 9 Szymon Brandys CLA 2007-07-31 09:40:09 EDT
The only thing that can be improved is to use one instance of comparator instead three (or more). Instead creating new instance, just set new parameters on the existing one and send the event that parameter (order or ascending/descending) was changed.
Comment 10 Michael Valenta CLA 2007-07-31 09:48:26 EDT
Also, it looks like you used a method on boolean that is not in Java 1.4 (parseBoolean). Until we are given the OK to move to 1.5, we need to make sure we stick to valid 1.4 syntax and class libraries. I changed the code to use valid 1.4 methods and I have released the patch to HEAD. Please verify that the change I made still has the expected behavior (i.e. options preserved over restart). 

Also, I agree with Szymon that having three instances of the comparator around is a bit wasteful and unnecessary. However, that code pre-dates the patch so I didn;t feel we needed to wait before releasing this patch. Szymon, could you log a separate bug report for that?
Comment 11 Michael Valenta CLA 2007-08-07 12:26:41 EDT
Verified in build I20070807-0010