]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add style names to selection checkboxes (#17755)
authorTeppo Kurki <teppo.kurki@vaadin.com>
Tue, 11 Aug 2015 19:55:43 +0000 (22:55 +0300)
committerTeppo Kurki <teppo.kurki@vaadin.com>
Tue, 11 Aug 2015 19:57:07 +0000 (22:57 +0300)
Change-Id: I982433f643962ed68b0856b520d331038c7fe838

client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java
client/src/com/vaadin/client/widgets/Grid.java
uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java

index 1e47d3ad6b92d9efad0ab853e5dc57c1060cab9c..c64908f24c4e2003303de7750b56cfd496ef81be 100644 (file)
@@ -56,6 +56,8 @@ import com.vaadin.client.widgets.Grid;
 public class MultiSelectionRenderer<T> extends
         ClickableRenderer<Boolean, CheckBox> {
 
+    private static final String SELECTION_CHECKBOX_CLASSNAME = "-selection-checkbox";
+
     /** The size of the autoscroll area, both top and bottom. */
     private static final int SCROLL_AREA_GRADIENT_PX = 100;
 
@@ -591,6 +593,8 @@ public class MultiSelectionRenderer<T> extends
     @Override
     public CheckBox createWidget() {
         final CheckBox checkBox = GWT.create(CheckBox.class);
+        checkBox.setStylePrimaryName(grid.getStylePrimaryName()
+                + SELECTION_CHECKBOX_CLASSNAME);
         CheckBoxEventHandler handler = new CheckBoxEventHandler(checkBox);
 
         // Sink events
index ce3db0970a14114e388109f4d42e32637f8e6570..369e530b9d2a7d399fbcb4eee3cb001b604add1e 100644 (file)
@@ -209,6 +209,8 @@ public class Grid<T> extends ResizeComposite implements
         HasSelectionHandlers<T>, SubPartAware, DeferredWorker, HasWidgets,
         HasEnabled {
 
+    private static final String SELECT_ALL_CHECKBOX_CLASSNAME = "-select-all-checkbox";
+
     /**
      * Enum describing different sections of Grid.
      */
@@ -2405,6 +2407,8 @@ public class Grid<T> extends ResizeComposite implements
 
             if (selectAllCheckBox == null) {
                 selectAllCheckBox = GWT.create(CheckBox.class);
+                selectAllCheckBox.setStylePrimaryName(getStylePrimaryName()
+                        + SELECT_ALL_CHECKBOX_CLASSNAME);
                 selectAllCheckBox
                         .addValueChangeHandler(new ValueChangeHandler<Boolean>() {
 
index 1f3085d273e172747c29af64a1e0dc21e01ff786..8bf8639d769352a983cc1faebd096a4c6470507a 100644 (file)
@@ -337,6 +337,24 @@ public class GridSelectionTest extends GridBasicFeaturesTest {
                 getRow(5).isSelected());
     }
 
+    @Test
+    public void testSelectionCheckBoxesHaveStyleNames() {
+        openTestURL();
+
+        setSelectionModelMulti();
+
+        assertTrue(
+                "Selection column CheckBox should have the proper style name set",
+                getGridElement().getCell(0, 0).findElement(By.tagName("span"))
+                        .getAttribute("class")
+                        .contains("v-grid-selection-checkbox"));
+
+        GridCellElement header = getGridElement().getHeaderCell(0, 0);
+        assertTrue("Select all CheckBox should have the proper style name set",
+                header.findElement(By.tagName("span")).getAttribute("class")
+                        .contains("v-grid-select-all-checkbox"));
+    }
+
     @Test
     public void testServerSideSelectTogglesSelectAllCheckBox() {
         openTestURL();