1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.eclipse.ui;
17
18 import org.eclipse.jface.viewers.Viewer;
19 import org.eclipse.jface.viewers.ViewerComparator;
20
21 public abstract class GenericTableComparator extends ViewerComparator {
22 private static final long serialVersionUID = -1175894935075325810L;
23 protected int propertyIndex;
24 public static final int ASCENDING = 0, DESCENDING = 1;
25 protected int direction = DESCENDING;
26
27
28
29
30
31
32
33
34 public GenericTableComparator(int defaultColumnIndex, int direction) {
35 propertyIndex = defaultColumnIndex;
36 this.direction = direction;
37 }
38
39 public void setColumn(int column) {
40 if (column == this.propertyIndex) {
41
42 direction = 1 - direction;
43 } else {
44
45 this.propertyIndex = column;
46 direction = DESCENDING;
47 }
48 }
49
50
51
52
53 public abstract int compare(Viewer viewer, Object e1, Object e2);
54 }