summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2008-06-09 08:29:45 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2008-06-09 08:29:45 +0000
commit9e9f2ade3aa2f967e0fa22da7545ec3330216170 (patch)
tree868e67cf8e04c1d58bc6d75e1d277d66715d004c
parent9da099bd32f9f89c0fe8f1ee18a6a9a182d9fe1c (diff)
downloadvaadin-framework-9e9f2ade3aa2f967e0fa22da7545ec3330216170.tar.gz
vaadin-framework-9e9f2ade3aa2f967e0fa22da7545ec3330216170.zip
fixes #1782
svn changeset:4802/svn branch:trunk
-rw-r--r--src/com/itmill/toolkit/ui/Panel.java49
1 files changed, 25 insertions, 24 deletions
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);
}
/**