From: Artur Signell Date: Thu, 2 Apr 2009 12:52:59 +0000 (+0000) Subject: Merged "Test case and fix for #2816: Form rendering causes artifacts in certain cases X-Git-Tag: 6.7.0.beta1~3031 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=651ab66ebf222a1220db7f05f39f04ab19bf7314;p=vaadin-framework.git Merged "Test case and fix for #2816: Form rendering causes artifacts in certain cases http://dev.itmill.com/ticket/2816" svn changeset:7289/svn branch:6.0 --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java index 1550d85446..0b91268d25 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java @@ -52,6 +52,8 @@ public class IForm extends ComplexPanel implements Container { private int borderPaddingVertical; + private boolean rendering = false; + public IForm() { setElement(DOM.createDiv()); DOM.appendChild(getElement(), fieldSet); @@ -72,6 +74,8 @@ public class IForm extends ComplexPanel implements Container { } public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { + rendering = true; + if (this.client == null) { this.client = client; borderPaddingVertical = getOffsetHeight(); @@ -79,6 +83,7 @@ public class IForm extends ComplexPanel implements Container { } if (client.updateComponent(this, uidl, false)) { + rendering = false; return; } @@ -159,6 +164,8 @@ public class IForm extends ComplexPanel implements Container { client.unregisterPaintable(footer); } } + + rendering = false; } public void updateSize() { @@ -266,7 +273,7 @@ public class IForm extends ComplexPanel implements Container { updateSize(); - if (height.equals("")) { + if (!rendering && height.equals("")) { // Width might affect height Util.updateRelativeChildrenAndSendSizeUpdateEvent(client, this); } diff --git a/src/com/itmill/toolkit/tests/components/form/FormRenderingFlicker.java b/src/com/itmill/toolkit/tests/components/form/FormRenderingFlicker.java new file mode 100644 index 0000000000..f670aa7d23 --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/form/FormRenderingFlicker.java @@ -0,0 +1,65 @@ +package com.itmill.toolkit.tests.components.form; + +import com.itmill.toolkit.data.Item; +import com.itmill.toolkit.event.ItemClickEvent; +import com.itmill.toolkit.event.ItemClickEvent.ItemClickListener; +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.Form; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.Table; +import com.itmill.toolkit.ui.VerticalLayout; + +public class FormRenderingFlicker extends TestBase { + + private VerticalLayout tableLayout; + private Table table; + private Panel tablePanel; + private Form form; + + @Override + protected String getDescription() { + return "Clicking on an item in the table will replace the panel (surrounding the table) with a form. This should not cause the table rows to move downwards or cause any other visible flicker"; + } + + @Override + protected Integer getTicketNumber() { + return 2816; + } + + @Override + protected void setup() { + createTableLayout(); + form = new Form(); + + tablePanel = new Panel(); + tablePanel.setLayout(tableLayout); + + addComponent(tablePanel); + } + + private void createTableLayout() { + tableLayout = new VerticalLayout(); + table = new Table(); + table.addContainerProperty("name", String.class, ""); + table.addContainerProperty("age", String.class, ""); + for (int i = 0; i < 100; i++) { + table.addItem(new Object[] { "Name " + i, String.valueOf(i) }, + new Object()); + } + table.setImmediate(true); + table.addListener(new ItemClickListener() { + + public void itemClick(ItemClickEvent event) { + clicked(event.getItem()); + } + + }); + + tableLayout.addComponent(table); + } + + protected void clicked(Item item) { + getLayout().replaceComponent(tablePanel, form); + } + +}