From 53c114ec5e0c2223dfb6e9456c60a05e1c2ad381 Mon Sep 17 00:00:00 2001 From: Teppo Kurki Date: Tue, 11 Aug 2015 22:55:43 +0300 Subject: [PATCH] Add style names to selection checkboxes (#17755) Change-Id: I982433f643962ed68b0856b520d331038c7fe838 --- .../grid/selection/MultiSelectionRenderer.java | 4 ++++ client/src/com/vaadin/client/widgets/Grid.java | 4 ++++ .../server/GridSelectionTest.java | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java b/client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java index 1e47d3ad6b..c64908f24c 100644 --- a/client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java +++ b/client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java @@ -56,6 +56,8 @@ import com.vaadin.client.widgets.Grid; public class MultiSelectionRenderer extends ClickableRenderer { + 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 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 diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index ce3db0970a..369e530b9d 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -209,6 +209,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, 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 extends ResizeComposite implements if (selectAllCheckBox == null) { selectAllCheckBox = GWT.create(CheckBox.class); + selectAllCheckBox.setStylePrimaryName(getStylePrimaryName() + + SELECT_ALL_CHECKBOX_CLASSNAME); selectAllCheckBox .addValueChangeHandler(new ValueChangeHandler() { diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java index 1f3085d273..8bf8639d76 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java @@ -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(); -- 2.39.5