1
2
3
4
5
6
7
8 package hoplugins.commons.ui.sorter;
9
10 import javax.swing.table.JTableHeader;
11 import javax.swing.table.TableColumnModel;
12
13 import java.awt.event.MouseAdapter;
14 import java.awt.event.MouseEvent;
15
16 /***
17 * DOCUMENT ME!
18 *
19 * @author
20 */
21 class MouseHandler extends MouseAdapter {
22 /*** TODO Missing Parameter Documentation */
23 private final AbstractTableSorter sorter;
24
25 /***
26 * Creates a new MouseHandler object.
27 *
28 * @param sorter
29 */
30 MouseHandler(AbstractTableSorter sorter) {
31 this.sorter = sorter;
32
33
34 }
35
36 /***
37 * DOCUMENT ME!
38 *
39 * @param e
40 */
41 public void mouseClicked(MouseEvent e) {
42 JTableHeader h = (JTableHeader) e.getSource();
43 TableColumnModel columnModel = h.getColumnModel();
44 int viewColumn = columnModel.getColumnIndexAtX(e.getX());
45 int column = columnModel.getColumn(viewColumn).getModelIndex();
46
47
48 if (column < this.sorter.minSortableColumn()) {
49 column = -1;
50 }
51
52 if (column != -1) {
53 int status = this.sorter.getSortingStatus(column);
54
55 if (!e.isControlDown()) {
56 this.sorter.cancelSorting();
57 }
58
59
60
61 status = status + (e.isShiftDown() ? (-1) : 1);
62 status = ((status + 4) % 3) - 1;
63 this.sorter.setSortingStatus(column, status);
64 }
65 }
66 }