public class ContributionComparator extends ViewerComparator implements Comparator
IComparableContribution
instances, either as a
ViewerComparator
(for StructuredViewer
s) or as a traditional
Comparator
.
This class orders contributions by first grouping by priority (IComparableContribution.getPriority()
)
and then by utilizing the JFace policy comparator to order by label (IComparableContribution.getLabel()
).IComparableContribution
Constructor and Description |
---|
ContributionComparator() |
Modifier and Type | Method and Description |
---|---|
int |
category(IComparableContribution c)
Returns the category of the given element.
|
int |
category(Object element)
Returns the category of the given element.
|
int |
compare(IComparableContribution c1,
IComparableContribution c2)
Returns a negative, zero, or positive number depending on whether the
first element is less than, equal to, or greater than the second element.
|
int |
compare(Object o1,
Object o2)
This implementation of
Comparator.compare(Object, Object) does a
blind cast on each element to IComparableContribution . |
int |
compare(Viewer viewer,
Object e1,
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.
|
getComparator, isSorterProperty, sort
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
equals
public int compare(Object o1, Object o2)
Comparator.compare(Object, Object)
does a
blind cast on each element to IComparableContribution
.compare
in interface Comparator
public int compare(IComparableContribution c1, IComparableContribution c2)
The default implementation of this method is based on comparing the
elements' categories as computed by the category
framework
method. Elements within the same category are further subjected to a case
insensitive compare of their label strings. Subclasses may override.
c1
- the first elementc2
- the second element0
if the first element is equal
to the second element; and a positive number if the first element
is greater than the second elementpublic int compare(Viewer viewer, Object e1, Object e2)
ViewerComparator
The default implementation of this method is based on
comparing the elements' categories as computed by the category
framework method. Elements within the same category are further
subjected to a case insensitive compare of their label strings, either
as computed by the content viewer's label provider, or their
toString
values in other cases. Subclasses may override.
compare
in class ViewerComparator
viewer
- the viewere1
- the first elemente2
- the second element0
if the first element is
equal to the second element; and a positive number if the first
element is greater than the second elementpublic int category(IComparableContribution c)
The default implementation of this framework method returns the result of
IComparableContribution.getPriority()
. Subclasses may
re-implement this method to provide non-trivial categorization.
c
- the elementpublic int category(Object element)
ViewerComparator
The default implementation of this framework method returns
0
. Subclasses may reimplement this method to provide
non-trivial categorization.
category
in class ViewerComparator
element
- the element
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.