diff options
3 files changed, 163 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/ui/table/TableConnector.java b/client/src/com/vaadin/client/ui/table/TableConnector.java index 7fb4bc108a..9f1f99bae3 100644 --- a/client/src/com/vaadin/client/ui/table/TableConnector.java +++ b/client/src/com/vaadin/client/ui/table/TableConnector.java @@ -425,4 +425,15 @@ public class TableConnector extends AbstractHasComponentsConnector implements // TODO Move code from updateFromUIDL to this method } + @Override + protected void updateComponentSize(String newWidth, String newHeight) { + super.updateComponentSize(newWidth, newHeight); + + if("".equals(newWidth)) { + getWidget().updateWidth(); + } + if("".equals(newHeight)) { + getWidget().updateHeight(); + } + } } diff --git a/uitest/src/com/vaadin/tests/components/table/TableSetUndefinedSize.java b/uitest/src/com/vaadin/tests/components/table/TableSetUndefinedSize.java new file mode 100644 index 0000000000..3b5ee875e9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableSetUndefinedSize.java @@ -0,0 +1,115 @@ +package com.vaadin.tests.components.table; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Table; + +public class TableSetUndefinedSize extends AbstractTestUI { + @Override + protected void setup(VaadinRequest request) { + getLayout().setSizeFull(); + + Table table = createTable(); + table.setSizeFull(); + addComponent(table); + + HorizontalLayout widthButtons = createWidthButtons(table); + addComponent(widthButtons); + + HorizontalLayout heightButtons = createHeigthButtons(table); + addComponent(heightButtons); + + addComponent(createSizeUndefinedButton(table)); + } + + private Button createSizeUndefinedButton(final Table table) { + return new Button("size undefined", new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + table.setSizeUndefined(); + } + }); + } + + private HorizontalLayout createWidthButtons(final Table table) { + HorizontalLayout layout = new HorizontalLayout(); + + layout.addComponent(new Button("width 500px", new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + table.setWidth("500px"); + } + })); + layout.addComponent(new Button("width 100%", new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + table.setWidth("100%"); + } + })); + layout.addComponent(new Button("undefined width", new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + table.setWidthUndefined(); + } + })); + + return layout; + } + + private HorizontalLayout createHeigthButtons(final Table table) { + HorizontalLayout layout = new HorizontalLayout(); + + layout.addComponent(new Button("height 200px", new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + table.setHeight("200px"); + } + })); + layout.addComponent(new Button("height 300px", new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + table.setHeight("300px"); + } + })); + layout.addComponent(new Button("height 100%", new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + table.setHeight("100%"); + } + })); + layout.addComponent(new Button("undefined height", new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + table.setHeightUndefined(); + } + })); + + return layout; + } + + private Table createTable() { + Table table = new Table(""); + + table.addContainerProperty("column 1", String.class, "column 1 value"); + table.addContainerProperty("column 2", String.class, "column 2 value"); + table.addContainerProperty("column 3", String.class, "column 3 value"); + + for(int i=0; i<5; i++) { + table.addItem(); + } + + return table; + } + + @Override + public String getDescription() { + return "Table width and height changing to undefined doesn't update table size"; + } + + @Override + protected Integer getTicketNumber() { + return 15384; + } +} diff --git a/uitest/src/com/vaadin/tests/components/table/TableSetUndefinedSizeTest.java b/uitest/src/com/vaadin/tests/components/table/TableSetUndefinedSizeTest.java new file mode 100644 index 0000000000..1745c580c2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableSetUndefinedSizeTest.java @@ -0,0 +1,37 @@ +package com.vaadin.tests.components.table; + +import org.junit.Test; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedCondition; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TableSetUndefinedSizeTest extends MultiBrowserTest { + @Test + public void testTableShouldChangeSizeIfWidthSetToUndefined() { + openTestURL(); + + $(ButtonElement.class).caption("width 500px").first().click(); + + final TableElement table = $(TableElement.class).first(); + final int previousWidth = table.getSize().getWidth(); + + $(ButtonElement.class).caption("undefined width").first().click(); + + waitUntil(new ExpectedCondition<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + return previousWidth != table.getSize().getWidth(); + } + + @Override + public String toString() { + // Timed out after 10 seconds waiting for ... + return "table to change size (was: " + previousWidth + ")"; + } + }); + } +} |