1
2
3
4
5
6
7
8 package hoplugins.commons.ui.sorter;
9
10 import javax.swing.event.TableModelEvent;
11 import javax.swing.event.TableModelListener;
12
13 /***
14 * DOCUMENT ME!
15 *
16 * @author
17 */
18 class TableModelHandler implements TableModelListener {
19 /*** TODO Missing Parameter Documentation */
20 private final AbstractTableSorter sorter;
21
22 /***
23 * Creates a new TableModelHandler object.
24 *
25 * @param sorter
26 */
27 TableModelHandler(AbstractTableSorter sorter) {
28 this.sorter = sorter;
29 }
30
31 /***
32 * DOCUMENT ME!
33 *
34 * @param e
35 */
36 public void tableChanged(TableModelEvent e) {
37
38 if (!this.sorter.isSorting()) {
39 this.sorter.clearSortingState();
40 this.sorter.fireTableChanged(e);
41
42 return;
43 }
44
45
46
47
48 if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
49 this.sorter.cancelSorting();
50 this.sorter.fireTableChanged(e);
51
52 return;
53 }
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 int column = e.getColumn();
74
75 if ((e.getFirstRow() == e.getLastRow())
76 && (column != TableModelEvent.ALL_COLUMNS)
77 && (this.sorter.getSortingStatus(column) == AbstractTableSorter.NOT_SORTED)
78 && (this.sorter.getModelToView() != null)) {
79 int viewIndex = this.sorter.getModelToView()[e.getFirstRow()];
80
81 this.sorter.fireTableChanged(new TableModelEvent(this.sorter,
82 viewIndex, viewIndex, column, e.getType()));
83
84 return;
85 }
86
87
88 this.sorter.clearSortingState();
89 this.sorter.fireTableDataChanged();
90
91 return;
92 }
93 }