]> source.dussan.org Git - vaadin-framework.git/commitdiff
Store MeasuredSize instance in VAbstractPaintableWidget (#8313)
authorLeif Åstrand <leif@vaadin.com>
Tue, 7 Feb 2012 12:52:46 +0000 (14:52 +0200)
committerLeif Åstrand <leif@vaadin.com>
Tue, 7 Feb 2012 12:52:46 +0000 (14:52 +0200)
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
src/com/vaadin/terminal/gwt/client/ComponentDetail.java
src/com/vaadin/terminal/gwt/client/MeasureManager.java
src/com/vaadin/terminal/gwt/client/VPaintableMap.java
src/com/vaadin/terminal/gwt/client/VPaintableWidget.java
src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
src/com/vaadin/terminal/gwt/client/ui/VMeasuringOrderedLayoutPaintable.java

index 9b112587a0ff1f334c916e5840326746507cc912..afd8130ada6b091dec4a7dd9bedced2551df14bf 100644 (file)
@@ -1789,7 +1789,8 @@ public class ApplicationConnection {
         // Dirty if either dimension changed between relative and non-relative
         if (w.endsWith("%") != style.getWidth().endsWith("%")
                 || h.endsWith("%") != style.getHeight().endsWith("%")) {
-            MeasureManager.MeasuredSize measuredSize = getMeasuredSize(paintable);
+            MeasureManager.MeasuredSize measuredSize = paintable
+                    .getMeasuredSize();
             if (measuredSize != null) {
                 measuredSize.setDirty(true);
             }
@@ -2252,10 +2253,4 @@ public class ApplicationConnection {
             Scheduler.get().scheduleDeferred(layoutCommand);
         }
     }
-
-    public MeasureManager.MeasuredSize getMeasuredSize(
-            VPaintableWidget paintable) {
-        return paintableMap.getMeasuredSize(paintable);
-    }
-
 }
index e70a49fdade0f50474f5683481cc82d2fcaa31c4..eff5a76583c5d2c1cf054f5f78d82733b605ff8d 100644 (file)
@@ -6,13 +6,11 @@ package com.vaadin.terminal.gwt.client;
 import java.util.HashMap;
 
 import com.google.gwt.core.client.JsArrayString;
-import com.vaadin.terminal.gwt.client.MeasureManager.MeasuredSize;
 import com.vaadin.terminal.gwt.client.RenderInformation.Size;
 
 class ComponentDetail {
 
     private TooltipInfo tooltipInfo = new TooltipInfo();
-    private MeasureManager.MeasuredSize measuredSize = new MeasureManager.MeasuredSize();
 
     public ComponentDetail() {
 
@@ -49,8 +47,7 @@ class ComponentDetail {
     private HashMap<Object, TooltipInfo> additionalTooltips;
 
     /**
-
-    /**
+     * 
      * @return the offsetSize
      */
     Size getOffsetSize() {
@@ -110,8 +107,4 @@ class ComponentDetail {
         }
         return false;
     }
-
-    public MeasureManager.MeasuredSize getMeasuredSize() {
-        return measuredSize;
-    }
 }
index ed0bb20cf8eaeafd0d063fb00b498619e95891c6..cab4822ef434a854731e73826ecaaf26ad277cc9 100644 (file)
@@ -180,8 +180,8 @@ public class MeasureManager {
         for (VPaintableWidget paintableWidget : paintableWidgets) {
             Widget widget = paintableWidget.getWidgetForPaintable();
 
-            MeasureManager.MeasuredSize measuredSize = paintableMap
-                    .getMeasuredSize(paintableWidget);
+            MeasureManager.MeasuredSize measuredSize = paintableWidget
+                    .getMeasuredSize();
 
             measuredSize.setWidth(widget.getOffsetWidth());
             measuredSize.setHeight(widget.getOffsetHeight());
index 309c527e7a26324b0d20f9ac75ec554e21a1974f..48d32f4a5be691d73169c20248483586bd74e969 100644 (file)
@@ -17,7 +17,6 @@ import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.ui.HasWidgets;
 import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.terminal.Paintable;
-import com.vaadin.terminal.gwt.client.MeasureManager.MeasuredSize;
 import com.vaadin.terminal.gwt.client.RenderInformation.Size;
 
 public class VPaintableMap {
@@ -392,17 +391,4 @@ public class VPaintableMap {
         return getPid(w) != null;
     }
 
-    /**
-     * FIXME: Should not be here
-     */
-    @Deprecated
-    public MeasuredSize getMeasuredSize(VPaintableWidget paintable) {
-        ComponentDetail componentDetail = getComponentDetail(paintable);
-        if (componentDetail == null) {
-            return null;
-        }
-
-        return componentDetail.getMeasuredSize();
-    }
-
 }
\ No newline at end of file
index 4b8720b1325af30fd9e90266b28928de23c538bb..a66129fd877bfb2edf5051bce0bab0c41f18188e 100644 (file)
@@ -5,6 +5,7 @@
 package com.vaadin.terminal.gwt.client;
 
 import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.terminal.gwt.client.MeasureManager.MeasuredSize;
 
 /**
  * An interface used by client-side widgets or paintable parts to receive
@@ -28,4 +29,6 @@ public interface VPaintableWidget extends VPaintable {
      */
     // FIXME: Rename to getParent()
     public VPaintableWidgetContainer getParent();
+
+    public MeasuredSize getMeasuredSize();
 }
index 9747deacd1b3b46ac9bad940a171f93efc6cdcaa..1555371e47108f701b60c1534b60cf5a4f0f5395 100644 (file)
@@ -5,6 +5,7 @@ package com.vaadin.terminal.gwt.client.ui;
 
 import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.MeasureManager.MeasuredSize;
 import com.vaadin.terminal.gwt.client.VPaintableMap;
 import com.vaadin.terminal.gwt.client.VPaintableWidget;
 import com.vaadin.terminal.gwt.client.VPaintableWidgetContainer;
@@ -16,6 +17,8 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
     private String id;
     private VPaintableWidgetContainer parent;
 
+    private final MeasuredSize measuredSize = new MeasuredSize();
+
     /* State variables */
     private boolean enabled = true;
 
@@ -106,4 +109,8 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
             }
         }
     }
+
+    public MeasuredSize getMeasuredSize() {
+        return measuredSize;
+    }
 }
