Bug 158118 Change ViewerSorter.getComparator?
20060920 We have an API class JavaElementSorter that extends ViewerSorter. I can't change that as it would be API breaking but I was hoping that that I could still be used as both a ViewerSorter and a ViewerComparator as ViewerSorter extends ViewerComparator . Internally I changed our code to only use getComparator when comparing elements, to avoid any use of getCollator. The APi is still there, but just for API compability Unfortunatly ViewerSorter reimplements getComparator and replaces it with getCollator. This blocks all accesses to the comparator instance in the ViewerComparator. One possibility I see is: Change ViewerSorter(Collator c) to call super(c), so no overriding of getComparator is required. In our case we would call ViewerSorter(null) and overwrite getComparator and getCollator to lazy create the collator (see other bug).
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerSorter.java
/**
 * A viewer sorter is used by a {@link StructuredViewer} to reorder the elements 
 * provided by its content provider.
 * <p>
 * The default <code>compare</code> method compares elements using two steps. 
 * The first step uses the values returned from <code>category</code>. 
 * By default, all elements are in the same category. 
 * The second level is based on a case insensitive compare of the strings obtained 
 * from the content viewer's label provider via <code>ILabelProvider.getText</code>.
 * </p>
 * <p>
 * Subclasses may implement the <code>isSorterProperty</code> method;
 * they may reimplement the <code>category</code> method to provide 
 * categorization; and they may override the <code>compare</code> methods
 * to provide a totally different way of sorting elements.
 * </p>
 * <p>
 * It is recommended to use <code>ViewerComparator</code> instead.
 * </p>
 * @see IStructuredContentProvider
 * @see StructuredViewer
 */
public class ViewerSorter extends ViewerComparator {
    /**
     * The collator used to sort strings.
     */
    protected Collator collator;
    /**
     * Creates a new viewer sorter, which uses the default collator
     * to sort strings.