//Check whether "group" widget has been clicked
boolean bGroupWidgetClick = isGroupWidgetClicked( event,
target );
// Find the cell where the event occurred.
TableCellElement eventTableCell = findNearestParentCell( target );
if ( eventTableCell == null ) {
return;
}
int htmlCol = eventTableCell.getCellIndex();
Element trElem = eventTableCell.getParentElement();
if ( trElem == null ) {
return;
}
TableRowElement tr = TableRowElement.as( trElem );
int htmlRow = tr.getSectionRowIndex();
// Convert HTML coordinates to physical coordinates
CellValue< ? > htmlCell = data.get( htmlRow ).get( htmlCol );
Coordinate eventPhysicalCoordinate = htmlCell.getPhysicalCoordinate();
CellValue< ? > eventPhysicalCell = data.get( eventPhysicalCoordinate.getRow() ).get( eventPhysicalCoordinate.getCol() );
//Event handlers
if ( eventType.equals( "mousedown" ) ) {
handleMousedownEvent( event,
eventPhysicalCoordinate,
bGroupWidgetClick );
return;
} else if ( eventType.equals( "mousemove" ) ) {
handleMousemoveEvent( event,
eventPhysicalCoordinate );
return;
} else if ( eventType.equals( "mouseup" ) ) {
handleMouseupEvent( event,
eventPhysicalCoordinate );
return;
} else if ( eventType.equals( "keydown" ) ) {
handleKeyboardNavigationEvent( event );
if ( event.getKeyCode() == KeyCodes.KEY_ENTER ) {
// Enter key is a special case; as the selected cell needs to be
// sent events and not the cell that GWT deemed the target for
// events.
switch ( rangeDirection ) {
case UP :
eventPhysicalCell = selections.first();
break;
case DOWN :
eventPhysicalCell = selections.last();
break;
}
eventPhysicalCoordinate = eventPhysicalCell.getCoordinate();
eventTableCell = tbody.getRows().getItem( eventPhysicalCell.getHtmlCoordinate().getRow() ).getCells().getItem( eventPhysicalCell.getHtmlCoordinate().getCol() );
}
}
// Pass event and physical cell to Cell Widget for handling
Cell<CellValue< ? extends Comparable< ? >>> cellWidget = columns.get( eventPhysicalCoordinate.getCol() ).getCell();
// Implementations of AbstractCell aren't forced to initialise consumed events
Set<String> consumedEvents = cellWidget.getConsumedEvents();
if ( consumedEvents != null && consumedEvents.contains( eventType ) ) {
Context context = new Context( eventPhysicalCoordinate.getRow(),
eventPhysicalCoordinate.getCol(),
eventPhysicalCoordinate );
//The element containing the cell's HTML is nested inside two DIVs
Element parent = eventTableCell.getFirstChildElement().getFirstChildElement();
cellWidget.onBrowserEvent( context,
parent,
eventPhysicalCell,
event,
null );