]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes #1907 : Switching between horizontal and vertical modes broken in IOrderedLayout
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Fri, 4 Jul 2008 07:57:49 +0000 (07:57 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Fri, 4 Jul 2008 07:57:49 +0000 (07:57 +0000)
svn changeset:5055/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
src/com/itmill/toolkit/ui/OrderedLayout.java

index e0ed8a1102bdded2704c0eec9ffa05be408f8a1b..c81ddc0f8414641323302d189a57b50554651372 100644 (file)
@@ -157,14 +157,38 @@ public class IOrderedLayout extends Panel implements Container,
             return;
         }
 
+        // Remove fixed state
+        removeFixedSizes();
+
         orientationMode = newOrientationMode;
 
         createAndEmptyWrappedChildContainer();
 
         // Reinsert all widget wrappers to this container
         for (int i = 0; i < childWidgetWrappers.size(); i++) {
-            DOM.appendChild(wrappedChildContainer,
-                    ((WidgetWrapper) childWidgetWrappers.get(i)).getElement());
+            WidgetWrapper wr = (WidgetWrapper) childWidgetWrappers.get(i);
+            Element oldWrElement = wr.resetRootElement();
+            Element newWrElement = wr.getElement();
+            String oldStyle = DOM.getElementAttribute(oldWrElement, "class");
+            if (oldStyle != null) {
+                DOM.setElementAttribute(newWrElement, "class", oldStyle);
+            }
+            while (DOM.getChildCount(oldWrElement) > 0) {
+                Element c = DOM.getFirstChild(oldWrElement);
+                DOM.removeChild(oldWrElement, c);
+                DOM.appendChild(newWrElement, c);
+            }
+
+            DOM.appendChild(wrappedChildContainer, newWrElement);
+        }
+
+        // Reconsider being fixed
+        if ((orientationMode == ORIENTATION_HORIZONTAL && "100%".equals(DOM
+                .getStyleAttribute(margin, "width")))
+                || (orientationMode == ORIENTATION_VERTICAL && "100%"
+                        .equals(DOM.getStyleAttribute(margin, "height")))) {
+            fixedCellSize = true;
+            updateFixedSizes();
         }
 
         // Update child layouts
@@ -486,18 +510,30 @@ public class IOrderedLayout extends Panel implements Container,
         Element td;
         Caption caption = null;
 
-        /** Created td or div - depending on the orientation of the layout. */
+        /** Set the root element */
         public WidgetWrapper() {
+            resetRootElement();
+        }
+
+        /**
+         * Create td or div - depending on the orientation of the layout and set
+         * it as root.
+         * 
+         * @return Previous root element.
+         */
+        private Element resetRootElement() {
+            Element e = getElement();
             if (orientationMode == ORIENTATION_VERTICAL) {
                 setElement(DOM.createDiv());
                 // Apply 'hasLayout' for IE (needed to get accurate dimension
                 // calculations)
                 if (BrowserInfo.get().isIE()) {
-                    DOM.setStyleAttribute(getElement(), "zoom", "1");
+                    DOM.setStyleAttribute(e, "zoom", "1");
                 }
             } else {
                 setElement(DOM.createTD());
             }
+            return e;
         }
 
         /** Update the caption of the element contained in this wrapper. */
index 97bceee1fab5de79ca41c366253ac4985312c1e4..a3c3da5392ce596aa0747cce3508f1d739788cc9 100644 (file)
@@ -218,15 +218,7 @@ public class OrderedLayout extends AbstractLayout implements
 
         this.orientation = orientation;
 
-        // requestRepaint()
-        // FIXME remove lines below and uncomment above
-        // Workaround to bypass IOrderedLayouts limitations (separate classes
-        // for different orientation + subtreecacing)
-        final Iterator it = getComponentIterator();
-        while (it.hasNext()) {
-            final Component c = (Component) it.next();
-            c.requestRepaint();
-        }
+        requestRepaint();
     }
 
     /* Documented in superclass */