From: Artur Signell Date: Fri, 16 Mar 2012 13:13:47 +0000 (+0200) Subject: Removed extra getDeclaredWidth/getDeclaredHeight as they directly X-Git-Tag: 7.0.0.alpha2~298 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ce24fb4f0289cf8bb8841d397ccb214189530905;p=vaadin-framework.git Removed extra getDeclaredWidth/getDeclaredHeight as they directly contain the width and height from the state. --- diff --git a/src/com/vaadin/terminal/gwt/client/ComponentConnector.java b/src/com/vaadin/terminal/gwt/client/ComponentConnector.java index 7be7799604..206be10700 100644 --- a/src/com/vaadin/terminal/gwt/client/ComponentConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ComponentConnector.java @@ -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. diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java index 81f0b59d06..c7f58df835 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java @@ -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; } /* diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java index f7ad2e6eda..0b077d9353 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java @@ -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) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java b/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java index 537d76f2ec..71240d9c1d 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java @@ -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) + "\" "); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java index 0d13a8e95b..bf6d37ec96 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java @@ -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