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 asDelegatingStyledCellLabelProvider.IStyledLabelProvider
andDelegatingStyledCellLabelProvider
.
-
-
Constructor Summary
Constructors Constructor Description LabelComparator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(org.eclipse.jface.viewers.Viewer viewer, java.lang.Object e1, java.lang.Object e2)
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 java.lang.String
getLabel(org.eclipse.jface.viewers.Viewer viewer, java.lang.Object element)
Returns the label string for the given viewer element to use for sorting the viewer's contents.
-
-
-
Method Detail
-
compare
public int compare(org.eclipse.jface.viewers.Viewer viewer, java.lang.Object e1, java.lang.Object e2)
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
protected java.lang.String getLabel(org.eclipse.jface.viewers.Viewer viewer, java.lang.Object element)
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
-
-