/*-{
var vScroll = esc.@com.vaadin.client.widgets.Escalator::verticalScrollbar;
var vScrollElem = vScroll.@com.vaadin.client.widget.escalator.ScrollbarBundle::getElement()();
-
+
var hScroll = esc.@com.vaadin.client.widgets.Escalator::horizontalScrollbar;
var hScrollElem = hScroll.@com.vaadin.client.widget.escalator.ScrollbarBundle::getElement()();
-
+
return $entry(function(e) {
var target = e.target;
-
+
// in case the scroll event was native (i.e. scrollbars were dragged, or
// the scrollTop/Left was manually modified), the bundles have old cache
// values. We need to make sure that the caches are kept up to date.
return $entry(function(e) {
var deltaX = e.deltaX ? e.deltaX : -0.5*e.wheelDeltaX;
var deltaY = e.deltaY ? e.deltaY : -0.5*e.wheelDeltaY;
-
+
// Delta mode 0 is in pixels; we don't need to do anything...
-
+
// A delta mode of 1 means we're scrolling by lines instead of pixels
// We need to scale the number of lines by the default line height
if(e.deltaMode === 1) {
var brc = esc.@com.vaadin.client.widgets.Escalator::body;
deltaY *= brc.@com.vaadin.client.widgets.Escalator.AbstractRowContainer::getDefaultRowHeight()();
}
-
+
// Other delta modes aren't supported
if((e.deltaMode !== undefined) && (e.deltaMode >= 2 || e.deltaMode < 0)) {
var msg = "Unsupported wheel delta mode \"" + e.deltaMode + "\"";
-
+
// Print warning message
esc.@com.vaadin.client.widgets.Escalator::logWarning(*)(msg);
}
-
+
// IE8 has only delta y
if (isNaN(deltaY)) {
deltaY = -0.5*e.wheelDelta;
}
-
+
@com.vaadin.client.widgets.Escalator.JsniUtil::moveScrollFromEvent(*)(esc, deltaX, deltaY, e);
});
}-*/;
*/
@Override
public void removeColumns(final int index, final int numberOfColumns) {
+ if (numberOfColumns == 0) {
+ return;
+ }
+
// Validate
assertArgumentsAreValidAndWithinRange(index, numberOfColumns);
*/
@Override
public void insertColumns(final int index, final int numberOfColumns) {
+ if (numberOfColumns == 0) {
+ return;
+ }
+
// Validate
if (index < 0 || index > getColumnCount()) {
throw new IndexOutOfBoundsException("The given index(" + index
import com.vaadin.tests.util.PortableRandom;
import com.vaadin.tests.util.TestDataGenerator;
import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.Column;
import com.vaadin.ui.renderers.NumberRenderer;
public class GridInitiallyHiddenColumns extends AbstractTestUIWithLog {
grid.addColumn(Person::getFirstName).setHidden(true).setHidable(true)
.setCaption("First Name");
- grid.addColumn(Person::getLastName).setHidable(true)
- .setCaption("Last Name");
+ Column<Person, String> col2 = grid.addColumn(Person::getLastName)
+ .setHidable(true).setCaption("Last Name");
+ if (request.getParameter("allHidden") != null) {
+ col2.setHidden(true);
+ }
grid.addColumn(Person::getAge, new NumberRenderer()).setHidden(true)
.setHidable(true).setCaption("Age");
--- /dev/null
+/*
+ * 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 com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractReindeerTestUI;
+import com.vaadin.tests.data.bean.Person;
+import com.vaadin.tests.data.bean.Sex;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
+
+public class InitialFrozenColumns extends AbstractReindeerTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Grid<Person> grid = new Grid<>(Person.class);
+ grid.setSelectionMode(SelectionMode.NONE);
+ grid.setColumns();
+ grid.addColumn("firstName").setWidth(200);
+ grid.addColumn("lastName").setWidth(200);
+ grid.addColumn("email").setWidth(200);
+
+ grid.setItems(
+ new Person("First", "last", "email", 242, Sex.UNKNOWN, null));
+
+ int frozen = 2;
+ if (request.getParameter("frozen") != null) {
+ frozen = Integer.parseInt(request.getParameter("frozen"));
+ }
+ grid.setFrozenColumnCount(frozen);
+
+ addComponent(grid);
+ }
+
+}
+++ /dev/null
-/*
- * 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.Grid;
-import com.vaadin.v7.ui.Grid.SelectionMode;
-
-public class InitialFrozenColumns extends AbstractReindeerTestUI {
-
- @Override
- protected void setup(VaadinRequest request) {
- Grid grid = new Grid();
- grid.setSelectionMode(SelectionMode.NONE);
-
- grid.addColumn("foo").setWidth(200);
- grid.addColumn("bar").setWidth(200);
- grid.addColumn("baz").setWidth(200);
-
- grid.addRow("a", "b", "c");
-
- grid.setFrozenColumnCount(2);
-
- addComponent(grid);
- }
-
-}
}
+ @Test
+ public void ensureCorrectlyRenderedAllInitiallyHidden() {
+ openTestURL("debug&allHidden");
+ GridElement grid = $(GridElement.class).first();
+
+ getSidebarOpenButton(grid).click();
+ getColumnHidingToggle(grid, "First Name").click();
+ getColumnHidingToggle(grid, "Last Name").click();
+ getColumnHidingToggle(grid, "Age").click();
+ getSidebarOpenButton(grid).click();
+
+ Assert.assertEquals("Umberto", grid.getCell(0, 0).getText());
+ Assert.assertEquals("Rowling", grid.getCell(0, 1).getText());
+ Assert.assertEquals("40", grid.getCell(0, 2).getText());
+ Assert.assertEquals("Alex", grid.getCell(1, 0).getText());
+ Assert.assertEquals("Barks", grid.getCell(1, 1).getText());
+ Assert.assertEquals("25", grid.getCell(1, 2).getText());
+
+ }
+
// TODO: as to the getX methods reuse ones from GridBasicFeaturesTest?
protected WebElement getSidebarOpenButton(GridElement grid) {
--- /dev/null
+/*
+ * 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 static org.junit.Assert.assertTrue;
+
+import java.util.logging.Level;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.testbench.elements.NotificationElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+@TestCategory("grid")
+public class InitialFrozenColumnsTest extends MultiBrowserTest {
+ @Test
+ public void testInitialFrozenColumns() {
+ setDebug(true);
+ openTestURL();
+
+ Assert.assertFalse("Notification was present",
+ isElementPresent(NotificationElement.class));
+
+ WebElement cell = $(GridElement.class).first().getCell(0, 0);
+ assertTrue(cell.getAttribute("class").contains("frozen"));
+ }
+
+ @Test
+ public void testInitialAllColumnsFrozen() {
+ setDebug(true);
+ openTestURL("frozen=3");
+
+ Assert.assertFalse("Notification was present",
+ isElementPresent(NotificationElement.class));
+ assertNoDebugMessage(Level.SEVERE);
+ WebElement cell = $(GridElement.class).first().getCell(0, 2);
+ assertTrue(cell.getAttribute("class").contains("frozen"));
+ }
+}
+++ /dev/null
-/*
- * 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.assertTrue;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.elements.GridElement;
-import com.vaadin.testbench.elements.NotificationElement;
-import com.vaadin.testbench.parallel.TestCategory;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-@TestCategory("grid")
-public class InitialFrozenColumnsTest extends MultiBrowserTest {
- @Test
- public void testInitialFrozenColumns() {
- setDebug(true);
- openTestURL();
-
- Assert.assertFalse("Notification was present",
- isElementPresent(NotificationElement.class));
-
- WebElement cell = $(GridElement.class).first().getCell(0, 0);
- assertTrue(cell.getAttribute("class").contains("frozen"));
- }
-}