]> source.dussan.org Git - vaadin-framework.git/commitdiff
Delete CheckboxRenderer
authorIlia Motornyi <elmot@vaadin.com>
Thu, 15 Dec 2016 14:32:39 +0000 (16:32 +0200)
committerGitHub <noreply@github.com>
Thu, 15 Dec 2016 14:32:39 +0000 (16:32 +0200)
Fixes vaadin/framework8-issues#551

client/src/main/java/com/vaadin/client/connectors/CheckBoxRendererConnector.java [deleted file]
client/src/main/java/com/vaadin/client/renderers/CheckBoxRenderer.java [deleted file]
server/src/main/java/com/vaadin/ui/renderers/CheckBoxRenderer.java [deleted file]
shared/src/main/java/com/vaadin/shared/ui/grid/renderers/CheckBoxRendererState.java [deleted file]
uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java
uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java

diff --git a/client/src/main/java/com/vaadin/client/connectors/CheckBoxRendererConnector.java b/client/src/main/java/com/vaadin/client/connectors/CheckBoxRendererConnector.java
deleted file mode 100644 (file)
index 4d9ec78..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.client.connectors;
-
-import com.google.gwt.event.shared.HandlerRegistration;
-import com.vaadin.client.renderers.CheckBoxRenderer;
-import com.vaadin.client.renderers.ClickableRenderer.RendererClickHandler;
-import com.vaadin.shared.ui.Connect;
-import com.vaadin.shared.ui.grid.renderers.CheckBoxRendererState;
-
-import elemental.json.JsonObject;
-
-/**
- * A connector for {@link com.vaadin.ui.renderers.CheckBoxRenderer}.
- *
- * @since 8.0
- * @author Vaadin Ltd
- */
-@Connect(com.vaadin.ui.renderers.CheckBoxRenderer.class)
-public class CheckBoxRendererConnector
-        extends ClickableRendererConnector<Boolean> {
-
-    @Override
-    public CheckBoxRenderer getRenderer() {
-        return (CheckBoxRenderer) super.getRenderer();
-    }
-
-    @Override
-    protected HandlerRegistration addClickHandler(
-            RendererClickHandler<JsonObject> handler) {
-        return getRenderer().addClickHandler(handler);
-    }
-
-    @Override
-    public CheckBoxRendererState getState() {
-        return (CheckBoxRendererState) super.getState();
-    }
-}
diff --git a/client/src/main/java/com/vaadin/client/renderers/CheckBoxRenderer.java b/client/src/main/java/com/vaadin/client/renderers/CheckBoxRenderer.java
deleted file mode 100644 (file)
index b004b1c..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.client.renderers;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.ui.CheckBox;
-import com.vaadin.client.ui.VCheckBox;
-import com.vaadin.client.widget.grid.RendererCellReference;
-
-/**
- * A Renderer that displays a boolean value as a checkbox.
- *
- * <p>
- *
- * Click handlers can be added to the renderer, invoked when any of the rendered
- * checkboxes are clicked.
- *
- * @since 8.0
- * @author Vaadin Ltd
- */
-public class CheckBoxRenderer extends ClickableRenderer<Boolean, CheckBox> {
-
-    @Override
-    public CheckBox createWidget() {
-        CheckBox cb = GWT.create(VCheckBox.class);
-        cb.addClickHandler(this);
-        return cb;
-    }
-
-    @Override
-    public void render(RendererCellReference cell, Boolean data,
-            CheckBox widget) {
-        widget.setValue(data);
-    }
-
-}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/CheckBoxRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/CheckBoxRenderer.java
deleted file mode 100644 (file)
index c57776d..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.ui.renderers;
-
-import java.util.function.BiConsumer;
-import java.util.function.Function;
-
-import com.vaadin.shared.ui.grid.renderers.CheckBoxRendererState;
-
-/**
- * A renderer that displays boolean valued grid columns as checkboxes.
- *
- * @since 8.0
- * @author Vaadin Ltd
- */
-public class CheckBoxRenderer<T> extends ClickableRenderer<T, Boolean> {
-
-    /**
-     * Creates a new checkbox renderer, given getter and setter functions.
-     * Getters and setters are used to update the object corresponding to a
-     * given row in the grid on the server side.
-     *
-     * @param getter
-     *            function for getting the desired boolean value
-     * @param setter
-     *            function for setting the boolean value after a change from the
-     *            client side
-     */
-    public CheckBoxRenderer(Function<T, Boolean> getter,
-            BiConsumer<T, Boolean> setter) {
-        super(Boolean.class, "");
-        addClickListener(clickEvent -> setter.accept(clickEvent.getItem(),
-                !getter.apply(clickEvent.getItem())));
-    }
-
-    @Override
-    protected CheckBoxRendererState getState() {
-        return (CheckBoxRendererState) super.getState();
-    }
-
-    @Override
-    protected CheckBoxRendererState getState(boolean markAsDirty) {
-        return (CheckBoxRendererState) super.getState(markAsDirty);
-    }
-}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/grid/renderers/CheckBoxRendererState.java b/shared/src/main/java/com/vaadin/shared/ui/grid/renderers/CheckBoxRendererState.java
deleted file mode 100644 (file)
index 6d2c302..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.shared.ui.grid.renderers;
-
-/**
- * Shared state for CheckBoxRenderer.
- *
- * @since 8.0
- */
-public class CheckBoxRendererState extends ClickableRendererState {
-
-}
index 42647e3d97b8df8ec9c7cbb729c2220628db7b2e..5fa2a43386a48a865dcfde0ec7ebd8715d219534 100644 (file)
@@ -6,7 +6,6 @@ import com.vaadin.tests.components.AbstractReindeerTestUI;
 import com.vaadin.ui.Grid;
 import com.vaadin.ui.Label;
 import com.vaadin.ui.renderers.ButtonRenderer;
