From: Henri Sara Date: Wed, 21 Nov 2012 11:28:49 +0000 (+0200) Subject: Implement abstract HasComponents related client side connectors (#10248) X-Git-Tag: 7.0.0.beta10~73 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fchanges%2F80%2F280%2F4;p=vaadin-framework.git Implement abstract HasComponents related client side connectors (#10248) Change-Id: I8e0d1505d24ed8d24702557a38ffd867a513bdd2 --- diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 4357e431b3..4e24349570 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -1719,7 +1719,7 @@ public class ApplicationConnection { VConsole.log(oldChildren); String newChildren = "* New children: "; - ComponentContainerConnector parent = (ComponentContainerConnector) event + HasComponentsConnector parent = (HasComponentsConnector) event .getConnector(); for (ComponentConnector child : parent.getChildComponents()) { newChildren += Util.getConnectorString(child) + " "; @@ -1939,8 +1939,8 @@ public class ApplicationConnection { continue; } - if (parentConnector instanceof ComponentContainerConnector) { - ComponentContainerConnector ccc = (ComponentContainerConnector) parentConnector; + if (parentConnector instanceof HasComponentsConnector) { + HasComponentsConnector ccc = (HasComponentsConnector) parentConnector; List oldComponents = ccc .getChildComponents(); if (!Util.collectionsEquals(oldComponents, @@ -1957,7 +1957,7 @@ public class ApplicationConnection { } else if (!newComponents.isEmpty()) { VConsole.error("Hierachy claims " + Util.getConnectorString(parentConnector) - + " has component children even though it isn't a ComponentContainerConnector"); + + " has component children even though it isn't a HasComponentsConnector"); } parentConnector.setChildren(newChildren); @@ -2029,13 +2029,13 @@ public class ApplicationConnection { * Create an artificial hierarchy event for containers to give * it a chance to clean up after its children if it has any */ - if (connector instanceof ComponentContainerConnector) { - ComponentContainerConnector ccc = (ComponentContainerConnector) connector; + if (connector instanceof HasComponentsConnector) { + HasComponentsConnector ccc = (HasComponentsConnector) connector; List oldChildren = ccc .getChildComponents(); if (!oldChildren.isEmpty()) { /* - * ComponentContainerConnector has a separate child + * HasComponentsConnector has a separate child * component list that should also be cleared */ ccc.setChildComponents(Collections diff --git a/client/src/com/vaadin/client/ComponentContainerConnector.java b/client/src/com/vaadin/client/ComponentContainerConnector.java deleted file mode 100644 index 926ad2319d..0000000000 --- a/client/src/com/vaadin/client/ComponentContainerConnector.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.vaadin.client; - -import java.util.List; - -import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.user.client.ui.HasWidgets; -import com.vaadin.client.ConnectorHierarchyChangeEvent.ConnectorHierarchyChangeHandler; - -/** - * An interface used by client-side connectors whose widget is a component - * container (implements {@link HasWidgets}). - */ -public interface ComponentContainerConnector extends ServerConnector { - - /** - * Update child components caption, description and error message. - * - *

- * Each component is responsible for maintaining its caption, description - * and error message. In most cases components doesn't want to do that and - * those elements reside outside of the component. Because of this layouts - * must provide service for it's childen to show those elements for them. - *

- * - * @param connector - * Child component for which service is requested. - */ - void updateCaption(ComponentConnector connector); - - /** - * Returns the children for this connector. - *

- * The children for this connector are defined as all - * {@link ComponentConnector}s whose parent is this - * {@link ComponentContainerConnector}. - *

- * - * @return A collection of children for this connector. An empty collection - * if there are no children. Never returns null. - */ - public List getChildComponents(); - - /** - * Sets the children for this connector. This method should only be called - * by the framework to ensure that the connector hierarchy on the client - * side and the server side are in sync. - *

- * Note that calling this method does not call - * {@link ConnectorHierarchyChangeHandler#onConnectorHierarchyChange(ConnectorHierarchyChangeEvent)} - * . The event method is called only when the hierarchy has been updated for - * all connectors. - * - * @param children - * The new child connectors - */ - public void setChildComponents(List children); - - /** - * Adds a handler that is called whenever the child hierarchy of this - * connector has been updated by the server. - * - * @param handler - * The handler that should be added. - * @return A handler registration reference that can be used to unregister - * the handler - */ - public HandlerRegistration addConnectorHierarchyChangeHandler( - ConnectorHierarchyChangeHandler handler); - -} diff --git a/client/src/com/vaadin/client/ConnectorHierarchyChangeEvent.java b/client/src/com/vaadin/client/ConnectorHierarchyChangeEvent.java index f5dff60e4c..9c97b2dd8b 100644 --- a/client/src/com/vaadin/client/ConnectorHierarchyChangeEvent.java +++ b/client/src/com/vaadin/client/ConnectorHierarchyChangeEvent.java @@ -41,7 +41,7 @@ public class ConnectorHierarchyChangeEvent extends public static final Type TYPE = new Type(); List oldChildren; - private ComponentContainerConnector parent; + private HasComponentsConnector parent; public ConnectorHierarchyChangeEvent() { } @@ -67,25 +67,25 @@ public class ConnectorHierarchyChangeEvent extends } /** - * Returns the {@link ComponentContainerConnector} for which this event + * Returns the {@link HasComponentsConnector} for which this event * occurred. * - * @return The {@link ComponentContainerConnector} whose child collection + * @return The {@link HasComponentsConnector} whose child collection * has changed. Never returns null. */ - public ComponentContainerConnector getParent() { + public HasComponentsConnector getParent() { return parent; } /** - * Sets the {@link ComponentContainerConnector} for which this event + * Sets the {@link HasComponentsConnector} for which this event * occurred. * * @param The - * {@link ComponentContainerConnector} whose child collection has + * {@link HasComponentsConnector} whose child collection has * changed. */ - public void setParent(ComponentContainerConnector parent) { + public void setParent(HasComponentsConnector parent) { this.parent = parent; } diff --git a/client/src/com/vaadin/client/HasComponentsConnector.java b/client/src/com/vaadin/client/HasComponentsConnector.java new file mode 100644 index 0000000000..375e4792a3 --- /dev/null +++ b/client/src/com/vaadin/client/HasComponentsConnector.java @@ -0,0 +1,85 @@ +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.client; + +import java.util.List; + +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.HasWidgets; +import com.vaadin.client.ConnectorHierarchyChangeEvent.ConnectorHierarchyChangeHandler; + +/** + * An interface used by client-side connectors whose widget is a component + * container (implements {@link HasWidgets}). + */ +public interface HasComponentsConnector extends ServerConnector { + + /** + * Update child components caption, description and error message. + * + *

+ * Each component is responsible for maintaining its caption, description + * and error message. In most cases components doesn't want to do that and + * those elements reside outside of the component. Because of this layouts + * must provide service for it's childen to show those elements for them. + *

+ * + * @param connector + * Child component for which service is requested. + */ + void updateCaption(ComponentConnector connector); + + /** + * Returns the children for this connector. + *

+ * The children for this connector are defined as all {@link HasComponents}s + * whose parent is this {@link HasComponentsConnector}. + *

+ * + * @return A collection of children for this connector. An empty collection + * if there are no children. Never returns null. + */ + public List getChildComponents(); + + /** + * Sets the children for this connector. This method should only be called + * by the framework to ensure that the connector hierarchy on the client + * side and the server side are in sync. + *

+ * Note that calling this method does not call + * {@link ConnectorHierarchyChangeHandler#onConnectorHierarchyChange(ConnectorHierarchyChangeEvent)} + * . The event method is called only when the hierarchy has been updated for + * all connectors. + * + * @param children + * The new child connectors + */ + public void setChildComponents(List children); + + /** + * Adds a handler that is called whenever the child hierarchy of this + * connector has been updated by the server. + * + * @param handler + * The handler that should be added. + * @return A handler registration reference that can be used to unregister + * the handler + */ + public HandlerRegistration addConnectorHierarchyChangeHandler( + ConnectorHierarchyChangeHandler handler); + +} diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index 49e879a681..9868bc329d 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -25,7 +25,7 @@ import com.google.gwt.user.client.ui.HasEnabled; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ComponentConnector; -import com.vaadin.client.ComponentContainerConnector; +import com.vaadin.client.HasComponentsConnector; import com.vaadin.client.ConnectorMap; import com.vaadin.client.LayoutManager; import com.vaadin.client.ServerConnector; @@ -150,8 +150,8 @@ public abstract class AbstractComponentConnector extends AbstractConnector // Set captions if (delegateCaptionHandling()) { ServerConnector parent = getParent(); - if (parent instanceof ComponentContainerConnector) { - ((ComponentContainerConnector) parent).updateCaption(this); + if (parent instanceof HasComponentsConnector) { + ((HasComponentsConnector) parent).updateCaption(this); } else if (parent == null && !(this instanceof UIConnector)) { VConsole.error("Parent of connector " + Util.getConnectorString(this) @@ -180,8 +180,8 @@ public abstract class AbstractComponentConnector extends AbstractConnector // make sure the caption has or has not v-disabled style if (delegateCaptionHandling()) { ServerConnector parent = getParent(); - if (parent instanceof ComponentContainerConnector) { - ((ComponentContainerConnector) parent).updateCaption(this); + if (parent instanceof HasComponentsConnector) { + ((HasComponentsConnector) parent).updateCaption(this); } else if (parent == null && !(this instanceof UIConnector)) { VConsole.error("Parent of connector " + Util.getConnectorString(this) diff --git a/client/src/com/vaadin/client/ui/AbstractComponentContainerConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentContainerConnector.java index 20afb3de4b..e070f2aabb 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentContainerConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentContainerConnector.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 Vaadin Ltd. + * Copyright 2012 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of @@ -15,59 +15,12 @@ */ package com.vaadin.client.ui; -import java.util.Collections; -import java.util.List; - -import com.google.gwt.event.shared.HandlerRegistration; -import com.vaadin.client.ComponentConnector; -import com.vaadin.client.ComponentContainerConnector; -import com.vaadin.client.ConnectorHierarchyChangeEvent; -import com.vaadin.client.ConnectorHierarchyChangeEvent.ConnectorHierarchyChangeHandler; - +/** + * Client side connector for subclasses of AbstractComponentConnector. + * + * @since 7.0 + */ public abstract class AbstractComponentContainerConnector extends - AbstractComponentConnector implements ComponentContainerConnector, - ConnectorHierarchyChangeHandler { - - List childComponents; - - private final boolean debugLogging = false; - - /** - * Default constructor - */ - public AbstractComponentContainerConnector() { - addConnectorHierarchyChangeHandler(this); - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.client.ComponentContainerConnector#getChildren() - */ - @Override - public List getChildComponents() { - if (childComponents == null) { - return Collections.emptyList(); - } - - return childComponents; - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.client.ComponentContainerConnector#setChildren - * (java.util.Collection) - */ - @Override - public void setChildComponents(List childComponents) { - this.childComponents = childComponents; - } + AbstractHasComponentsConnector { - @Override - public HandlerRegistration addConnectorHierarchyChangeHandler( - ConnectorHierarchyChangeHandler handler) { - return ensureHandlerManager().addHandler( - ConnectorHierarchyChangeEvent.TYPE, handler); - } } diff --git a/client/src/com/vaadin/client/ui/AbstractHasComponentsConnector.java b/client/src/com/vaadin/client/ui/AbstractHasComponentsConnector.java new file mode 100644 index 0000000000..02d12936d6 --- /dev/null +++ b/client/src/com/vaadin/client/ui/AbstractHasComponentsConnector.java @@ -0,0 +1,71 @@ +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui; + +import java.util.Collections; +import java.util.List; + +import com.google.gwt.event.shared.HandlerRegistration; +import com.vaadin.client.ComponentConnector; +import com.vaadin.client.HasComponentsConnector; +import com.vaadin.client.ConnectorHierarchyChangeEvent; +import com.vaadin.client.ConnectorHierarchyChangeEvent.ConnectorHierarchyChangeHandler; + +public abstract class AbstractHasComponentsConnector extends + AbstractComponentConnector implements HasComponentsConnector, + ConnectorHierarchyChangeHandler { + + List childComponents; + + /** + * Default constructor + */ + public AbstractHasComponentsConnector() { + addConnectorHierarchyChangeHandler(this); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.client.HasComponentsConnector#getChildren() + */ + @Override + public List getChildComponents() { + if (childComponents == null) { + return Collections.emptyList(); + } + + return childComponents; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.client.HasComponentsConnector#setChildren + * (java.util.Collection) + */ + @Override + public void setChildComponents(List childComponents) { + this.childComponents = childComponents; + } + + @Override + public HandlerRegistration addConnectorHierarchyChangeHandler( + ConnectorHierarchyChangeHandler handler) { + return ensureHandlerManager().addHandler( + ConnectorHierarchyChangeEvent.TYPE, handler); + } +} diff --git a/client/src/com/vaadin/client/ui/AbstractSingleComponentContainerConnector.java b/client/src/com/vaadin/client/ui/AbstractSingleComponentContainerConnector.java new file mode 100644 index 0000000000..d8f2ed95ab --- /dev/null +++ b/client/src/com/vaadin/client/ui/AbstractSingleComponentContainerConnector.java @@ -0,0 +1,61 @@ +/* + * Copyright 2012 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui; + +import java.util.List; + +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ComponentConnector; + +/** + * Client side connector for subclasses of AbstractSingleComponentConnector. + * + * @since 7.0 + */ +public abstract class AbstractSingleComponentContainerConnector extends + AbstractHasComponentsConnector { + + /** + * Returns the content (only/first child) of the container. + * + * @return child connector or null if none (e.g. invisible or not set on + * server) + */ + protected ComponentConnector getContent() { + List children = getChildComponents(); + if (children.isEmpty()) { + return null; + } else { + return children.get(0); + } + } + + /** + * Returns the widget (if any) of the content of the container. + * + * @return widget of the only/first connector of the container, null if no + * content or if there is no widget for the connector + */ + protected Widget getContentWidget() { + ComponentConnector content = getContent(); + if (null != content) { + return content.getWidget(); + } else { + return null; + } + } + +} diff --git a/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java b/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java index d13b079388..c51422dc27 100644 --- a/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java @@ -101,7 +101,7 @@ public class AbsoluteLayoutConnector extends * (non-Javadoc) * * @see - * com.vaadin.client.ComponentContainerConnector#updateCaption(com.vaadin + * com.vaadin.client.HasComponentsConnector#updateCaption(com.vaadin * .client.ComponentConnector) */ @Override @@ -162,10 +162,8 @@ public class AbsoluteLayoutConnector extends } private void setChildWidgetPosition(ComponentConnector child) { - getWidget().setWidgetPosition( - child.getWidget(), - getState().connectorToCssPosition.get(child - .getConnectorId())); + getWidget().setWidgetPosition(child.getWidget(), + getState().connectorToCssPosition.get(child.getConnectorId())); }; /* diff --git a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java index 98969d881a..71ffeb738c 100644 --- a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java @@ -183,7 +183,7 @@ public class CssLayoutConnector extends AbstractLayoutConnector { * (non-Javadoc) * * @see - * com.vaadin.client.ComponentContainerConnector#updateCaption(com.vaadin + * com.vaadin.client.HasComponentsConnector#updateCaption(com.vaadin * .client.ComponentConnector) */ @Override diff --git a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java index 67555e8331..1bb7bfd528 100644 --- a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java +++ b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.Set; import com.vaadin.client.ComponentConnector; -import com.vaadin.client.ComponentContainerConnector; +import com.vaadin.client.HasComponentsConnector; import com.vaadin.client.ServerConnector; import com.vaadin.client.Util; import com.vaadin.client.VConsole; @@ -204,8 +204,8 @@ public class LayoutDependencyTree { resized.add(connector); } - if (connector instanceof ComponentContainerConnector) { - ComponentContainerConnector container = (ComponentContainerConnector) connector; + if (connector instanceof HasComponentsConnector) { + HasComponentsConnector container = (HasComponentsConnector) connector; for (ComponentConnector child : container.getChildComponents()) { if (isRelativeInDirection(child, direction)) { resized.add(child); diff --git a/client/src/com/vaadin/client/ui/layout/MayScrollChildren.java b/client/src/com/vaadin/client/ui/layout/MayScrollChildren.java index cc2341e26b..5619fb27fb 100644 --- a/client/src/com/vaadin/client/ui/layout/MayScrollChildren.java +++ b/client/src/com/vaadin/client/ui/layout/MayScrollChildren.java @@ -15,8 +15,8 @@ */ package com.vaadin.client.ui.layout; -import com.vaadin.client.ComponentContainerConnector; +import com.vaadin.client.HasComponentsConnector; -public interface MayScrollChildren extends ComponentContainerConnector { +public interface MayScrollChildren extends HasComponentsConnector { } diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index c21155e26d..65736397cb 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -235,7 +235,7 @@ public abstract class AbstractOrderedLayoutConnector extends * (non-Javadoc) * * @see - * com.vaadin.client.ComponentContainerConnector#updateCaption(com.vaadin + * com.vaadin.client.HasComponentsConnector#updateCaption(com.vaadin * .client.ComponentConnector) */ @Override diff --git a/client/src/com/vaadin/client/ui/panel/PanelConnector.java b/client/src/com/vaadin/client/ui/panel/PanelConnector.java index 9642aaa268..ae1c7e3455 100644 --- a/client/src/com/vaadin/client/ui/panel/PanelConnector.java +++ b/client/src/com/vaadin/client/ui/panel/PanelConnector.java @@ -18,14 +18,13 @@ package com.vaadin.client.ui.panel; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.LayoutManager; import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; -import com.vaadin.client.ui.AbstractComponentContainerConnector; +import com.vaadin.client.ui.AbstractSingleComponentContainerConnector; import com.vaadin.client.ui.ClickEventHandler; import com.vaadin.client.ui.PostLayoutListener; import com.vaadin.client.ui.ShortcutActionHandler; @@ -40,7 +39,7 @@ import com.vaadin.shared.ui.panel.PanelState; import com.vaadin.ui.Panel; @Connect(Panel.class) -public class PanelConnector extends AbstractComponentContainerConnector +public class PanelConnector extends AbstractSingleComponentContainerConnector implements Paintable, SimpleManagedLayout, PostLayoutListener, MayScrollChildren { @@ -241,13 +240,7 @@ public class PanelConnector extends AbstractComponentContainerConnector @Override public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { // We always have 1 child, unless the child is hidden - Widget newChildWidget = null; - if (getChildComponents().size() == 1) { - ComponentConnector newChild = getChildComponents().get(0); - newChildWidget = newChild.getWidget(); - } - - getWidget().setWidget(newChildWidget); + getWidget().setWidget(getContentWidget()); } } diff --git a/client/src/com/vaadin/client/ui/popupview/PopupViewConnector.java b/client/src/com/vaadin/client/ui/popupview/PopupViewConnector.java index c1048766fe..7fdd986d93 100644 --- a/client/src/com/vaadin/client/ui/popupview/PopupViewConnector.java +++ b/client/src/com/vaadin/client/ui/popupview/PopupViewConnector.java @@ -44,9 +44,8 @@ public class PopupViewConnector extends AbstractComponentContainerConnector @Override protected void init() { super.init(); - - handlerRegistration.add(getWidget().addVisibilityChangeHandler( - this)); + + handlerRegistration.add(getWidget().addVisibilityChangeHandler(this)); } @Override diff --git a/client/src/com/vaadin/client/ui/table/TableConnector.java b/client/src/com/vaadin/client/ui/table/TableConnector.java index 35e7020ce0..ef1b117bcb 100644 --- a/client/src/com/vaadin/client/ui/table/TableConnector.java +++ b/client/src/com/vaadin/client/ui/table/TableConnector.java @@ -33,7 +33,7 @@ import com.vaadin.client.ServerConnector; import com.vaadin.client.TooltipInfo; import com.vaadin.client.UIDL; import com.vaadin.client.Util; -import com.vaadin.client.ui.AbstractComponentContainerConnector; +import com.vaadin.client.ui.AbstractHasComponentsConnector; import com.vaadin.client.ui.PostLayoutListener; import com.vaadin.client.ui.VScrollTable; import com.vaadin.client.ui.VScrollTable.ContextMenuDetails; @@ -43,7 +43,7 @@ import com.vaadin.shared.ui.table.TableConstants; import com.vaadin.shared.ui.table.TableState; @Connect(com.vaadin.ui.Table.class) -public class TableConnector extends AbstractComponentContainerConnector +public class TableConnector extends AbstractHasComponentsConnector implements Paintable, DirectionalManagedLayout, PostLayoutListener { @Override diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index a51cccf355..588fb5c5cf 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -44,7 +44,7 @@ import com.vaadin.client.UIDL; import com.vaadin.client.VConsole; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; -import com.vaadin.client.ui.AbstractComponentContainerConnector; +import com.vaadin.client.ui.AbstractSingleComponentContainerConnector; import com.vaadin.client.ui.ClickEventHandler; import com.vaadin.client.ui.ShortcutActionHandler; import com.vaadin.client.ui.VNotification; @@ -62,8 +62,8 @@ import com.vaadin.shared.ui.ui.UIState; import com.vaadin.ui.UI; @Connect(value = UI.class, loadStyle = LoadStyle.EAGER) -public class UIConnector extends AbstractComponentContainerConnector implements - Paintable, MayScrollChildren { +public class UIConnector extends AbstractSingleComponentContainerConnector + implements Paintable, MayScrollChildren { private HandlerRegistration childStateChangeHandlerRegistration; @@ -336,15 +336,6 @@ public class UIConnector extends AbstractComponentContainerConnector implements return (VUI) super.getWidget(); } - protected ComponentConnector getContent() { - List children = getChildComponents(); - if (children.isEmpty()) { - return null; - } else { - return children.get(0); - } - } - protected void onChildSizeChange() { ComponentConnector child = getContent(); if (child == null) { diff --git a/client/src/com/vaadin/client/ui/window/WindowConnector.java b/client/src/com/vaadin/client/ui/window/WindowConnector.java index 8b4c5d9f37..4f1825e749 100644 --- a/client/src/com/vaadin/client/ui/window/WindowConnector.java +++ b/client/src/com/vaadin/client/ui/window/WindowConnector.java @@ -23,7 +23,6 @@ import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; @@ -31,13 +30,13 @@ import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.LayoutManager; import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; -import com.vaadin.client.ui.AbstractComponentContainerConnector; +import com.vaadin.client.ui.AbstractSingleComponentContainerConnector; import com.vaadin.client.ui.ClickEventHandler; import com.vaadin.client.ui.PostLayoutListener; import com.vaadin.client.ui.ShortcutActionHandler; -import com.vaadin.client.ui.VWindow; import com.vaadin.client.ui.ShortcutActionHandler.BeforeShortcutActionListener; import com.vaadin.client.ui.SimpleManagedLayout; +import com.vaadin.client.ui.VWindow; import com.vaadin.client.ui.layout.MayScrollChildren; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.Connect; @@ -45,7 +44,7 @@ import com.vaadin.shared.ui.window.WindowServerRpc; import com.vaadin.shared.ui.window.WindowState; @Connect(value = com.vaadin.ui.Window.class) -public class WindowConnector extends AbstractComponentContainerConnector +public class WindowConnector extends AbstractSingleComponentContainerConnector implements Paintable, BeforeShortcutActionListener, SimpleManagedLayout, PostLayoutListener, MayScrollChildren { @@ -213,15 +212,8 @@ public class WindowConnector extends AbstractComponentContainerConnector @Override public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { // We always have 1 child, unless the child is hidden - Widget newChildWidget = null; - ComponentConnector newChild = null; - if (getChildComponents().size() == 1) { - newChild = getChildComponents().get(0); - newChildWidget = newChild.getWidget(); - } - - getWidget().layout = newChild; - getWidget().contentPanel.setWidget(newChildWidget); + getWidget().layout = getContent(); + getWidget().contentPanel.setWidget(getContentWidget()); } @Override