]> source.dussan.org Git - vaadin-framework.git/commitdiff
Refactoring based on review (#6219)
authorArtur Signell <artur.signell@itmill.com>
Tue, 7 Aug 2012 11:44:18 +0000 (11:44 +0000)
committerArtur Signell <artur.signell@itmill.com>
Tue, 7 Aug 2012 11:44:18 +0000 (11:44 +0000)
svn changeset:24093/svn branch:6.8

src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
src/com/vaadin/terminal/gwt/client/ui/VNotification.java
src/com/vaadin/terminal/gwt/client/ui/VOverlay.java
src/com/vaadin/terminal/gwt/client/ui/VPopupView.java

index d89cec9ad6b749da190d327a845e904db6201991..04374f357e8118a4cd70f2df1892ca37259075de 100644 (file)
@@ -793,7 +793,7 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
                             contentWidth + Util.getNativeScrollbarSize(),
                             Unit.PX);
                 }
-                popup.sizeOrPositionUpdated();
+                popup.positionOrSizeUpdated();
             }
         }
         return top;
index e56a458147cc3a1a99d58e118514eef532ab22b5..ca4c99be01d2f890e8bca00f64c4fccf21eda199 100644 (file)
@@ -154,7 +154,7 @@ public class VNotification extends VOverlay {
         super.show();
         notifications.add(this);
         setPosition(position);
-        sizeOrPositionUpdated();
+        positionOrSizeUpdated();
         /**
          * Android 4 fails to render notifications correctly without a little
          * nudge (#8551)
index f385aa0676783ca1f69b4130280964ede0f32638..60829f1cc8e0205b5e241ac4b794e84c8003f047 100644 (file)
@@ -30,6 +30,14 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
     public static class PositionAndSize {
         private int left, top, width, height;
 
+        public PositionAndSize(int left, int top, int width, int height) {
+            super();
+            setLeft(left);
+            setTop(top);
+            setWidth(width);
+            setHeight(height);
+        }
+
         public int getLeft() {
             return left;
         }
@@ -51,6 +59,10 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
         }
 
         public void setWidth(int width) {
+            if (width < 0) {
+                width = 0;
+            }
+
             this.width = width;
         }
 
@@ -59,6 +71,10 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
         }
 
         public void setHeight(int height) {
+            if (height < 0) {
+                height = 0;
+            }
+
             this.height = height;
         }
 
@@ -224,7 +240,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
         style.setMarginLeft(-adjustByRelativeLeftBodyMargin(), Unit.PX);
         style.setMarginTop(-adjustByRelativeTopBodyMargin(), Unit.PX);
         super.setPopupPosition(left, top);
-        sizeOrPositionUpdated(isAnimationEnabled() ? 0 : 1);
+        positionOrSizeUpdated(isAnimationEnabled() ? 0 : 1);
     }
 
     private IFrameElement getShimElement() {
@@ -316,7 +332,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
         if (isAnimationEnabled()) {
             new ResizeAnimation().run(POPUP_PANEL_ANIMATION_DURATION);
         } else {
-            sizeOrPositionUpdated(1.0);
+            positionOrSizeUpdated(1.0);
         }
         Util.runIE7ZeroSizedBodyFix();
     }
@@ -348,13 +364,13 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
     @Override
     public void setWidth(String width) {
         super.setWidth(width);
-        sizeOrPositionUpdated(1.0);
+        positionOrSizeUpdated(1.0);
     }
 
     @Override
     public void setHeight(String height) {
         super.setHeight(height);
-        sizeOrPositionUpdated(1.0);
+        positionOrSizeUpdated(1.0);
     }
 
     /**
@@ -378,15 +394,15 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
      * size of overlay without using normal 'setWidth(String)' and
      * 'setHeight(String)' methods (if not calling super.setWidth/Height).
      * 
-     * @deprecated Call {@link #sizeOrPositionUpdated()} instead.
+     * @deprecated Call {@link #positionOrSizeUpdated()} instead.
      */
     @Deprecated
     protected void updateShadowSizeAndPosition() {
-        sizeOrPositionUpdated();
+        positionOrSizeUpdated();
     }
 
-    protected void sizeOrPositionUpdated() {
-        sizeOrPositionUpdated(1.0);
+    protected void positionOrSizeUpdated() {
+        positionOrSizeUpdated(1.0);
     }
 
     /**
@@ -399,7 +415,7 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
      *            A value between 0.0 and 1.0, indicating the progress of the
      *            animation (0=start, 1=end).
      */
-    private void sizeOrPositionUpdated(final double progress) {
+    private void positionOrSizeUpdated(final double progress) {
         // Don't do anything if overlay element is not attached
         if (!isAttached()) {
             return;
@@ -424,18 +440,8 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
             getOffsetWidth();
         }
 
-        PositionAndSize positionAndSize = new PositionAndSize();
-        positionAndSize.left = getActualLeft();
-        positionAndSize.top = getActualTop();
-        positionAndSize.width = getOffsetWidth();
-        positionAndSize.height = getOffsetHeight();
-
-        if (positionAndSize.width < 0) {
-            positionAndSize.width = 0;
-        }
-        if (positionAndSize.height < 0) {
-            positionAndSize.height = 0;
-        }
+        PositionAndSize positionAndSize = new PositionAndSize(getActualLeft(),
+                getActualTop(), getOffsetWidth(), getOffsetHeight());
 
         // Animate the size
         positionAndSize.setAnimationFromCenterProgress(progress);
@@ -452,12 +458,12 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
 
         // Update correct values
         if (isShadowEnabled()) {
-            updateSizeAndPosition(shadow, positionAndSize);
+            updatePositionAndSize(shadow, positionAndSize);
             DOM.setStyleAttribute(shadow, "zIndex", zIndex);
             DOM.setStyleAttribute(shadow, "display", progress < 0.9 ? "none"
                     : "");
         }
-        updateSizeAndPosition((Element) Element.as(getShimElement()),
+        updatePositionAndSize((Element) Element.as(getShimElement()),
                 positionAndSize);
 
         // Opera fix, part 2 (ticket #2704)
@@ -489,18 +495,18 @@ public class VOverlay extends PopupPanel implements CloseHandler<PopupPanel> {
 
     }
 
-    private void updateSizeAndPosition(Element e,
+    private void updatePositionAndSize(Element e,
             PositionAndSize positionAndSize) {
-        e.getStyle().setLeft(positionAndSize.left, Unit.PX);
-        e.getStyle().setTop(positionAndSize.top, Unit.PX);
-        e.getStyle().setWidth(positionAndSize.width, Unit.PX);
-        e.getStyle().setHeight(positionAndSize.height, Unit.PX);
+        e.getStyle().setLeft(positionAndSize.getLeft(), Unit.PX);
+        e.getStyle().setTop(positionAndSize.getTop(), Unit.PX);
+        e.getStyle().setWidth(positionAndSize.getWidth(), Unit.PX);
+        e.getStyle().setHeight(positionAndSize.getHeight(), Unit.PX);
     }
 
     protected class ResizeAnimation extends Animation {
         @Override
         protected void onUpdate(double progress) {
-            sizeOrPositionUpdated(progress);
+            positionOrSizeUpdated(progress);
         }
     }
 
index 6a46d64c5afd4cd79015eeb9e8062400842955bc..280ca720fcc2ca534753dc8a6e7fbeafc87e7493 100644 (file)
@@ -477,7 +477,7 @@ public class VPopupView extends HTML implements Container, Iterable<Widget> {
     }
 
     public boolean requestLayout(Set<Paintable> child) {
-        popup.sizeOrPositionUpdated();
+        popup.positionOrSizeUpdated();
         return true;
     }