Package org.eclipse.handly.ui.viewer
Class LabelComparator
java.lang.Object
org.eclipse.jface.viewers.ViewerComparator
org.eclipse.handly.ui.viewer.LabelComparator
public class LabelComparator
extends org.eclipse.jface.viewers.ViewerComparator
Compares elements based on the strings obtained from the content viewer's
label provider.
This class supports label providers besides ILabelProvider
, such as
DelegatingStyledCellLabelProvider.IStyledLabelProvider
and DelegatingStyledCellLabelProvider
.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns a negative, zero, or positive number depending on whether the first element is less than, equal to, or greater than the second element.protected String
Returns the label string for the given viewer element to use for sorting the viewer's contents.Methods inherited from class org.eclipse.jface.viewers.ViewerComparator
category, getComparator, isSorterProperty, sort
-
Constructor Details
-
LabelComparator
public LabelComparator()
-
-
Method Details
-
compare
Returns a negative, zero, or positive number depending on whether the first element is less than, equal to, or greater than the second element.This implementation is based on comparing the elements' categories as computed by the
ViewerComparator.category(Object)
method. Elements within the same category are further subjected to comparing their label strings as computed by thegetLabel(Viewer, Object)
method. The label strings are compared using the comparator provided by theViewerComparator.getComparator()
method.- Overrides:
compare
in classorg.eclipse.jface.viewers.ViewerComparator
-
getLabel
Returns the label string for the given viewer element to use for sorting the viewer's contents.This implementation returns the label string obtained from the content viewer's label provider.
- Parameters:
viewer
- the viewerelement
- the element- Returns:
- the label string for the given viewer element,
or
null
if no label can be obtained
-