-import com.vaadin.ui.renderers.CheckBoxRenderer;
 import com.vaadin.ui.renderers.ImageRenderer;
 
 public class GridClickableRenderers extends AbstractReindeerTestUI {
@@ -39,13 +38,15 @@ public class GridClickableRenderers extends AbstractReindeerTestUI {
                         .setValue(event.getItem().testText + " clicked")))
                 .setId("buttons").setCaption("Buttons");
 
-        CheckBoxRenderer<TestPOJO> checkBoxRenderer = new CheckBoxRenderer<>(
-                pojo -> pojo.truthValue,
-                (pojo, newTruthValue) -> pojo.truthValue = newTruthValue);
-        checkBoxRenderer.addClickListener(click -> checkBoxValueLabel.setValue(
-                click.getItem().testText + " " + click.getItem().truthValue));
-        grid.addColumn(pojo -> pojo.truthValue, checkBoxRenderer)
-                .setId("checkboxes").setCaption("Checkboxes");
+        ButtonRenderer<TestPOJO> yesNoRenderer = new ButtonRenderer<>();
+        yesNoRenderer.addClickListener(event -> {
+            TestPOJO item = event.getItem();
+            item.truthValue = !item.truthValue;
+            checkBoxValueLabel.setValue(item.testText + " " + item.truthValue);
+            grid.getDataProvider().refreshAll();
+        });
+        grid.addColumn(pojo -> pojo.truthValue ? "Yes" : "No",
+                yesNoRenderer).setCaption("Truth").setId("truth");
 
         grid.setItems(new TestPOJO("first row", "", "button 1 text", true),
                 new TestPOJO("second row", "", "button 2 text", false));
index a548bff6797bb3b9010129df18e0e9dc654164b3..c4ec0d99eace3ba00b87adbdfe8e8c6cd25829a3 100644 (file)
@@ -30,39 +30,37 @@ public class GridClickableRenderersTest extends MultiBrowserTest {
         openTestURL();
         Assert.assertTrue(isElementPresent(By.className("v-nativebutton")));
         Assert.assertTrue(isElementPresent(By.className("gwt-Image")));
-        Assert.assertTrue(isElementPresent(By.className("v-checkbox")));
     }
 
     @Test
     public void buttonRendererReturnsCorrectItem() {
         openTestURL();
-        WebElement firstButton = findElements(By.className("v-nativebutton"))
+        WebElement firstRowButton = findElements(By.className("v-nativebutton"))
                 .get(0);
-        WebElement secondButton = findElements(By.className("v-nativebutton"))
-                .get(1);
+        WebElement secondRowButton = findElements(By.className("v-nativebutton"))
+                .get(2);
         LabelElement label = $(LabelElement.class).get(1);
 
-        firstButton.click();
+        firstRowButton.click();
         Assert.assertEquals("first row clicked", label.getText());
 
-        secondButton.click();
+        secondRowButton.click();
         Assert.assertEquals("second row clicked", label.getText());
     }
 
     @Test
     public void checkBoxRendererClick() {
         openTestURL();
-        WebElement firstCheckBox = findElements(
-                By.cssSelector("input[type='checkbox']")).get(0);
-        WebElement secondCheckBox = findElements(
-                By.cssSelector("input[type='checkbox']")).get(1);
-
+        WebElement firstRowButton = findElements(By.className("v-nativebutton"))
+                .get(1);
+        WebElement secondRowButton = findElements(By.className("v-nativebutton"))
+                .get(3);
         LabelElement label = $(LabelElement.class).get(2);
 
-        firstCheckBox.click();
+        firstRowButton.click();
         Assert.assertEquals("first row false", label.getText());
 
-        secondCheckBox.click();
+        secondRowButton.click();
         Assert.assertEquals("second row true", label.getText());
     }
 }