summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2016-01-05 16:26:22 +0200
committerVaadin Code Review <review@vaadin.com>2016-01-07 11:03:06 +0000
commitc7520351fef14334aa80305853afe7dcfff8609f (patch)
tree6ec81614bff81bb7ef1b4d596ec359e7b81f7432
parentbdec494f718d80cbd36363ce2e892647d31898d1 (diff)
downloadvaadin-framework-c7520351fef14334aa80305853afe7dcfff8609f.tar.gz
vaadin-framework-c7520351fef14334aa80305853afe7dcfff8609f.zip
Support non-AbstractFieldConnector fields with Grid Editor (#19440)
Change-Id: Ib3eaf0b35cfe88391c8ab3b5fcbe668d67c2dd3c
-rw-r--r--client/src/com/vaadin/client/connectors/GridConnector.java12
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridWithLabelEditor.java154
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridWithLabelEditorTest.java37
3 files changed, 197 insertions, 6 deletions
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java
index 1097a2f277..053487620a 100644
--- a/client/src/com/vaadin/client/connectors/GridConnector.java
+++ b/client/src/com/vaadin/client/connectors/GridConnector.java
@@ -48,7 +48,7 @@ import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
import com.vaadin.client.connectors.RpcDataSourceConnector.DetailsListener;
import com.vaadin.client.connectors.RpcDataSourceConnector.RpcDataSource;
-import com.vaadin.client.ui.AbstractFieldConnector;
+import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.AbstractHasComponentsConnector;
import com.vaadin.client.ui.ConnectorFocusAndBlurHandler;
import com.vaadin.client.ui.SimpleManagedLayout;
@@ -160,7 +160,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements
private AbstractRendererConnector<Object> rendererConnector;
- private AbstractFieldConnector editorConnector;
+ private AbstractComponentConnector editorConnector;
private HandlerRegistration errorStateHandler;
@@ -196,12 +196,12 @@ public class GridConnector extends AbstractHasComponentsConnector implements
return null;
}
- private AbstractFieldConnector getEditorConnector() {
+ private AbstractComponentConnector getEditorConnector() {
return editorConnector;
}
private void setEditorConnector(
- final AbstractFieldConnector editorConnector) {
+ final AbstractComponentConnector editorConnector) {
this.editorConnector = editorConnector;
if (errorStateHandler != null) {
@@ -328,7 +328,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements
assert column != null;
if (column instanceof CustomGridColumn) {
- AbstractFieldConnector c = ((CustomGridColumn) column)
+ AbstractComponentConnector c = ((CustomGridColumn) column)
.getEditorConnector();
if (c == null) {
@@ -1033,7 +1033,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements
column.setHidingToggleCaption(state.hidingToggleCaption);
column.setEditable(state.editable);
- column.setEditorConnector((AbstractFieldConnector) state.editorConnector);
+ column.setEditorConnector((AbstractComponentConnector) state.editorConnector);
}
/**
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridWithLabelEditor.java b/uitest/src/com/vaadin/tests/components/grid/GridWithLabelEditor.java
new file mode 100644
index 0000000000..91c5a06c66
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridWithLabelEditor.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2000-2014 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.tests.components.grid;
+
+import java.util.Collection;
+
+import com.vaadin.data.Validator;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Label;
+
+public class GridWithLabelEditor extends AbstractTestUI {
+
+ public class LabelEditor extends Label implements Field<String> {
+
+ @Override
+ public void focus() {
+ super.focus();
+ }
+
+ @Override
+ public boolean isInvalidCommitted() {
+ return false;
+ }
+
+ @Override
+ public void setInvalidCommitted(boolean isCommitted) {
+ }
+
+ @Override
+ public void commit() throws SourceException, InvalidValueException {
+ }
+
+ @Override
+ public void discard() throws SourceException {
+ }
+
+ @Override
+ public void setBuffered(boolean buffered) {
+ }
+
+ @Override
+ public boolean isBuffered() {
+ return false;
+ }
+
+ @Override
+ public boolean isModified() {
+ return false;
+ }
+
+ @Override
+ public void addValidator(Validator validator) {
+ }
+
+ @Override
+ public void removeValidator(Validator validator) {
+ }
+
+ @Override
+ public void removeAllValidators() {
+ }
+
+ @Override
+ public Collection<Validator> getValidators() {
+ return null;
+ }
+
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+
+ @Override
+ public void validate() throws InvalidValueException {
+ }
+
+ @Override
+ public boolean isInvalidAllowed() {
+ return false;
+ }
+
+ @Override
+ public void setInvalidAllowed(boolean invalidValueAllowed)
+ throws UnsupportedOperationException {
+ }
+
+ @Override
+ public int getTabIndex() {
+ return -1;
+ }
+
+ @Override
+ public void setTabIndex(int tabIndex) {
+ }
+
+ @Override
+ public boolean isRequired() {
+ return false;
+ }
+
+ @Override
+ public void setRequired(boolean required) {
+ }
+
+ @Override
+ public void setRequiredError(String requiredMessage) {
+ }
+
+ @Override
+ public String getRequiredError() {
+ return null;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return false;
+ }
+
+ @Override
+ public void clear() {
+ }
+
+ }
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Grid grid = new Grid();
+ addComponent(grid);
+
+ grid.setEditorEnabled(true);
+ grid.addColumn("Foo", String.class).setEditorField(new LabelEditor());
+ grid.addRow("FooFoo");
+
+ grid.editItem(grid.getContainerDataSource().firstItemId());
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridWithLabelEditorTest.java b/uitest/src/com/vaadin/tests/components/grid/GridWithLabelEditorTest.java
new file mode 100644
index 0000000000..7917d0e279
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridWithLabelEditorTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2014 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.tests.components.grid;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class GridWithLabelEditorTest extends SingleBrowserTest {
+
+ @Test
+ public void testNoExceptionOnEdit() {
+ setDebug(true);
+ openTestURL();
+
+ assertNoErrorNotifications();
+
+ assertEquals("LabelEditor content not correct.", "FooFoo",
+ $(GridElement.class).first().getEditor().getField(0).getText());
+ }
+}