Fixes vaadin/framework8-issues#592tags/8.0.0.beta2
@@ -1 +1 @@ | |||
Subproject commit eec6eee6610e80e28736e8a27aaaa2166ea2fa7c | |||
Subproject commit 203312a80a5f76d48fc36ef8d215f8b70b8e7545 |
@@ -0,0 +1,60 @@ | |||
/* | |||
* 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.tests.components.grid; | |||
import java.util.Arrays; | |||
import java.util.stream.IntStream; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.tests.data.bean.Person; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Grid; | |||
import com.vaadin.ui.Grid.Column; | |||
import com.vaadin.ui.Grid.SelectionMode; | |||
public class GridEditingWithNoScrollBars extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Grid<Person> grid = new Grid<>(); | |||
grid.addColumn(Person::getFirstName); | |||
Column<Person, String> column = grid.addColumn(Person::getLastName); | |||
grid.setItems(IntStream.range(0, 10).mapToObj(this::createPerson)); | |||
ComboBox<String> stCombo = new ComboBox<>(); | |||
stCombo.setItems(Arrays.asList("1", "2", "3")); | |||
stCombo.setEmptySelectionAllowed(false); | |||
stCombo.setSizeFull(); | |||
column.setEditorComponent(stCombo); | |||
grid.setSelectionMode(SelectionMode.SINGLE); | |||
grid.getEditor().setEnabled(true); | |||
grid.setSizeFull(); | |||
addComponent(grid); | |||
} | |||
private Person createPerson(int i) { | |||
Person person = new Person(); | |||
person.setFirstName("foo"); | |||
person.setLastName(String.valueOf(i % 3 + 1)); | |||
return person; | |||
} | |||
} |
@@ -13,20 +13,21 @@ | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.v7.tests.components.grid; | |||
package com.vaadin.tests.components.grid; | |||
import com.vaadin.tests.util.PersonContainer; | |||
import com.vaadin.v7.ui.Grid; | |||
import com.vaadin.tests.util.Person; | |||
import com.vaadin.ui.Grid; | |||
public class GridEditorFrozenColumnsUI extends GridEditorUI { | |||
@Override | |||
protected Grid createGrid(PersonContainer container) { | |||
Grid grid = super.createGrid(container); | |||
protected Grid<Person> createGrid() { | |||
Grid<Person> grid = super.createGrid(); | |||
grid.setFrozenColumnCount(2); | |||
grid.setWidth("600px"); | |||
grid.setHeight("100%"); | |||
return grid; | |||
} |
@@ -0,0 +1,63 @@ | |||
package com.vaadin.tests.components.grid; | |||
import java.util.stream.IntStream; | |||
import com.vaadin.data.Binder; | |||
import com.vaadin.data.converter.StringToIntegerConverter; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.tests.data.bean.Person; | |||
import com.vaadin.ui.Grid; | |||
import com.vaadin.ui.Grid.Column; | |||
import com.vaadin.ui.TextField; | |||
import com.vaadin.ui.renderers.NumberRenderer; | |||
public class GridEditorMultiselect extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Grid<Person> grid = new Grid<>(); | |||
Column<Person, String> nameColumn = grid.addColumn(Person::getFirstName) | |||
.setCaption("name"); | |||
Column<Person, Number> ageColumn = grid | |||
.addColumn(Person::getAge, new NumberRenderer()) | |||
.setCaption("age"); | |||
Binder<Person> binder = new Binder<>(); | |||
grid.getEditor().setBinder(binder); | |||
TextField name = new TextField(); | |||
nameColumn.setEditorComponent(name); | |||
binder.bind(name, Person::getFirstName, Person::setFirstName); | |||
TextField age = new TextField(); | |||
ageColumn.setEditorComponent(age); | |||
binder.forField(age).withConverter(new StringToIntegerConverter("")) | |||
.bind(Person::getAge, Person::setAge); | |||
grid.setItems(IntStream.range(0, 30).mapToObj(this::createPerson)); | |||
grid.getEditor().setEnabled(true); | |||
grid.setSelectionMode(Grid.SelectionMode.MULTI); | |||
addComponent(grid); | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 17132; | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "Grid Multiselect: Edit mode allows invalid selection"; | |||
} | |||
private Person createPerson(int i) { | |||
Person person = new Person(); | |||
person.setFirstName("name" + i); | |||
person.setAge(i); | |||
return person; | |||
} | |||
} |
@@ -0,0 +1,108 @@ | |||
/* | |||
* 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.tests.components.grid; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.Random; | |||
import com.vaadin.data.Binder; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.tests.util.Person; | |||
import com.vaadin.tests.util.TestDataGenerator; | |||
import com.vaadin.ui.Grid; | |||
import com.vaadin.ui.Grid.Column; | |||
import com.vaadin.ui.PasswordField; | |||
import com.vaadin.ui.TextField; | |||
import com.vaadin.ui.renderers.NumberRenderer; | |||
public class GridEditorUI extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Grid<Person> grid = createGrid(); | |||
grid.setItems(createTestData()); | |||
addComponent(grid); | |||
} | |||
protected Collection<Person> createTestData() { | |||
return createTestData(100); | |||
} | |||
protected Collection<Person> createTestData(int size) { | |||
Random r = new Random(0); | |||
ArrayList<Person> testData = new ArrayList<>(); | |||
for (int i = 0; i < size; i++) { | |||
Person person = new Person(); | |||
person.setFirstName(TestDataGenerator.getFirstName(r)); | |||
person.setLastName(TestDataGenerator.getLastName(r)); | |||
person.getAddress().setCity(TestDataGenerator.getCity(r)); | |||
person.setEmail(person.getFirstName().toLowerCase() + "." | |||
+ person.getLastName().toLowerCase() + "@vaadin.com"); | |||
person.setPhoneNumber(TestDataGenerator.getPhoneNumber(r)); | |||
person.getAddress() | |||
.setPostalCode(TestDataGenerator.getPostalCode(r)); | |||
person.getAddress() | |||
.setStreetAddress(TestDataGenerator.getStreetAddress(r)); | |||
testData.add(person); | |||
} | |||
return testData; | |||
} | |||
protected Grid<Person> createGrid() { | |||
Grid<Person> grid = new Grid<>(); | |||
Binder<Person> binder = new Binder<>(); | |||
grid.getEditor().setBinder(binder); | |||
grid.addColumn(Person::getEmail).setCaption("Email"); | |||
Column<Person, String> fistNameColumn = grid | |||
.addColumn(Person::getFirstName).setCaption("First Name"); | |||
Column<Person, String> lastNameColumn = grid | |||
.addColumn(Person::getLastName).setCaption("Last Name"); | |||
Column<Person, String> phoneColumn = grid | |||
.addColumn(Person::getPhoneNumber).setCaption("Phone Number"); | |||
grid.addColumn(person -> person.getAddress().getStreetAddress()) | |||
.setCaption("Street Address"); | |||
grid.addColumn(person -> person.getAddress().getPostalCode(), | |||
new NumberRenderer()).setCaption("Postal Code"); | |||
grid.addColumn(person -> person.getAddress().getCity()) | |||
.setCaption("City"); | |||
grid.getEditor().setEnabled(true); | |||
PasswordField passwordField = new PasswordField(); | |||
fistNameColumn.setEditorComponent(passwordField); | |||
binder.bind(passwordField, Person::getFirstName, Person::setFirstName); | |||
TextField lastNameEditor = new TextField(); | |||
lastNameColumn.setEditorComponent(lastNameEditor); | |||
lastNameEditor.setMaxLength(50); | |||
binder.bind(lastNameEditor, Person::getLastName, Person::setLastName); | |||
TextField phoneEditor = new TextField(); | |||
phoneEditor.setReadOnly(true); | |||
phoneColumn.setEditorComponent(phoneEditor); | |||
binder.bind(phoneEditor, Person::getPhoneNumber, | |||
Person::setPhoneNumber); | |||
return grid; | |||
} | |||
} |
@@ -1,62 +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.v7.tests.components.grid; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractReindeerTestUI; | |||
import com.vaadin.v7.ui.Grid; | |||
@SuppressWarnings("serial") | |||
public class GridDragAndDrop extends AbstractReindeerTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
List<String> columnIds = Arrays.asList("Hello", "this", "are", | |||
"multiple", "columns", "plus", "these", "resemble", "a", | |||
"group", "here", "no", "more"); | |||
Grid grid = new Grid(); | |||
for (String columnId : columnIds) { | |||
grid.addColumn(columnId); | |||
} | |||
for (int i = 0; i < 100; i++) { | |||
grid.addRow(columnIds.toArray()); | |||
} | |||
grid.setColumnReorderingAllowed(true); | |||
grid.setFrozenColumnCount(1); | |||
grid.setSelectionMode(Grid.SelectionMode.MULTI); | |||
addComponent(grid); | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "Start dragging a column header and move left and right.<br> The drop indicator should appear exactly on the lines between column headers."; | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 18925; | |||
} | |||
} |
@@ -1,53 +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.v7.tests.components.grid; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractReindeerTestUI; | |||
import com.vaadin.v7.ui.ComboBox; | |||
import com.vaadin.v7.ui.Grid; | |||
import com.vaadin.v7.ui.Grid.Column; | |||
import com.vaadin.v7.ui.Grid.SelectionMode; | |||
public class GridEditingWithNoScrollBars extends AbstractReindeerTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Grid grid = new Grid(); | |||
grid.addColumn("foo", String.class); | |||
grid.addColumn("bar", String.class); | |||
for (int i = 0; i < 10; ++i) { | |||
grid.addRow("foo", "" + (i % 3 + 1)); | |||
} | |||
ComboBox stCombo = new ComboBox(); | |||
stCombo.addItem("" + 1); | |||
stCombo.addItem("" + 2); | |||
stCombo.addItem("" + 3); | |||
stCombo.setNullSelectionAllowed(false); | |||
stCombo.setSizeFull(); | |||
Column stCol = grid.getColumn("bar"); | |||
stCol.setEditorField(stCombo); | |||
grid.setSelectionMode(SelectionMode.SINGLE); | |||
grid.setEditorEnabled(true); | |||
grid.setSizeFull(); | |||
addComponent(grid); | |||
} | |||
} |
@@ -1,56 +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.v7.tests.components.grid; | |||
import com.vaadin.server.ErrorHandler; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.v7.ui.Grid; | |||
public class GridEditorConverterNotFound extends AbstractTestUIWithLog { | |||
class Foo { | |||
} | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Grid grid = new Grid(); | |||
grid.addColumn("foo", Foo.class); | |||
grid.addRow(new Foo()); | |||
grid.setEditorEnabled(true); | |||
grid.setErrorHandler(new ErrorHandler() { | |||
@Override | |||
public void error(com.vaadin.server.ErrorEvent event) { | |||
log(event.getThrowable().toString()); | |||
} | |||
}); | |||
addComponent(grid); | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 17935; | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "Grid should gracefully handle bind failures when opening editor"; | |||
} | |||
} |
@@ -1,35 +0,0 @@ | |||
package com.vaadin.v7.tests.components.grid; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractReindeerTestUI; | |||
import com.vaadin.v7.ui.Grid; | |||
public class GridEditorMultiselect extends AbstractReindeerTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Grid grid = new Grid(); | |||
grid.addColumn("name"); | |||
grid.addColumn("age", Integer.class); | |||
for (int i = 0; i < 30; i++) { | |||
grid.addRow("name " + i, i); | |||
} | |||
grid.setEditorEnabled(true); | |||
grid.setSelectionMode(Grid.SelectionMode.MULTI); | |||
addComponent(grid); | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 17132; | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "Grid Multiselect: Edit mode allows invalid selection"; | |||
} | |||
} |
@@ -13,7 +13,7 @@ | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.v7.tests.components.grid; | |||
package com.vaadin.tests.components.grid; | |||
import static org.junit.Assert.assertEquals; | |||
@@ -13,7 +13,7 @@ | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package com.vaadin.v7.tests.components.grid; | |||
package com.vaadin.tests.components.grid; | |||
import java.io.IOException; | |||
@@ -1,4 +1,4 @@ | |||
package com.vaadin.v7.tests.components.grid; | |||
package com.vaadin.tests.components.grid; | |||
import java.util.List; | |||
@@ -26,6 +26,7 @@ public class GridEditorMultiselectTest extends MultiBrowserTest { | |||
openTestURL(); | |||
GridElement grid = openEditor(); | |||
grid.getEditor().save(); | |||
waitForElementNotPresent(By.className("v-grid-editor-cells")); | |||
assertCheckboxesEnabled(grid, true); | |||
} | |||
@@ -1,42 +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.v7.tests.components.grid; | |||
import static org.junit.Assert.assertEquals; | |||
import org.junit.Test; | |||
import com.vaadin.testbench.customelements.GridElement; | |||
import com.vaadin.v7.tests.components.grid.basicfeatures.GridBasicFeaturesTest; | |||
public class GridEditorConverterNotFoundTest extends GridBasicFeaturesTest { | |||
@Override | |||
protected Class<?> getUIClass() { | |||
// Use the correct UI with helpers from GridBasicFeatures | |||
return GridEditorConverterNotFound.class; | |||
} | |||
@Test | |||
public void testConverterNotFound() { | |||
openTestURL(); | |||
$(GridElement.class).first().getCell(0, 0).doubleClick(); | |||
assertEquals("1. com.vaadin.v7.data.Buffered$SourceException", | |||
getLogRow(0)); | |||
} | |||
} |