From: Matti Tahvonen Date: Mon, 9 Jun 2008 08:29:45 +0000 (+0000) Subject: fixes #1782 X-Git-Tag: 6.7.0.beta1~4646 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9e9f2ade3aa2f967e0fa22da7545ec3330216170;p=vaadin-framework.git fixes #1782 svn changeset:4802/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/ui/Panel.java b/src/com/itmill/toolkit/ui/Panel.java index 0d26a7a998..c936ddd374 100644 --- a/src/com/itmill/toolkit/ui/Panel.java +++ b/src/com/itmill/toolkit/ui/Panel.java @@ -108,49 +108,50 @@ public class Panel extends AbstractComponentContainer implements Scrollable, } /** - * Sets the layout of the panel. All the components are moved to new layout. + * Sets the layout of the panel. * - * @param layout + * If given layout is null, an OrderedLayout is used as a default. + * + * Components from old layout are not moved to new layout by default + * (changed in 5.2.2). Use function in Layout interface manually. + * + * @param newLayout * the New layout of the panel. */ - public void setLayout(Layout layout) { + public void setLayout(Layout newLayout) { // Only allow non-null layouts - if (layout == null) { - layout = new OrderedLayout(); + if (newLayout == null) { + newLayout = new OrderedLayout(); // Force margins by default - layout.setMargin(true); + newLayout.setMargin(true); } - if (layout == this.layout) { + if (newLayout == layout) { // don't set the same layout twice return; } - // Sets the panel to be parent for the layout - layout.setParent(this); - - // If panel already contains a layout, move the contents to new one - // and detach old layout from the panel - if (this.layout != null) { - layout.moveComponentsFrom(this.layout); - this.layout.setParent(null); - } - - // Removes the event listeners from the old layout - if (this.layout != null) { - this.layout + // detach old layout if present + if (layout != null) { + layout.setParent(null); + layout .removeListener((ComponentContainer.ComponentAttachListener) this); - this.layout + layout .removeListener((ComponentContainer.ComponentDetachListener) this); } + // Sets the panel to be parent for the layout + newLayout.setParent(this); + // Sets the new layout - this.layout = layout; + layout = newLayout; // Adds the event listeners for new layout - layout.addListener((ComponentContainer.ComponentAttachListener) this); - layout.addListener((ComponentContainer.ComponentDetachListener) this); + newLayout + .addListener((ComponentContainer.ComponentAttachListener) this); + newLayout + .addListener((ComponentContainer.ComponentDetachListener) this); } /**