List of usage examples for com.google.gwt.dom.client TableSectionElement as
public static TableSectionElement as(Element elem)
From source file:org.rstudio.core.client.widget.MultiSelectCellTable.java
License:Open Source License
private void handleContextMenu(ContextMenuEvent cmEvent) { // bail if there are no context menu handlers if (handlerManager_.getHandlerCount(ContextMenuEvent.getType()) == 0) return;// w w w .ja va 2 s .c om // Get the event target. NativeEvent event = cmEvent.getNativeEvent(); EventTarget eventTarget = event.getEventTarget(); if (!Element.is(eventTarget)) return; final Element target = event.getEventTarget().cast(); // always squelch default handling (when there is a handler) event.stopPropagation(); event.preventDefault(); // find the table cell element then get its parent and cast to row TableCellElement tableCell = findNearestParentCell(target); if (tableCell == null) return; Element trElem = tableCell.getParentElement(); if (trElem == null) return; TableRowElement tr = TableRowElement.as(trElem); // get the section of the row and confirm it is a tbody (as opposed // to a thead or tfoot) Element sectionElem = tr.getParentElement(); if (sectionElem == null) return; TableSectionElement section = TableSectionElement.as(sectionElem); if (section != getTableBodyElement()) return; // determine the row/item target int row = tr.getSectionRowIndex(); T item = getVisibleItem(row); // if this row isn't already selected then clear the existing selection if (!getSelectionModel().isSelected(item)) clearSelection(); // select the clicked on item getSelectionModel().setSelected(item, true); // forward the event DomEvent.fireNativeEvent(event, handlerManager_); }