layout.setWidget(3, 0, highlightedRowLabel);
layout.setWidget(2, 1, unhighlightedRowLabel);
layout.setWidget(3, 1, unhighlightedCellLabel);
// Add all of the listeners
FixedWidthGrid dataTable = ScrollTableDemo.get().getDataTable();
dataTable.addTableListener(new TableListener() {
public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
addLogEntry("cell clicked: (" + row + "," + cell + ")", "#ff00ff");
}
});
dataTable.addColumnSortHandler(new ColumnSortHandler() {
public void onColumnSorted(ColumnSortEvent event) {
ColumnSortList sortList = event.getColumnSortList();
int column = -1;
boolean ascending = true;
if (sortList != null) {
column = sortList.getPrimaryColumn();
ascending = sortList.isPrimaryAscending();
}
if (ascending) {
addLogEntry("sorted column: " + column + " (ascending)", "black");
} else {
addLogEntry("sorted column: " + column, "black");
}
}
});
dataTable.addCellHighlightHandler(new CellHighlightHandler() {
public void onCellHighlight(CellHighlightEvent event) {
Cell cell = event.getValue();
highlightedCellLabel.setText("Highlighted cell: (" + cell.getRowIndex()
+ "," + cell.getCellIndex() + ")");
}
});
dataTable.addCellUnhighlightHandler(new CellUnhighlightHandler() {
public void onCellUnhighlight(CellUnhighlightEvent event) {
Cell cell = event.getValue();
unhighlightedCellLabel.setText("Last unhighlighted cell: ("
+ cell.getRowIndex() + "," + cell.getCellIndex() + ")");
}
});
dataTable.addRowHighlightHandler(new RowHighlightHandler() {
public void onRowHighlight(RowHighlightEvent event) {
Row cell = event.getValue();
highlightedRowLabel.setText("Highlighted row: (" + cell.getRowIndex()
+ ")");
}
});
dataTable.addRowUnhighlightHandler(new RowUnhighlightHandler() {
public void onRowUnhighlight(RowUnhighlightEvent event) {
Row cell = event.getValue();
unhighlightedRowLabel.setText("Last unhighlighted row: ("
+ cell.getRowIndex() + ")");
}
});
dataTable.addRowSelectionHandler(new RowSelectionHandler() {
public void onRowSelection(RowSelectionEvent event) {
// Show the previously selected rows
Set<Row> deselectedRows = event.getDeselectedRows();
String previous = "Previously selected rows: ";
for (Row row : event.getOldValue()) {