]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixed problems with the new layouts not showing
authorRisto Yrjänä <risto.yrjana@itmill.com>
Wed, 12 Nov 2008 12:14:48 +0000 (12:14 +0000)
committerRisto Yrjänä <risto.yrjana@itmill.com>
Wed, 12 Nov 2008 12:14:48 +0000 (12:14 +0000)
svn changeset:5877/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupView.java
src/com/itmill/toolkit/ui/PopupView.java

index be18720328ab6861e2b593ca108ae2d3e5740734..633dc82a81dc010c6de2cd91f5e2534a650a9e63 100644 (file)
@@ -74,6 +74,7 @@ public class IPopupView extends HTML implements Paintable {
         });
 
         popup.setAnimationEnabled(true);
+
     }
 
     /**
@@ -106,8 +107,10 @@ public class IPopupView extends HTML implements Paintable {
         if (hostPopupVisible) {
             UIDL popupUIDL = uidl.getChildUIDL(0);
 
+            // showPopupOnTop(popup, hostReference);
+            preparePopup(popup, hostReference);
             popup.updateFromUIDL(popupUIDL, client);
-            showPopupOnTop(popup, hostReference);
+            showPopup(popup, hostReference);
 
             // The popup isn't visible so we should remove its child. The popup
             // handles hiding so we don't need to hide it here.
@@ -128,6 +131,37 @@ public class IPopupView extends HTML implements Paintable {
         }
     }
 
+    private void preparePopup(final CustomPopup popup, final Widget host) {
+        popup.setVisible(false);
+        popup.show();
+    }
+
+    private void showPopup(final CustomPopup popup, final Widget host) {
+        int offsetWidth = popup.getOffsetWidth();
+        int offsetHeight = popup.getOffsetHeight();
+
+        int hostHorizontalCenter = host.getAbsoluteLeft()
+                + host.getOffsetWidth() / 2;
+        int hostVerticalCenter = host.getAbsoluteTop() + host.getOffsetHeight()
+                / 2;
+
+        int left = hostHorizontalCenter - offsetWidth / 2;
+        int top = hostVerticalCenter - offsetHeight / 2;
+
+        // Superclass takes care of top and left
+        if ((left + offsetWidth) > windowRight) {
+            left -= (left + offsetWidth) - windowRight;
+        }
+
+        if ((top + offsetHeight) > windowBottom) {
+            top -= (top + offsetHeight) - windowBottom;
+        }
+
+        popup.setPopupPosition(left, top);
+
+        setVisible(true);
+    }
+
     /**
      * This shows the popup on top of the widget below. This function allows us
      * to position the popup before making it visible.
@@ -137,31 +171,30 @@ public class IPopupView extends HTML implements Paintable {
      * @param host
      *            the widget to draw the popup on
      */
-    private void showPopupOnTop(final CustomPopup popup, final Widget host) {
-        popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
-            public void setPosition(int offsetWidth, int offsetHeight) {
-                int hostHorizontalCenter = host.getAbsoluteLeft()
-                        + host.getOffsetWidth() / 2;
-                int hostVerticalCenter = host.getAbsoluteTop()
-                        + host.getOffsetHeight() / 2;
-
-                int left = hostHorizontalCenter - offsetWidth / 2;
-                int top = hostVerticalCenter - offsetHeight / 2;
-
-                // Superclass takes care of top and left
-                if ((left + offsetWidth) > windowRight) {
-                    left -= (left + offsetWidth) - windowRight;
-                }
-
-                if ((top + offsetHeight) > windowBottom) {
-                    top -= (top + offsetHeight) - windowBottom;
-                }
-
-                popup.setPopupPosition(left, top);
-            }
-        });
-    }
-
+    // private void showPopupOnTop(final CustomPopup popup, final Widget host) {
+    // popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
+    // public void setPosition(int offsetWidth, int offsetHeight) {
+    // int hostHorizontalCenter = host.getAbsoluteLeft()
+    // + host.getOffsetWidth() / 2;
+    // int hostVerticalCenter = host.getAbsoluteTop()
+    // + host.getOffsetHeight() / 2;
+    //
+    // int left = hostHorizontalCenter - offsetWidth / 2;
+    // int top = hostVerticalCenter - offsetHeight / 2;
+    //
+    // // Superclass takes care of top and left
+    // if ((left + offsetWidth) > windowRight) {
+    // left -= (left + offsetWidth) - windowRight;
+    // }
+    //
+    // if ((top + offsetHeight) > windowBottom) {
+    // top -= (top + offsetHeight) - windowBottom;
+    // }
+    //
+    // popup.setPopupPosition(left, top);
+    // }
+    // });
+    // }
     public void updateWindowSize() {
         windowTop = RootPanel.get().getAbsoluteTop();
         windowLeft = RootPanel.get().getAbsoluteLeft();
@@ -313,13 +346,11 @@ public class IPopupView extends HTML implements Paintable {
         }
 
         public boolean requestLayout(Set<Paintable> child) {
-            // TODO Auto-generated method stub
-            return false;
+            return true;
         }
 
         public RenderSpace getAllocatedSpace(Widget child) {
-            // TODO Auto-generated method stub
-            return null;
+            return new RenderSpace(windowRight, windowBottom);
         }
 
     }// class CustomPopup
index 252e137c21486ef6b510c344ab51d2689c4535ad..0eb4049c8606e6c23aa75719df2e8733111e75a8 100644 (file)
@@ -9,7 +9,7 @@ import com.itmill.toolkit.terminal.PaintTarget;
 
 /**
  * 
- * A component for displaying a two different views to data. The minmized view
+ * A component for displaying a two different views to data. The minimized view
  * is normally used to render the component, and when it is clicked the full
  * view is displayed on a popup. The inner class {@link PopupView.Content} is
  * used to deliver contents to this component.
@@ -56,9 +56,9 @@ public class PopupView extends AbstractComponentContainer {
      */
     public PopupView(PopupView.Content content) {
         super();
-        setContent(content);
         popupVisible = false;
         componentList = new ArrayList<Component>(1);
+        setContent(content);
     }
 
     /**
@@ -111,7 +111,7 @@ public class PopupView extends AbstractComponentContainer {
      * 
      * @see com.itmill.toolkit.ui.ComponentContainer#getComponentIterator()
      */
-    public Iterator getComponentIterator() {
+    public Iterator<Component> getComponentIterator() {
         return componentList.iterator();
 
     }