Add a protected method CellTable#doSelection() as a hook that allows users to customize how the table selects rows. We will later expand this to use a SelectionManager, but the protected method is a good stopgap for now.
Review at http://gwt-code-reviews.appspot.com/1088801
Review by: sbrubaker@google.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9199 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/cellview/client/CellTable.java b/user/src/com/google/gwt/user/cellview/client/CellTable.java
index 5b3cb50..33e05e3 100644
--- a/user/src/com/google/gwt/user/cellview/client/CellTable.java
+++ b/user/src/com/google/gwt/user/cellview/client/CellTable.java
@@ -844,6 +844,22 @@
return dependsOnSelection;
}
+ /**
+ * Called when a user action triggers selection.
+ *
+ * @param event the event that triggered selection
+ * @param value the value that was selected
+ * @param row the row index of the value on the page
+ * @param column the column index where the event occurred
+ */
+ protected void doSelection(Event event, T value, int row, int column) {
+ // TODO(jlabanca): Defer to a user provided SelectionManager.
+ SelectionModel<? super T> selectionModel = getSelectionModel();
+ if (selectionModel != null) {
+ selectionModel.setSelected(value, true);
+ }
+ }
+
@Override
protected Element getChildContainer() {
return tbody;
@@ -967,10 +983,8 @@
return;
}
T value = getDisplayedItem(row);
- SelectionModel<? super T> selectionModel = getSelectionModel();
- if (selectionModel != null && "click".equals(eventType)
- && !handlesSelection) {
- selectionModel.setSelected(value, true);
+ if ("click".equals(eventType) && !handlesSelection) {
+ doSelection(event, value, row, col);
}
fireEventToCell(event, eventType, tableCell, value, row, columns.get(col));