index 5e0565f5396d46b5ef7af9f6592e0c2ca2853a6a..f1838cf30e19a8e54635225c102c33d3d85fb444 100644 (file)
@@ -31,8 +31,8 @@ public abstract class VMeasuringOrderedLayoutPaintable extends
                 getWidgetForPaintable().addCaption(caption, widget);
                 getWidgetForPaintable().captions.put(component, caption);
 
-                MeasureManager.MeasuredSize measuredSize = getWidgetForPaintable().client
-                        .getMeasuredSize(component);
+                MeasureManager.MeasuredSize measuredSize = component
+                        .getMeasuredSize();
 
                 measuredSize.registerDependency(caption.getElement());
             }
@@ -42,8 +42,8 @@ public abstract class VMeasuringOrderedLayoutPaintable extends
                     .remove(component);
             if (removedCaption != null) {
                 getWidgetForPaintable().remove(removedCaption);
-                MeasureManager.MeasuredSize measuredSize = getWidgetForPaintable().client
-                        .getMeasuredSize(component);
+                MeasureManager.MeasuredSize measuredSize = component
+                        .getMeasuredSize();
                 measuredSize.deRegisterDependency(removedCaption.getElement());
             }
         }
@@ -82,7 +82,7 @@ public abstract class VMeasuringOrderedLayoutPaintable extends
 
             if (!childUIDL.getBooleanAttribute("cached")) {
                 child.updateFromUIDL(childUIDL, client);
-                client.getMeasuredSize(child).setDirty(true);
+                child.getMeasuredSize().setDirty(true);
             }
             // TODO Update alignments and expand ratios
 
@@ -113,7 +113,7 @@ public abstract class VMeasuringOrderedLayoutPaintable extends
         getWidgetForPaintable().expandRatios = uidl
                 .getMapAttribute("expandRatios");
         getWidgetForPaintable().alignments = uidl.getMapAttribute("alignments");
-        client.getMeasuredSize(this).setDirty(true);
+        getMeasuredSize().setDirty(true);
     }
 
     private int getCaptionWidth(VPaintableWidget child) {
@@ -121,8 +121,7 @@ public abstract class VMeasuringOrderedLayoutPaintable extends
         if (caption == null) {
             return 0;
         } else {
-            MeasureManager.MeasuredSize measuredSize = getWidgetForPaintable().client
-                    .getMeasuredSize(child);
+            MeasureManager.MeasuredSize measuredSize = child.getMeasuredSize();
             return measuredSize.getDependencyWidth(caption.getElement());
         }
     }
@@ -131,8 +130,7 @@ public abstract class VMeasuringOrderedLayoutPaintable extends
 
         VCaption caption = getWidgetForPaintable().captions.get(child);
         if (caption != null) {
-            MeasureManager.MeasuredSize measuredSize = getWidgetForPaintable().client
-                    .getMeasuredSize(child);
+            MeasureManager.MeasuredSize measuredSize = child.getMeasuredSize();
             int captionHeight = measuredSize.getDependencyHeight(caption
                     .getElement());
 
@@ -181,8 +179,7 @@ public abstract class VMeasuringOrderedLayoutPaintable extends
 
     private int getMeasuredInDirection(VPaintableWidget paintable,
             boolean isVertical) {
-        MeasureManager.MeasuredSize measuredSize = getWidgetForPaintable().client
-                .getMeasuredSize(paintable);
+        MeasureManager.MeasuredSize measuredSize = paintable.getMeasuredSize();
         if (isVertical) {
             return measuredSize.getHeight();
         } else {