1 | |
package org.kuali.student.common.ui.client.widgets.table.scroll; |
2 | |
|
3 | |
import org.kuali.student.common.ui.client.util.BrowserUtils; |
4 | |
|
5 | |
import com.google.gwt.user.client.DOM; |
6 | |
import com.google.gwt.user.client.Element; |
7 | |
import com.google.gwt.user.client.Event; |
8 | |
import com.google.gwt.user.client.ui.FlexTable; |
9 | |
|
10 | |
public class MouseHoverFlexTable extends FlexTable { |
11 | |
private TableModel tableModel; |
12 | 0 | public MouseHoverFlexTable(){ |
13 | 0 | sinkEvents(Event.ONMOUSEOVER |Event.ONMOUSEOUT); |
14 | |
|
15 | 0 | } |
16 | |
public void setModel(TableModel tableModel){ |
17 | 0 | this.tableModel = tableModel; |
18 | 0 | } |
19 | |
|
20 | |
public void onBrowserEvent(Event event) { |
21 | 0 | super.onBrowserEvent(event); |
22 | 0 | Element td = getEventTargetCell(event); |
23 | 0 | String attrName = BrowserUtils.getClassAttr(); |
24 | 0 | if (td == null) |
25 | 0 | return; |
26 | |
|
27 | 0 | switch (DOM.eventGetType(event)) { |
28 | |
case Event.ONMOUSEOVER: { |
29 | 0 | Element tr = DOM.getParent(td); |
30 | 0 | tr.setAttribute(attrName, "table-row-hover"); |
31 | |
|
32 | 0 | break; |
33 | |
} |
34 | |
case Event.ONMOUSEOUT: { |
35 | 0 | int count = tableModel.getRowCount(); |
36 | 0 | for (int r = 0; r < count; r++) { |
37 | 0 | Element tr = getRowFormatter().getElement(r); |
38 | 0 | if (tableModel.getRow(r).isSelected()) { |
39 | 0 | tr.setAttribute(attrName, "table-row-selected"); |
40 | |
}else{ |
41 | 0 | tr.setAttribute(attrName, "table-row"); |
42 | |
} |
43 | |
} |
44 | 0 | break; |
45 | |
} |
46 | |
|
47 | |
} |
48 | |
|
49 | 0 | } |
50 | |
|
51 | |
} |