]> source.dussan.org Git - vaadin-framework.git/commitdiff
#8323 Renamed getParentPaintable to getParent and cache the
authorArtur Signell <artur@vaadin.com>
Tue, 7 Feb 2012 08:32:50 +0000 (10:32 +0200)
committerArtur Signell <artur@vaadin.com>
Tue, 7 Feb 2012 08:32:50 +0000 (10:32 +0200)
parentvalue. Should still be changed so that the framework constructs
the paintable hierarchy and sets it to the paintables.

src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
src/com/vaadin/terminal/gwt/client/VPaintableWidget.java
src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java

index 882251852b5398001b30f0b5bbf347eb0729f46b..bce5534eeb8e05a775b110e39e1e0d585e9b0f0d 100644 (file)
@@ -1660,7 +1660,7 @@ public class ApplicationConnection {
             // Changed invisibile <-> visible
             if (wasVisible && manageCaption) {
                 // Must hide caption when component is hidden
-                updateCaption(paintable, uidl);
+                paintable.getParent().updateCaption(paintable, uidl);
             }
         }
 
@@ -1705,7 +1705,7 @@ public class ApplicationConnection {
 
         // Set captions
         if (manageCaption) {
-            updateCaption(paintable, uidl);
+            paintable.getParent().updateCaption(paintable, uidl);
         }
 
         // add error classname to components w/ error
@@ -1725,12 +1725,6 @@ public class ApplicationConnection {
         return false;
     }
 
-    @Deprecated
-    private void updateCaption(VPaintableWidget paintable, UIDL uidl) {
-        VPaintableWidgetContainer parent = paintable.getParentPaintable();
-        parent.updateCaption(paintable, uidl);
-    }
-
     /**
      * Generates the style name for the widget based on the given primary style
      * name (typically returned by Widget.getPrimaryStyleName()) and the UIDL.
@@ -1931,8 +1925,7 @@ public class ApplicationConnection {
         boolean horizontalScrollBar = false;
         boolean verticalScrollBar = false;
 
-        VPaintableWidgetContainer parentPaintable = paintable
-                .getParentPaintable();
+        VPaintableWidgetContainer parentPaintable = paintable.getParent();
         RenderSpace renderSpace;
 
         // Parent-less components (like sub-windows) are relative to browser
index 11b6c9d0f6dbedd9e3c573f5488d87775e49f1e8..4b8720b1325af30fd9e90266b28928de23c538bb 100644 (file)
@@ -27,5 +27,5 @@ public interface VPaintableWidget extends VPaintable {
      * @return
      */
     // FIXME: Rename to getParent()
-    public VPaintableWidgetContainer getParentPaintable();
+    public VPaintableWidgetContainer getParent();
 }
index 09bf02ec439f158c0c0868155c8c84d972964551..474e9c416d4f66135433b7fc6f14a3de534882b2 100644 (file)
@@ -14,7 +14,8 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
     private Widget widget;
     private ApplicationConnection connection;
     private String id;
-
+    private VPaintableWidgetContainer parent;
+    
     /* State variables */
     private boolean enabled = true;
 
@@ -84,17 +85,19 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
         this.id = id;
     }
 
-    public VPaintableWidgetContainer getParentPaintable() {
-        // FIXME: Return VPaintableWidgetContainer
-        // FIXME: Store hierarchy instead of doing lookup every time
-
+    public VPaintableWidgetContainer getParent() {
+        if (parent != null)
+            return parent;
+        
+        // FIXME: Hierarchy should be set by framework instead of looked up here
         VPaintableMap paintableMap = VPaintableMap.get(getConnection());
 
         Widget w = getWidgetForPaintable();
         while (w != null) {
             w = w.getParent();
             if (paintableMap.isPaintable(w)) {
-                return (VPaintableWidgetContainer) paintableMap.getPaintable(w);
+                parent = (VPaintableWidgetContainer) paintableMap.getPaintable(w);
+                return parent;
             }
         }