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 public MouseHoverFlexTable(){ 13 sinkEvents(Event.ONMOUSEOVER |Event.ONMOUSEOUT); 14 15 } 16 public void setModel(TableModel tableModel){ 17 this.tableModel = tableModel; 18 } 19 20 public void onBrowserEvent(Event event) { 21 super.onBrowserEvent(event); 22 Element td = getEventTargetCell(event); 23 String attrName = BrowserUtils.getClassAttr(); 24 if (td == null) 25 return; 26 27 switch (DOM.eventGetType(event)) { 28 case Event.ONMOUSEOVER: { 29 Element tr = DOM.getParent(td); 30 tr.setAttribute(attrName, "table-row-hover"); 31 32 break; 33 } 34 case Event.ONMOUSEOUT: { 35 int count = tableModel.getRowCount(); 36 for (int r = 0; r < count; r++) { 37 Element tr = getRowFormatter().getElement(r); 38 if (tableModel.getRow(r).isSelected()) { 39 tr.setAttribute(attrName, "table-row-selected"); 40 }else{ 41 tr.setAttribute(attrName, "table-row"); 42 } 43 } 44 break; 45 } 46 47 } 48 49 } 50 51 }