Class ObjectViewerComparator
- java.lang.Object
-
- org.eclipse.jface.viewers.ViewerComparator
-
- org.eclipse.emfforms.spi.swt.core.ui.ObjectViewerComparator
-
public class ObjectViewerComparator extends org.eclipse.jface.viewers.ViewerComparator
TheObjectViewerComparator
allows to rotate between three sorting states:- no sorting
- ascending
- descending
- Since:
- 1.20
- Author:
- Lucas Koehler
-
-
Constructor Summary
Constructors Constructor Description ObjectViewerComparator(TriFunction<java.lang.Integer,java.lang.Integer,java.lang.Object,java.lang.Object> compareFunction)
Creates a new instance.
-
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)
int
getDirection()
Get the current sorting direction as an SWT constant.void
toggleDirection()
Toggles through the sorting directions: NONE -> UP (ascending) -> DOWN (descending) -> NONE.
-
-
-
Constructor Detail
-
ObjectViewerComparator
public ObjectViewerComparator(TriFunction<java.lang.Integer,java.lang.Integer,java.lang.Object,java.lang.Object> compareFunction)
Creates a new instance.- Parameters:
compareFunction
- The function used to compare objects of the viewer. This tri-function accepts the sorting direction as its first argument and the objects to compare as the following arguments. The sorting directions are: 0 = none, 1 = ascending, 2 = descending
-
-
Method Detail
-
toggleDirection
public void toggleDirection()
Toggles through the sorting directions: NONE -> UP (ascending) -> DOWN (descending) -> NONE.
-
getDirection
public int getDirection()
Get the current sorting direction as an SWT constant.- Returns:
- SWT.NONE, SWT.UP (ascending), or SWT.DOWN (descending)
-
compare
public int compare(org.eclipse.jface.viewers.Viewer viewer, java.lang.Object e1, java.lang.Object e2)
- Overrides:
compare
in classorg.eclipse.jface.viewers.ViewerComparator
-
-