]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge branch 'master' into layoutgraph
authorJohn Ahlroos <john@vaadin.com>
Mon, 3 Sep 2012 08:41:06 +0000 (11:41 +0300)
committerJohn Ahlroos <john@vaadin.com>
Mon, 3 Sep 2012 08:41:06 +0000 (11:41 +0300)
Conflicts:
shared/src/com/vaadin/shared/ComponentState.java

1  2 
client/src/com/vaadin/client/ComponentLocator.java
client/src/com/vaadin/client/LayoutManager.java
client/src/com/vaadin/client/ui/AbstractComponentConnector.java
client/src/com/vaadin/client/ui/AbstractConnector.java
client/src/com/vaadin/client/ui/orderedlayout/AbstractBoxLayoutConnector.java
shared/src/com/vaadin/shared/ComponentState.java

index c886d2f94cf283ca82461cb55f07ce3ab6854d8c,d5e8dc0ba0e48b4c562df3be4b913a354e742d7f..a17c3bc5142a18befb499e1e95555815d802c5b0
@@@ -42,11 -42,11 +42,12 @@@ import com.vaadin.client.ui.datefield.P
  import com.vaadin.shared.ComponentConstants;
  import com.vaadin.shared.ComponentState;
  import com.vaadin.shared.Connector;
