diff options
author | Henrik Paul <henrik@vaadin.com> | 2013-09-24 15:03:56 +0300 |
---|---|---|
committer | Henrik Paul <henrik@vaadin.com> | 2013-10-09 14:26:05 +0300 |
commit | b29caad20c1d14a655f546493f6c5507a0a6f856 (patch) | |
tree | 08c8e09bc2948f3d9fbbc5f2029c7ec0db5d7c37 /uitest/src/com/vaadin/tests/widgetset/client | |
parent | 0f7bcffdb9f753148d1027ff380c9520bb78bfd8 (diff) | |
download | vaadin-framework-b29caad20c1d14a655f546493f6c5507a0a6f856.tar.gz vaadin-framework-b29caad20c1d14a655f546493f6c5507a0a6f856.zip |
Initial escalator commit (#12645)
Change-Id: Ibd0ac2896e12b99ddebdc26674a2dfced486c49a
Diffstat (limited to 'uitest/src/com/vaadin/tests/widgetset/client')
3 files changed, 184 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java new file mode 100644 index 0000000000..ef624d6fc8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridConnector.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2013 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.widgetset.client.grid; + +import com.vaadin.client.ui.AbstractComponentConnector; +import com.vaadin.shared.ui.Connect; +import com.vaadin.tests.widgetset.server.grid.TestGrid; + +/** + * @since 7.2 + * @author Vaadin Ltd + */ +@Connect(TestGrid.class) +public class TestGridConnector extends AbstractComponentConnector { + @Override + protected void init() { + super.init(); + } + + @Override + public VTestGrid getWidget() { + return (VTestGrid) super.getWidget(); + } + + @Override + public TestGridState getState() { + return (TestGridState) super.getState(); + } +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java new file mode 100644 index 0000000000..9aeca0bdbe --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/TestGridState.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2013 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.widgetset.client.grid; + +import com.vaadin.shared.AbstractComponentState; + +/** + * @since 7.2 + * @author Vaadin Ltd + */ +public class TestGridState extends AbstractComponentState { + public static final String DEFAULT_HEIGHT = "400px"; + + /* TODO: this should be "100%" before setting final. */ + public static final String DEFAULT_WIDTH = "800px"; +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java new file mode 100644 index 0000000000..274b01b166 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java @@ -0,0 +1,113 @@ +package com.vaadin.tests.widgetset.client.grid; + +import com.google.gwt.user.client.ui.Composite; +import com.vaadin.client.ui.grid.Cell; +import com.vaadin.client.ui.grid.CellRenderer; +import com.vaadin.client.ui.grid.ColumnConfiguration; +import com.vaadin.client.ui.grid.Escalator; +import com.vaadin.client.ui.grid.RowContainer; + +public class VTestGrid extends Composite { + public static class HeaderRenderer implements CellRenderer { + private int i = 0; + + @Override + public void renderCell(final Cell cell) { + cell.getElement().setInnerText("Header " + (i++)); + } + } + + public static class BodyRenderer implements CellRenderer { + private int i = 0; + + @Override + public void renderCell(final Cell cell) { + cell.getElement().setInnerText("Cell #" + (i++)); + + double c = i * .1; + int r = (int) ((Math.cos(c) + 1) * 128); + int g = (int) ((Math.cos(c / Math.PI) + 1) * 128); + int b = (int) ((Math.cos(c / (Math.PI * 2)) + 1) * 128); + cell.getElement().getStyle() + .setBackgroundColor("rgb(" + r + "," + g + "," + b + ")"); + if ((r + g + b) / 3 < 127) { + cell.getElement().getStyle().setColor("white"); + } + } + } + + public static class FooterRenderer implements CellRenderer { + private int i = 0; + + @Override + public void renderCell(final Cell cell) { + cell.getElement().setInnerText("Footer " + (i++)); + } + } + + private Escalator escalator = new Escalator(); + + public VTestGrid() { + initWidget(escalator); + + final ColumnConfiguration cConf = escalator.getColumnConfiguration(); + cConf.insertColumns(0, 1); + cConf.insertColumns(0, 1); // prepend one column + cConf.insertColumns(cConf.getColumnCount(), 1); // append one column + // cConf.insertColumns(cConf.getColumnCount(), 10); // append 10 columns + + final RowContainer h = escalator.getHeader(); + h.setCellRenderer(new HeaderRenderer()); + h.insertRows(0, 1); + + final RowContainer b = escalator.getBody(); + b.setCellRenderer(new BodyRenderer()); + b.insertRows(0, 5); + + final RowContainer f = escalator.getFooter(); + f.setCellRenderer(new FooterRenderer()); + f.insertRows(0, 1); + + b.removeRows(3, 2); + // iterative transformations for testing. + // step2(); + // step3(); + // step4(); + // step5(); + // step6(); + + setWidth(TestGridState.DEFAULT_WIDTH); + setHeight(TestGridState.DEFAULT_HEIGHT); + } + + private void step2() { + RowContainer b = escalator.getBody(); + b.insertRows(0, 5); // prepend five rows + b.insertRows(b.getRowCount(), 5); // append five rows + } + + private void step3() { + ColumnConfiguration cConf = escalator.getColumnConfiguration(); + cConf.insertColumns(0, 1); // prepend one column + cConf.insertColumns(cConf.getColumnCount(), 1); // append one column + } + + private void step4() { + final ColumnConfiguration cConf = escalator.getColumnConfiguration(); + cConf.removeColumns(0, 1); + cConf.removeColumns(1, 1); + cConf.removeColumns(cConf.getColumnCount() - 1, 1); + } + + private void step5() { + final RowContainer b = escalator.getBody(); + b.removeRows(0, 1); + b.removeRows(b.getRowCount() - 1, 1); + } + + private void step6() { + RowContainer b = escalator.getBody(); + b.refreshRows(0, b.getRowCount()); + } + +} |