| Summary: | [Viewers] JFace StructuredViewer.preservingSelection ends up using Object.equals instead of comparer for comparing elements | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Ken Larson <bugzilla> |
| Component: | UI | Assignee: | Boris Bokowski <bokowski> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | eclipse, jason_brennan, tom.schindl |
| Version: | 3.1 | Keywords: | helpwanted |
| Target Milestone: | 3.4 M6 | ||
| Hardware: | PC | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Ken Larson
The problem with any change to this is Hashtable lookup - we cache element using a Hashtable which uses hashCode (which is spec'ed to be consistent with equals). The IElementComparer provides an alternate hash code mechanism.
The StructuredViewer is already set up to completely avoid using the elements'
equals and hashcode methods, using:
public void setComparer(IElementComparer comparer) {
this.comparer = comparer;
if (elementMap != null) {
elementMap = new CustomHashtable(elementMap, comparer);
}
}
The CustomHashtable (I believe) avoids using the Object.equals.
So it seems to me that the selection could and should use the same way of
storing and looking up elements as the list itself.
OK point taken. We should add a constructor to StructuredSelection that takes an IElementComparer. See TreeSelection, we pass in the IElementComparer when the viewer has a comparer. However, I think we can only use the element comparer in equals() if the element comparer of the other selection is identical to this selection's comparer. Should be fixed in TreeSelection.equals() as well to be consistent. Deferring Fix released to HEAD. Verified in I20080327-2251 Marking as verified. |