Reviewers: sbrubaker,

Description:
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.


Please review this at http://gwt-code-reviews.appspot.com/1088801/show

Affected files:
  M user/src/com/google/gwt/user/cellview/client/CellTable.java


Index: user/src/com/google/gwt/user/cellview/client/CellTable.java
===================================================================
--- user/src/com/google/gwt/user/cellview/client/CellTable.java (revision 9195) +++ user/src/com/google/gwt/user/cellview/client/CellTable.java (working copy)
@@ -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));


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to