]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - eclipse/org.argeo.cms.swt/src/org/argeo/eclipse/ui/GenericTableComparator.java
1 package org
.argeo
.eclipse
.ui
;
3 import org
.eclipse
.jface
.viewers
.Viewer
;
4 import org
.eclipse
.jface
.viewers
.ViewerComparator
;
6 public abstract class GenericTableComparator
extends ViewerComparator
{
7 private static final long serialVersionUID
= -1175894935075325810L;
8 protected int propertyIndex
;
9 public static final int ASCENDING
= 0, DESCENDING
= 1;
10 protected int direction
= DESCENDING
;
13 * Creates an instance of a sorter for TableViewer.
15 * @param defaultColumnIndex
16 * the default sorter column
19 public GenericTableComparator(int defaultColumnIndex
, int direction
) {
20 propertyIndex
= defaultColumnIndex
;
21 this.direction
= direction
;
24 public void setColumn(int column
) {
25 if (column
== this.propertyIndex
) {
26 // Same column as last sort; toggle the direction
27 direction
= 1 - direction
;
29 // New column; do a descending sort
30 this.propertyIndex
= column
;
31 direction
= DESCENDING
;
36 * Must be Overriden in each view.
38 public abstract int compare(Viewer viewer
, Object e1
, Object e2
);