});
Button multiRowSelectionButton = new Button("Set Multi-Row Selection");
multiRowSelectionButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
MultiRowSelectionModel selectionModel = new MultiRowSelectionModel();
table.setSelectionModel(selectionModel);
selectionModel.addListener(new MultiRowSelection.Listener() {
public void selectionCleared() {
messageLabel.setText("");
}
public void rowSelected(int row, MultiRowSelection model) {
printSelection(model);
}
public void rowUnselected(int row, MultiRowSelection model) {
printSelection(model);
}
private void printSelection(MultiRowSelection model) {
StringBuilder builder = new StringBuilder();
for (int selectedRow : model.getSelectedRows()) {
if (builder.length() > 0) {
builder.append(", ");
}
builder.append(selectedRow);
}
messageLabel.setText("Selected rows: " + builder.toString());
}
});
GGrowl.showMessage("Selection Model Changed", "Multi-row selection is enabled. Hold the Ctrl key to un/select multiple rows", 5000);
}
});
Button multiCellSelectionButton = new Button("Set Multi-Cell Selection");
multiCellSelectionButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
MultiCellSelectionModel selectionModel = new MultiCellSelectionModel();
table.setSelectionModel(selectionModel);
selectionModel.addListener(new MultiCellSelection.Listener() {
public void selectionCleared() {
messageLabel.setText("");
}
public void cellSelected(int row, int column, MultiCellSelection model) {