Package com.iizigo.navigator
Class ViewerComparator
- java.lang.Object
- org.eclipse.jface.viewers.ViewerComparator
- org.eclipse.jface.viewers.ViewerSorter
- com.iizigo.navigator.ViewerComparator
- All Implemented Interfaces:
IViewerComparator
public class ViewerComparator extends org.eclipse.jface.viewers.ViewerSorter implements IViewerComparator
Class to sort nodes in aCommonViewerEx.- Author:
- Christopher Mindus
Constructor Summary
Constructors Constructor Description ViewerComparator()Creates a newViewerComparator, which uses the default comparator to sort strings.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcategory(java.lang.Object element)Returns the category of the given element.intcompare(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.booleangetReverseSortOrdering()Get reverse ordering flag.booleangetSortByCategory()Gets sorting by category.voidsetReverseSortOrdering(boolean on)Sets reverse ordering.voidsetSortByCategory(boolean on)Sets sorting by category.
Constructor Detail
ViewerComparator
public ViewerComparator()
Creates a newViewerComparator, which uses the default comparator to sort strings.
Method Detail
setSortByCategory
public void setSortByCategory(boolean on)
Sets sorting by category.
getSortByCategory
public boolean getSortByCategory()
Gets sorting by category.
setReverseSortOrdering
public void setReverseSortOrdering(boolean on)
Sets reverse ordering.
getReverseSortOrdering
public boolean getReverseSortOrdering()
Get reverse ordering flag.
category
public int category(java.lang.Object element)
Returns the category of the given element. The category is a number used to allocate elements to bins; the bins are arranged in ascending numeric order. The elements within a bin are arranged via a second level sort criterion.- Overrides:
categoryin classorg.eclipse.jface.viewers.ViewerComparator- Parameters:
element- the element.- Returns:
- the category.
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.- Specified by:
comparein interfaceIViewerComparator- Overrides:
comparein classorg.eclipse.jface.viewers.ViewerComparator- Parameters:
viewer- The viewer.e1- The first elemente2- The second element.- Returns:
- a negative number if the first element is less than the second element; the value
0if the first element is equal to the second element; and a positive number if the first element is greater than the second element.