]> source.dussan.org Git - vaadin-framework.git/commitdiff
Removed extra getDeclaredWidth/getDeclaredHeight as they directly
authorArtur Signell <artur@vaadin.com>
Fri, 16 Mar 2012 13:13:47 +0000 (15:13 +0200)
committerArtur Signell <artur@vaadin.com>
Fri, 16 Mar 2012 13:33:29 +0000 (15:33 +0200)
contain the width and height from the state.

src/com/vaadin/terminal/gwt/client/ComponentConnector.java
src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java
src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java
src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java
src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java

index 7be7799604ade0027546e3079a865eca3044a6db..206be10700ba473f46def3a06cf14b9184d3cd3b 100644 (file)
@@ -70,20 +70,6 @@ public interface ComponentConnector extends ServerConnector {
      */
     public boolean isRelativeHeight();
 
-    /**
-     * Gets the width of this paintable as defined on the server.
-     * 
-     * @return the server side width definition
-     */
-    public String getDeclaredWidth();
-
-    /**
-     * Gets the height of this paintable as defined on the server.
-     * 
-     * @return the server side height definition
-     */
-    public String getDeclaredHeight();
-
     /**
      * Returns the parent of this connector. Can be null for only the root
      * connector.
index 81f0b59d064d1941541683bdfb42ac6252d65b07..c7f58df835a173fb62dae06deb91944d993f6c5e 100644 (file)
@@ -45,8 +45,8 @@ public abstract class AbstractComponentConnector extends AbstractConnector
     // shared state from the server to the client
     private ComponentState state;
 
-    private String declaredWidth = "";
-    private String declaredHeight = "";
+    private String lastKnownWidth = "";
+    private String lastKnownHeight = "";
 
     /**
      * Default constructor
@@ -205,75 +205,52 @@ public abstract class AbstractComponentConnector extends AbstractConnector
     }
 
     private void updateComponentSize() {
-        SharedState state = getState();
-
-        String w = "";
-        String h = "";
-        if (null != state || !(state instanceof ComponentState)) {
-            ComponentState componentState = (ComponentState) state;
-            // TODO move logging to VUIDLBrowser and VDebugConsole
-            // VConsole.log("Paintable state for "
-            // + getPaintableMap().getPid(paintable) + ": "
-            // + String.valueOf(state.getState()));
-            h = componentState.getHeight();
-            w = componentState.getWidth();
-        } else {
-            // TODO move logging to VUIDLBrowser and VDebugConsole
-            VConsole.log("No state for paintable " + getConnectorId()
-                    + " in VAbstractPaintableWidget.updateComponentSize()");
-        }
+        String newWidth = getState().getWidth();
+        String newHeight = getState().getHeight();
 
         // Parent should be updated if either dimension changed between relative
         // and non-relative
-        if (w.endsWith("%") != declaredWidth.endsWith("%")) {
+        if (newWidth.endsWith("%") != lastKnownWidth.endsWith("%")) {
             ComponentContainerConnector parent = getParent();
             if (parent instanceof ManagedLayout) {
                 getLayoutManager().setWidthNeedsUpdate((ManagedLayout) parent);
             }
         }
 
-        if (h.endsWith("%") != declaredHeight.endsWith("%")) {
+        if (newHeight.endsWith("%") != lastKnownHeight.endsWith("%")) {
             ComponentContainerConnector parent = getParent();
             if (parent instanceof ManagedLayout) {
                 getLayoutManager().setHeightNeedsUpdate((ManagedLayout) parent);
             }
         }
 
-        declaredWidth = w;
-        declaredHeight = h;
+        lastKnownWidth = newWidth;
+        lastKnownHeight = newHeight;
 
         // Set defined sizes
-        Widget component = getWidget();
+        Widget widget = getWidget();
 
-        component.setStyleName("v-has-width", !isUndefinedWidth());
-        component.setStyleName("v-has-height", !isUndefinedHeight());
+        widget.setStyleName("v-has-width", !isUndefinedWidth());
+        widget.setStyleName("v-has-height", !isUndefinedHeight());
 
-        component.setHeight(h);
-        component.setWidth(w);
+        widget.setHeight(newHeight);
+        widget.setWidth(newWidth);
     }
 
     public boolean isRelativeHeight() {
-        return declaredHeight.endsWith("%");
+        return getState().getHeight().endsWith("%");
     }
 
     public boolean isRelativeWidth() {
-        return declaredWidth.endsWith("%");
+        return getState().getWidth().endsWith("%");
     }
 
     public boolean isUndefinedHeight() {
-        return declaredHeight.length() == 0;
+        return getState().getHeight().length() == 0;
     }
 
     public boolean isUndefinedWidth() {
-        return declaredWidth.length() == 0;
-    }
-
-    public String getDeclaredHeight() {
-        return declaredHeight;
-    }
-
-    public String getDeclaredWidth() {
-        return declaredWidth;
+        return getState().getWidth().length() == 0;
     }
 
     /*
index f7ad2e6edaf7b206826d65869a48bfdcf7a6b2dd..0b077d93535b24eb8e05c687072417da5d010282 100644 (file)
@@ -193,9 +193,9 @@ public abstract class AbstractOrderedLayoutConnector extends
 
     private String getDefinedSize(boolean isVertical) {
         if (isVertical) {
-            return getDeclaredHeight();
+            return getState().getHeight();
         } else {
-            return getDeclaredWidth();
+            return getState().getWidth();
         }
     }
 
@@ -246,7 +246,7 @@ public abstract class AbstractOrderedLayoutConnector extends
             layout.addOrMove(slot, currentIndex++);
         }
 
-        // TODO: Move this to layout and base it on DOM and "currentIndex" 
+        // TODO: Move this to layout and base it on DOM and "currentIndex"
         for (ComponentConnector child : previousChildren) {
             Widget widget = child.getWidget();
             if (child.getParent() != this) {
index 537d76f2ececd37c987c0e813321ef907cc0e659..71240d9c1d7a225d084a618f9e6010c54a88b0e5 100644 (file)
@@ -86,8 +86,8 @@ public class VEmbedded extends HTML {
 
         ComponentConnector paintable = ConnectorMap.get(client).getConnector(
                 this);
-        String height = paintable.getDeclaredHeight();
-        String width = paintable.getDeclaredWidth();
+        String height = paintable.getState().getHeight();
+        String width = paintable.getState().getWidth();
 
         // Add width and height
         html.append("width=\"" + Util.escapeAttribute(width) + "\" ");
index 0d13a8e95bae2f6aa5d2b1fe7726022b9cc93734..bf6d37ec96e83966615c50c7e5b23281f455ee54 100644 (file)
@@ -976,7 +976,8 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
         if (!isDynamicWidth()) {
             ComponentConnector paintable = ConnectorMap.get(client)
                     .getConnector(this);
-            DOM.setStyleAttribute(tabs, "width", paintable.getDeclaredWidth());
+            DOM.setStyleAttribute(tabs, "width", paintable.getState()
+                    .getWidth());
         }
 
         // Make sure scrollerIndex is valid