aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/CheckBoxRendererConnector.java51
-rw-r--r--client/src/main/java/com/vaadin/client/renderers/CheckBoxRenderer.java49
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/CheckBoxRenderer.java58
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/grid/renderers/CheckBoxRendererState.java25
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java17
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java24
6 files changed, 20 insertions, 204 deletions
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
index 4d9ec782c7..0000000000
--- a/client/src/main/java/com/vaadin/client/connectors/CheckBoxRendererConnector.java
+++ /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
index b004b1c2fa..0000000000
--- a/client/src/main/java/com/vaadin/client/renderers/CheckBoxRenderer.java
+++ /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
index c57776d3c0..0000000000
--- a/server/src/main/java/com/vaadin/ui/renderers/CheckBoxRenderer.java
+++ /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
index 6d2c30265e..0000000000
--- a/shared/src/main/java/com/vaadin/shared/ui/grid/renderers/CheckBoxRendererState.java
+++ /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 {
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java
index 42647e3d97..5fa2a43386 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java
@@ -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));
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java
index a548bff679..c4ec0d99ea 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java
@@ -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());
}
}