public class LabelComparator
extends org.eclipse.jface.viewers.ViewerComparator
This class supports label providers besides ILabelProvider
, such as
DelegatingStyledCellLabelProvider.IStyledLabelProvider
and DelegatingStyledCellLabelProvider
.
Constructor and Description |
---|
LabelComparator() |
Modifier and Type | Method and 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.
|
public int compare(org.eclipse.jface.viewers.Viewer viewer, java.lang.Object e1, java.lang.Object e2)
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 the getLabel(Viewer, Object)
method. The label
strings are compared using the comparator provided by the ViewerComparator.getComparator()
method.
compare
in class org.eclipse.jface.viewers.ViewerComparator
protected java.lang.String getLabel(org.eclipse.jface.viewers.Viewer viewer, java.lang.Object element)
This implementation returns the label string obtained from the content viewer's label provider.
viewer
- the viewerelement
- the elementnull
if no label can be obtainedCopyright (c) 2014, 2018 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0