+ import com.vaadin.shared.ui.ComponentStateUtil;
  import com.vaadin.shared.ui.TabIndexState;
 +import com.vaadin.ui.themes.BaseTheme;
  
  public abstract class AbstractComponentConnector extends AbstractConnector
 -        implements ComponentConnector {
 +implements ComponentConnector {
  
      private Widget widget;
  
index a4fcea81f592f0be5d1a8cbaf4076626cf97c7a2,0000000000000000000000000000000000000000..6402d0696f0ebe066714821e33c7e0916ae483f1
mode 100644,000000..100644
--- /dev/null
@@@ -1,608 -1,0 +1,607 @@@
-         String caption = child.getState().getCaption();
 +/*
 +@VaadinApache2LicenseForJavaFiles@
 + */
 +package com.vaadin.client.ui.orderedlayout;
 +
 +import java.util.HashMap;
 +import java.util.HashSet;
 +import java.util.List;
 +
 +import com.google.gwt.dom.client.Style.Unit;
 +import com.google.gwt.user.client.Element;
 +import com.vaadin.client.ComponentConnector;
 +import com.vaadin.client.ConnectorHierarchyChangeEvent;
 +import com.vaadin.client.Util;
 +import com.vaadin.client.communication.RpcProxy;
 +import com.vaadin.client.communication.StateChangeEvent;
 +import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
 +import com.vaadin.client.ui.AbstractFieldConnector;
 +import com.vaadin.client.ui.AbstractLayoutConnector;
 +import com.vaadin.client.ui.LayoutClickEventHandler;
 +import com.vaadin.client.ui.layout.ElementResizeEvent;
 +import com.vaadin.client.ui.layout.ElementResizeListener;
 +import com.vaadin.client.ui.orderedlayout.VBoxLayout.CaptionPosition;
 +import com.vaadin.client.ui.orderedlayout.VBoxLayout.Slot;
 +import com.vaadin.shared.AbstractFieldState;
 +import com.vaadin.shared.ComponentConstants;
 +import com.vaadin.shared.communication.URLReference;
 +import com.vaadin.shared.ui.AlignmentInfo;
 +import com.vaadin.shared.ui.LayoutClickRpc;
 +import com.vaadin.shared.ui.MarginInfo;
 +import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutServerRpc;
 +import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState;
 +
 +public abstract class AbstractBoxLayoutConnector extends
 +        AbstractLayoutConnector /* implements PostLayoutListener */{
 +
 +    AbstractOrderedLayoutServerRpc rpc;
 +
 +    private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler(
 +            this) {
 +
 +        @Override
 +        protected ComponentConnector getChildComponent(Element element) {
 +            return Util.getConnectorForElement(getConnection(), getWidget(),
 +                    element);
 +        }
 +
 +        @Override
 +        protected LayoutClickRpc getLayoutClickRPC() {
 +            return rpc;
 +        };
 +
 +    };
 +
 +    @Override
 +    public void init() {
 +        super.init();
 +        rpc = RpcProxy.create(AbstractOrderedLayoutServerRpc.class, this);
 +        getWidget().setLayoutManager(getLayoutManager());
 +    }
 +
 +    @Override
 +    public AbstractOrderedLayoutState getState() {
 +        return (AbstractOrderedLayoutState) super.getState();
 +    }
 +
 +    @Override
 +    public VBoxLayout getWidget() {
 +        return (VBoxLayout) super.getWidget();
 +    }
 +
 +    /**
 +     * For bookkeeping. Used to determine if extra calculations are needed for
 +     * horizontal layout.
 +     */
 +    private HashSet<ComponentConnector> hasVerticalAlignment = new HashSet<ComponentConnector>();
 +
 +    /**
 +     * For bookkeeping. Used to determine if extra calculations are needed for
 +     * horizontal layout.
 +     */
 +    private HashSet<ComponentConnector> hasRelativeHeight = new HashSet<ComponentConnector>();
 +
 +    /**
 +     * For bookkeeping. Used to determine if extra calculations are needed for
 +     * horizontal layout.
 +     */
 +    private HashSet<ComponentConnector> hasExpandRatio = new HashSet<ComponentConnector>();
 +
 +    /**
 +     * For bookkeeping. Used in extra calculations for horizontal layout.
 +     */
 +    private HashSet<Element> needsMeasure = new HashSet<Element>();
 +
 +    /**
 +     * For bookkeeping. Used in extra calculations for horizontal layout.
 +     */
 +    // private HashMap<Element, Integer> childElementHeight = new
 +    // HashMap<Element, Integer>();
 +
 +    /**
 +     * For bookkeeping. Used in extra calculations for horizontal layout.
 +     */
 +    private HashMap<Element, Integer> childCaptionElementHeight = new HashMap<Element, Integer>();
 +
 +    @Override
 +    public void updateCaption(ComponentConnector child) {
 +        Slot slot = getWidget().getSlot(child);
 +
 +
-                 List<String> styles = child.getState().getStyles();
-                 String error = child.getState().getErrorMessage();
++        String caption = child.getState().caption;
 +        URLReference iconUrl = child.getState().resources
 +                .get(ComponentConstants.ICON_RESOURCE);
 +        String iconUrlString = iconUrl != null ? iconUrl.toString() : null;
-                     showError = showError && !abstractFieldState.isHideErrors();
++        List<String> styles = child.getState().styles;
++        String error = child.getState().errorMessage;
 +                boolean showError = error != null;
 +                if (child.getState() instanceof AbstractFieldState) {
 +                    AbstractFieldState abstractFieldState = (AbstractFieldState) child
 +                            .getState();
-                 boolean enabled = child.getState().isEnabled();
++            showError = showError && !abstractFieldState.hideErrors;
 +                }
 +                boolean required = false;
 +                if (child instanceof AbstractFieldConnector) {
 +                    required = ((AbstractFieldConnector) child).isRequired();
 +                }
-         getWidget().setMargin(new MarginInfo(getState().getMarginsBitmask()));
-         getWidget().setSpacing(getState().isSpacing());
++        boolean enabled = child.getState().enabled;
 +
 +        slot.setCaption(caption, iconUrlString, styles, error, showError,
 +                required,
 +                        enabled);
 +
 +                slot.setRelativeWidth(child.isRelativeWidth());
 +                slot.setRelativeHeight(child.isRelativeHeight());
 +
 +                if (slot.hasCaption()) {
 +                    CaptionPosition pos = slot.getCaptionPosition();
 +                    getLayoutManager().addElementResizeListener(
 +                            slot.getCaptionElement(), slotCaptionResizeListener);
 +                    if (child.isRelativeHeight()
 +                            && (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM)) {
 +                        getWidget().updateCaptionOffset(slot.getCaptionElement());
 +                    } else if (child.isRelativeWidth()
 +                            && (pos == CaptionPosition.LEFT || pos == CaptionPosition.RIGHT)) {
 +                        getWidget().updateCaptionOffset(slot.getCaptionElement());
 +                    }
 +                } else {
 +                    childCaptionElementHeight.remove(child.getWidget().getElement());
 +                }
 +
 +                updateLayoutHeight();
 +
 +                if (needsExpand()) {
 +                    updateExpand();
 +                }
 +    }
 +
 +    @Override
 +    public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
 +        super.onConnectorHierarchyChange(event);
 +
 +        List<ComponentConnector> previousChildren = event.getOldChildren();
 +        int currentIndex = 0;
 +        VBoxLayout layout = getWidget();
 +
 +        for (ComponentConnector child : getChildComponents()) {
 +            Slot slot = layout.getSlot(child);
 +            if (slot.getParent() != layout) {
 +                child.addStateChangeHandler(childStateChangeHandler);
 +            }
 +            layout.addOrMoveSlot(slot, currentIndex++);
 +        }
 +
 +        for (ComponentConnector child : previousChildren) {
 +            if (child.getParent() != this) {
 +                Slot slot = layout.getSlot(child);
 +                hasVerticalAlignment.remove(child);
 +                hasRelativeHeight.remove(child);
 +                hasExpandRatio.remove(child);
 +                needsMeasure.remove(child.getWidget().getElement());
 +                // childElementHeight.remove(child.getWidget().getElement());
 +                childCaptionElementHeight
 +                .remove(child.getWidget().getElement());
 +                getLayoutManager().removeElementResizeListener(
 +                        child.getWidget().getElement(),
 +                        childComponentResizeListener);
 +                if (slot.hasCaption()) {
 +                    getLayoutManager()
 +                    .removeElementResizeListener(
 +                            slot.getCaptionElement(),
 +                            slotCaptionResizeListener);
 +                }
 +                if (slot.getSpacingElement() != null) {
 +                    getLayoutManager().removeElementResizeListener(
 +                            slot.getSpacingElement(), spacingResizeListener);
 +                }
 +                child.removeStateChangeHandler(childStateChangeHandler);
 +                layout.removeSlot(child.getWidget());
 +            }
 +        }
 +
 +        // If some component is added/removed, we need to recalculate the expand
 +        if (needsExpand()) {
 +            updateExpand();
 +        } else {
 +            getWidget().clearExpand();
 +        }
 +
 +    }
 +
 +    @Override
 +    public void onStateChanged(StateChangeEvent stateChangeEvent) {
 +        super.onStateChanged(stateChangeEvent);
 +
 +        clickEventHandler.handleEventHandlerRegistration();
-             double expandRatio = getState().getChildData().get(child)
-                     .getExpandRatio();
++        getWidget().setMargin(new MarginInfo(getState().marginsBitmask));
++        getWidget().setSpacing(getState().spacing);
 +
 +        hasExpandRatio.clear();
 +        hasVerticalAlignment.clear();
 +        hasRelativeHeight.clear();
 +        needsMeasure.clear();
 +
 +        boolean equalExpandRatio = getWidget().vertical ? !isUndefinedHeight()
 +                : !isUndefinedWidth();
 +        for (ComponentConnector child : getChildComponents()) {
-             AlignmentInfo alignment = new AlignmentInfo(getState()
-                     .getChildData().get(child).getAlignmentBitmask());
++            double expandRatio = getState().childData.get(child).expandRatio;
 +            if (expandRatio > 0) {
 +                equalExpandRatio = false;
 +                break;
 +            }
 +        }
 +
 +        for (ComponentConnector child : getChildComponents()) {
 +            Slot slot = getWidget().getSlot(child);
 +
-             double expandRatio = getState().getChildData().get(child)
-                     .getExpandRatio();
++            AlignmentInfo alignment = new AlignmentInfo(
++                    getState().childData.get(child).alignmentBitmask);
 +            slot.setAlignment(alignment);
 +
++            double expandRatio = getState().childData.get(child).expandRatio;
++
 +            if (equalExpandRatio) {
 +                expandRatio = 1;
 +            } else if (expandRatio == 0) {
 +                expandRatio = -1;
 +            }
 +            slot.setExpandRatio(expandRatio);
 +
 +            // Bookkeeping to identify special cases that need extra
 +            // calculations
 +            if (alignment.isVerticalCenter() || alignment.isBottom()) {
 +                hasVerticalAlignment.add(child);
 +            }
 +
 +            if (expandRatio > 0) {
 +                hasExpandRatio.add(child);
 +            }
 +
 +            // if (child.getState().isRelativeHeight()) {
 +            // hasRelativeHeight.add(child);
 +            // } else {
 +            // needsMeasure.add(child.getWidget().getElement());
 +            // }
 +        }
 +
 +        updateAllSlotListeners();
 +
 +        updateLayoutHeight();
 +    }
 +
 +    StateChangeHandler childStateChangeHandler = new StateChangeHandler() {
 +        @Override
 +        public void onStateChanged(StateChangeEvent stateChangeEvent) {
 +
 +            ComponentConnector child = (ComponentConnector) stateChangeEvent
 +                    .getConnector();
 +
 +            // We need to update the slot size if the component size is changed
 +            // to relative
 +            Slot slot = getWidget().getSlot(child);
 +            slot.setRelativeWidth(child.isRelativeWidth());
 +            slot.setRelativeHeight(child.isRelativeHeight());
 +
 +            // For relative sized widgets, we need to set the caption offset
 +            // if (slot.hasCaption()) {
 +            // CaptionPosition pos = slot.getCaptionPosition();
 +            // if (child.isRelativeHeight()
 +            // && (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM))
 +            // {
 +            // getWidget().updateCaptionOffset(slot.getCaptionElement());
 +            // } else if (child.isRelativeWidth()
 +            // && (pos == CaptionPosition.LEFT || pos == CaptionPosition.RIGHT))
 +            // {
 +            // getWidget().updateCaptionOffset(slot.getCaptionElement());
 +            // }
 +            // }
 +
 +            updateSlotListeners(child);
 +            // updateAllSlotListeners();
 +
 +            updateLayoutHeight();
 +        }
 +    };
 +
 +    private boolean needsFixedHeight() {
 +        if (!getWidget().vertical
 +                && isUndefinedHeight()
 +                && (hasRelativeHeight.size() > 0 || (hasVerticalAlignment
 +                        .size() > 0 && hasVerticalAlignment.size() < getChildren()
 +                        .size()))) {
 +            return true;
 +        }
 +        return false;
 +    }
 +
 +    private boolean needsExpand() {
 +        boolean canApplyExpand = (getWidget().vertical && !isUndefinedHeight())
 +                || (!getWidget().vertical && !isUndefinedWidth());
 +        return hasExpandRatio.size() > 0 && canApplyExpand;
 +    }
 +
 +    private void updateAllSlotListeners() {
 +        for (ComponentConnector child : getChildComponents()) {
 +            updateSlotListeners(child);
 +        }
 +        // if (needsFixedHeight()) {
 +        // getWidget().clearHeight();
 +        // setLayoutHeightListener(true);
 +        // getLayoutManager().setNeedsMeasure(AbstractBoxLayoutConnector.this);
 +        // } else {
 +        // setLayoutHeightListener(false);
 +        // }
 +    }
 +
 +    /**
 +     * Add/remove necessary ElementResizeListeners for one slot. This should be
 +     * called after each update to the slot's or it's widget.
 +     */
 +    private void updateSlotListeners(ComponentConnector child) {
 +        Slot slot = getWidget().getSlot(child);
 +
 +        // Clear all possible listeners first
 +        dontListen(slot.getWidget().getElement(), childComponentResizeListener);
 +        if (slot.hasCaption()) {
 +            dontListen(slot.getCaptionElement(), slotCaptionResizeListener);
 +        }
 +        if (slot.hasSpacing()) {
 +            dontListen(slot.getSpacingElement(), spacingResizeListener);
 +        }
 +
 +        // Add all necessary listeners
 +        if (needsFixedHeight()) {
 +            listen(slot.getWidget().getElement(), childComponentResizeListener);
 +            if (slot.hasCaption()) {
 +                listen(slot.getCaptionElement(), slotCaptionResizeListener);
 +            }
 +        } else if ((child.isRelativeHeight() || child.isRelativeWidth())
 +                && slot.hasCaption()) {
 +            // If the slot has caption, we need to listen for it's size changes
 +            // in order to update the padding/margin offset for relative sized
 +            // components
 +            listen(slot.getCaptionElement(), slotCaptionResizeListener);
 +        }
 +
 +        if (needsExpand()) {
 +            listen(slot.getWidget().getElement(), childComponentResizeListener);
 +            if (slot.hasSpacing()) {
 +                listen(slot.getSpacingElement(), spacingResizeListener);
 +            }
 +        }
 +
 +        if (child.isRelativeHeight()) {
 +            hasRelativeHeight.add(child);
 +            needsMeasure.remove(child.getWidget().getElement());
 +        } else {
 +            hasRelativeHeight.remove(child);
 +            needsMeasure.add(child.getWidget().getElement());
 +        }
 +
 +    }
 +
 +    // public void postLayout() {
 +    // if (needsFixedHeight()) {
 +    // // Re-measure all elements that are available
 +    // for (Element el : needsMeasure) {
 +    // childElementHeight.put(el, getLayoutManager()
 +    // .getOuterHeight(el));
 +    //
 +    // Element captionElement = el.getParentElement()
 +    // .getFirstChildElement().cast();
 +    // if (captionElement.getClassName().contains("v-caption")) {
 +    // childCaptionElementHeight.put(el, getLayoutManager()
 +    // .getOuterHeight(captionElement));
 +    // }
 +    // }
 +    // // System.out.println("  ###  Child sizes: "
 +    // // + childElementHeight.values().toString());
 +    // // System.out.println("  ###  Caption sizes: "
 +    // // + childCaptionElementHeight.values().toString());
 +    //
 +    // int height = getMaxHeight()
 +    // + getLayoutManager().getBorderHeight(
 +    // getWidget().getElement())
 +    // + getLayoutManager().getPaddingHeight(
 +    // getWidget().getElement());
 +    // getWidget().getElement().getStyle().setHeight(height, Unit.PX);
 +    // }
 +    // }
 +
 +    // private ElementResizeListener layoutResizeListener = new
 +    // ElementResizeListener() {
 +    // public void onElementResize(ElementResizeEvent e) {
 +    // updateLayoutHeight();
 +    // if (needsExpand() && (isUndefinedHeight() || isUndefinedWidth())) {
 +    // updateExpand();
 +    // }
 +    // }
 +    // };
 +
 +    private ElementResizeListener slotCaptionResizeListener = new ElementResizeListener() {
 +        @Override
 +        public void onElementResize(ElementResizeEvent e) {
 +
 +            // Get all needed element references
 +            Element captionElement = (Element) e.getElement().cast();
 +
 +            // Caption position determines if the widget element is the first or
 +            // last child inside the caption wrap
 +            CaptionPosition pos = getWidget().getCaptionPositionFromElement(
 +                    (Element) captionElement.getParentElement().cast());
 +
 +            // The default is the last child
 +            Element widgetElement = captionElement.getParentElement()
 +                    .getLastChild().cast();
 +
 +            // ...but if caption position is bottom or right, the widget is the
 +            // first child
 +            if (pos == CaptionPosition.BOTTOM || pos == CaptionPosition.RIGHT) {
 +                widgetElement = captionElement.getParentElement()
 +                        .getFirstChildElement().cast();
 +            }
 +
 +            if (captionElement == widgetElement) {
 +                // Caption element already detached
 +                dontListen(captionElement, slotCaptionResizeListener);
 +                childCaptionElementHeight.remove(widgetElement);
 +                return;
 +            }
 +
 +            String widgetWidth = widgetElement.getStyle().getWidth();
 +            String widgetHeight = widgetElement.getStyle().getHeight();
 +
 +            if (widgetHeight.endsWith("%")
 +                    && (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM)) {
 +                getWidget().updateCaptionOffset(captionElement);
 +            } else if (widgetWidth.endsWith("%")
 +                    && (pos == CaptionPosition.LEFT || pos == CaptionPosition.RIGHT)) {
 +                getWidget().updateCaptionOffset(captionElement);
 +            }
 +
 +            int h = getLayoutManager().getOuterHeight(captionElement)
 +                    - getLayoutManager().getMarginHeight(captionElement);
 +            childCaptionElementHeight.put(widgetElement, h);
 +
 +            // if (needsFixedHeight()) {
 +            // getWidget().clearHeight();
 +            // getLayoutManager().setNeedsMeasure(
 +            // AbstractBoxLayoutConnector.this);
 +            // }
 +
 +            updateLayoutHeight();
 +
 +            if (needsExpand()) {
 +                updateExpand();
 +            }
 +        }
 +    };
 +
 +    private ElementResizeListener childComponentResizeListener = new ElementResizeListener() {
 +        @Override
 +        public void onElementResize(ElementResizeEvent e) {
 +            // int h = getLayoutManager().getOuterHeight(e.getElement());
 +            // childElementHeight.put((Element) e.getElement().cast(), h);
 +            updateLayoutHeight();
 +
 +            if (needsExpand()) {
 +                updateExpand();
 +            }
 +        }
 +    };
 +
 +    private ElementResizeListener spacingResizeListener = new ElementResizeListener() {
 +        @Override
 +        public void onElementResize(ElementResizeEvent e) {
 +            if (needsExpand()) {
 +                updateExpand();
 +            }
 +        }
 +    };
 +
 +    private void updateLayoutHeight() {
 +        if (needsFixedHeight()) {
 +            int h = getMaxHeight();
 +            h += getLayoutManager().getBorderHeight(getWidget().getElement())
 +                    + getLayoutManager().getPaddingHeight(
 +                            getWidget().getElement());
 +            getWidget().getElement().getStyle().setHeight(h, Unit.PX);
 +            getLayoutManager().setNeedsMeasure(this);
 +        }
 +    }
 +
 +    private void updateExpand() {
 +        // System.out.println("All sizes: "
 +        // + childElementHeight.values().toString() + " - Caption sizes: "
 +        // + childCaptionElementHeight.values().toString());
 +        getWidget().updateExpand();
 +    }
 +
 +    private int getMaxHeight() {
 +        int highestNonRelative = -1;
 +        int highestRelative = -1;
 +
 +        for (ComponentConnector child : getChildComponents()) {
 +            // TODO would be more efficient to measure the slot element if both
 +            // caption and child widget elements need to be measured. Keeping
 +            // track of what to measure is the most difficult part of this
 +            // layout.
 +            Element el = child.getWidget().getElement();
 +            CaptionPosition pos = getWidget().getCaptionPositionFromElement(
 +                    (Element) el.getParentElement().cast());
 +            if (needsMeasure.contains(el)) {
 +                int h = getLayoutManager().getOuterHeight(el);
 +                String sHeight = el.getStyle().getHeight();
 +                // Only add the caption size to the height of the slot if
 +                // coption position is top or bottom
 +                if (childCaptionElementHeight.containsKey(el)
 +                        && (sHeight == null || !sHeight.endsWith("%"))
 +                        && (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM)) {
 +                    h += childCaptionElementHeight.get(el);
 +                }
 +                if (h > highestNonRelative) {
 +                    highestNonRelative = h;
 +                }
 +            } else {
 +                int h = getLayoutManager().getOuterHeight(el);
 +                if (childCaptionElementHeight.containsKey(el)
 +                        && (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM)) {
 +                    h += childCaptionElementHeight.get(el);
 +                }
 +                if (h > highestRelative) {
 +                    highestRelative = h;
 +                }
 +            }
 +        }
 +        return highestNonRelative > -1 ? highestNonRelative : highestRelative;
 +    }
 +
 +    @Override
 +    public void onUnregister() {
 +        // Cleanup all ElementResizeListeners
 +
 +        // dontListen(getWidget().getElement(), layoutResizeListener);
 +
 +        for (ComponentConnector child : getChildComponents()) {
 +            Slot slot = getWidget().getSlot(child);
 +            if (slot.hasCaption()) {
 +                dontListen(slot.getCaptionElement(), slotCaptionResizeListener);
 +            }
 +
 +            if (slot.getSpacingElement() != null) {
 +                dontListen(slot.getSpacingElement(), spacingResizeListener);
 +            }
 +
 +            dontListen(slot.getWidget().getElement(),
 +                    childComponentResizeListener);
 +        }
 +
 +        super.onUnregister();
 +    }
 +
 +    // private void setLayoutHeightListener(boolean add) {
 +    // if (add) {
 +    // listen(getWidget().getElement(), layoutResizeListener);
 +    // } else {
 +    // dontListen(getWidget().getElement(), layoutResizeListener);
 +    // if (!needsExpand()) {
 +    // System.out.println("Clearing element sizes");
 +    // childElementHeight.clear();
 +    // childCaptionElementHeight.clear();
 +    // }
 +    // }
 +    // }
 +
 +    /*
 +     * Convenience methods
 +     */
 +
 +    private void listen(Element el, ElementResizeListener listener) {
 +        getLayoutManager().addElementResizeListener(el, listener);
 +    }
 +
 +    private void dontListen(Element el, ElementResizeListener listener) {
 +        getLayoutManager().removeElementResizeListener(el, listener);
 +    }
 +
 +}
index 06330a860483fee9b715fa016dc894fa7e6a76f3,55a26a8e0f5481656abd8995d81d1f30cb45fc98..86ae042f79a54581b3140bc5c8e8714f9ddada22
@@@ -49,355 -48,6 +48,6 @@@ public class ComponentState extends Sha
      // HTML formatted error message for the component
      // TODO this could be an object with more information, but currently the UI
      // only uses the message
-     private String errorMessage = null;
-     /**
-      * Returns the component height as set by the server.
-      * 
-      * Can be relative (containing the percent sign) or absolute, or empty
-      * string for undefined height.
-      * 
-      * @return component height as defined by the server, not null
-      */
-     public String getHeight() {
-         if (height == null) {
-             return "";
-         }
-         return height;
-     }
-     /**
-      * Sets the height of the component in the server format.
-      * 
-      * Can be relative (containing the percent sign) or absolute, or null or
-      * empty string for undefined height.
-      * 
-      * @param height
-      *            component height
-      */
-     public void setHeight(String height) {
-         this.height = height;
-     }
-     /**
-      * Returns true if the component height is undefined, false if defined
-      * (absolute or relative).
-      * 
-      * @return true if component height is undefined
-      */
-     public boolean isUndefinedHeight() {
-         return "".equals(getHeight());
-     }
-     /**
-      * Returns true if the component height is relative to the parent, i.e.
-      * percentage, false if it is fixed/auto.
-      * 
-      * @return true if component height is relative (percentage)
-      */
-     public boolean isRelativeHeight() {
-         return getHeight().endsWith("%");
-     }
-     /**
-      * Returns the component width as set by the server.
-      * 
-      * Can be relative (containing the percent sign) or absolute, or empty
-      * string for undefined height.
-      * 
-      * @return component width as defined by the server, not null
-      */
-     public String getWidth() {
-         if (width == null) {
-             return "";
-         }
-         return width;
-     }
-     /**
-      * Sets the width of the component in the server format.
-      * 
-      * Can be relative (containing the percent sign) or absolute, or null or
-      * empty string for undefined width.
-      * 
-      * @param width
-      *            component width
-      */
-     public void setWidth(String width) {
-         this.width = width;
-     }
-     /**
-      * Returns true if the component width is undefined, false if defined
-      * (absolute or relative).
-      * 
-      * @return true if component width is undefined
-      */
-     public boolean isUndefinedWidth() {
-         return "".equals(getWidth());
-     }
-     /**
-      * Returns true if the component width is relative to the parent, i.e.
-      * percentage, false if it is fixed/auto.
-      * 
-      * @return true if component width is relative (percentage)
-      */
-     public boolean isRelativeWidth() {
-         return getWidth().endsWith("%");
-     }
-     /**
-      * Returns true if the component is in read-only mode.
-      * 
-      * @see com.vaadin.ui.Component#isReadOnly()
-      * 
-      * @return true if the component is in read-only mode
-      */
-     public boolean isReadOnly() {
-         return readOnly;
-     }
-     /**
-      * Sets or resets the read-only mode for a component.
-      * 
-      * @see com.vaadin.ui.Component#setReadOnly()
-      * 
-      * @param readOnly
-      *            new mode for the component
-      */
-     public void setReadOnly(boolean readOnly) {
-         this.readOnly = readOnly;
-     }
-     /**
-      * Returns true if the component is in immediate mode.
-      * 
-      * @see com.vaadin.server.VariableOwner#isImmediate()
-      * 
-      * @return true if the component is in immediate mode
-      */
-     public boolean isImmediate() {
-         return immediate;
-     }
-     /**
-      * Sets or resets the immediate mode for a component.
-      * 
-      * @see com.vaadin.server.VariableOwner#setImmediate()
-      * 
-      * @param immediate
-      *            new mode for the component
-      */
-     public void setImmediate(boolean immediate) {
-         this.immediate = immediate;
-     }
-     /**
-      * Returns true if the component has user-defined styles.
-      * 
-      * @return true if the component has user-defined styles
-      */
-     public boolean hasStyles() {
-         return styles != null && !styles.isEmpty();
-     }
-     /**
-      * Gets the description of the component (typically shown as tooltip).
-      * 
-      * @see com.vaadin.ui.AbstractComponent#getDescription()
-      * 
-      * @return component description (not null, can be empty string)
-      */
-     public String getDescription() {
-         return description;
-     }
-     /**
-      * Sets the description of the component (typically shown as tooltip).
-      * 
-      * @see com.vaadin.ui.AbstractComponent#setDescription(String)
-      * 
-      * @param description
-      *            new component description (can be null)
-      */
-     public void setDescription(String description) {
-         this.description = description;
-     }
-     /**
-      * Returns true if the component has a description.
-      * 
-      * @return true if the component has a description
-      */
-     public boolean hasDescription() {
-         return getDescription() != null && !"".equals(getDescription());
-     }
-     /**
-      * Gets the caption of the component (typically shown by the containing
-      * layout).
-      * 
-      * @see com.vaadin.ui.Component#getCaption()
-      * 
-      * @return component caption - can be null (no caption) or empty string
-      *         (reserve space for an empty caption)
-      */
-     public String getCaption() {
-         return caption;
-     }
-     /**
-      * Sets the caption of the component (typically shown by the containing
-      * layout).
-      * 
-      * @see com.vaadin.ui.Component#setCaption(String)
-      * 
-      * @param caption
-      *            new component caption - can be null (no caption) or empty
-      *            string (reserve space for an empty caption)
-      */
-     public void setCaption(String caption) {
-         this.caption = caption;
-     }
-     /**
-      * Returns the visibility state of the component. Note that this state is
-      * related to the component only, not its parent. This might differ from
-      * what {@link com.vaadin.ui.Component#isVisible()} returns as this takes
-      * the hierarchy into account.
-      * 
-      * @return The visibility state.
-      */
-     public boolean isVisible() {
-         return visible;
-     }
-     /**
-      * Sets the visibility state of the component.
-      * 
-      * @param visible
-      *            The new visibility state.
-      */
-     public void setVisible(boolean visible) {
-         this.visible = visible;
-     }
-     /**
-      * Gets the style names for the component.
-      * 
-      * @return A List of style names or null if no styles have been set.
-      */
-     public List<String> getStyles() {
-         return styles;
-     }
-     /**
-      * Sets the style names for the component.
-      * 
-      * @param styles
-      *            A list containing style names
-      */
-     public void setStyles(List<String> styles) {
-         this.styles = styles;
-     }
-     /**
-      * Gets the id for the component. The id is added as DOM id for the
-      * component.
-      * 
-      * @return The id for the component or null if not set
-      */
-     public String getId() {
-         return id;
-     }
-     /**
-      * Sets the id for the component. The id is added as DOM id for the
-      * component.
-      * 
-      * @param id
-      *            The new id for the component or null for no id
-      * 
-      */
-     public void setId(String id) {
-         this.id = id;
-     }
-     /**
-      * Gets the identifiers for the event listeners that have been registered
-      * for the component (using an event id)
-      * 
-      * @return A set of event identifiers or null if no identifiers have been
-      *         registered
-      */
-     public Set<String> getRegisteredEventListeners() {
-         return registeredEventListeners;
-     }
-     /**
-      * Sets the identifiers for the event listeners that have been registered
-      * for the component (using an event id)
-      * 
-      * @param registeredEventListeners
-      *            The new set of identifiers or null if no identifiers have been
-      *            registered
-      */
-     public void setRegisteredEventListeners(Set<String> registeredEventListeners) {
-         this.registeredEventListeners = registeredEventListeners;
-     }
-     /**
-      * Adds an event listener id.
-      * 
-      * @param eventListenerId
-      *            The event identifier to add
-      */
-     public void addRegisteredEventListener(String eventListenerId) {
-         if (registeredEventListeners == null) {
-             registeredEventListeners = new HashSet<String>();
-         }
-         registeredEventListeners.add(eventListenerId);
-     }
-     /**
-      * Removes an event listener id.
-      * 
-      * @param eventListenerId
-      *            The event identifier to remove
-      */
-     public void removeRegisteredEventListener(String eventIdentifier) {
-         if (registeredEventListeners == null) {
-             return;
-         }
-         registeredEventListeners.remove(eventIdentifier);
-         if (registeredEventListeners.size() == 0) {
-             registeredEventListeners = null;
-         }
-     }
-     /**
-      * Returns the current error message for the component.
-      * 
-      * @return HTML formatted error message to show for the component or null if
-      *         none
-      */
-     public String getErrorMessage() {
-         return errorMessage;
-     }
-     /**
-      * Sets the current error message for the component.
-      * 
-      * TODO this could use an object with more details about the error
-      * 
-      * @param errorMessage
-      *            HTML formatted error message to show for the component or null
-      *            for none
-      */
-     public void setErrorMessage(String errorMessage) {
-         this.errorMessage = errorMessage;
-     }
+     public String errorMessage = null;
 +}
 -}