]> source.dussan.org Git - vaadin-framework.git/commitdiff
Implement abstract HasComponents related client side connectors (#10248) 80/280/4
authorHenri Sara <hesara@vaadin.com>
Wed, 21 Nov 2012 11:28:49 +0000 (13:28 +0200)
committerVaadin Code Review <review@vaadin.com>
Wed, 21 Nov 2012 11:35:44 +0000 (11:35 +0000)
Change-Id: I8e0d1505d24ed8d24702557a38ffd867a513bdd2

18 files changed:
client/src/com/vaadin/client/ApplicationConnection.java
client/src/com/vaadin/client/ComponentContainerConnector.java [deleted file]
client/src/com/vaadin/client/ConnectorHierarchyChangeEvent.java
client/src/com/vaadin/client/HasComponentsConnector.java [new file with mode: 0644]
client/src/com/vaadin/client/ui/AbstractComponentConnector.java
client/src/com/vaadin/client/ui/AbstractComponentContainerConnector.java
client/src/com/vaadin/client/ui/AbstractHasComponentsConnector.java [new file with mode: 0644]
client/src/com/vaadin/client/ui/AbstractSingleComponentContainerConnector.java [new file with mode: 0644]
client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java
client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java
client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java
client/src/com/vaadin/client/ui/layout/MayScrollChildren.java
client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
client/src/com/vaadin/client/ui/panel/PanelConnector.java
client/src/com/vaadin/client/ui/popupview/PopupViewConnector.java
client/src/com/vaadin/client/ui/table/TableConnector.java
client/src/com/vaadin/client/ui/ui/UIConnector.java
client/src/com/vaadin/client/ui/window/WindowConnector.java

index 4357e431b35b56cc3aeba21e9b38a1e7b4d5f86e..4e243495709fd8feb3269fb73a671ccb1ee2d07c 100644 (file)
@@ -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<ComponentConnector> 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<ComponentConnector> 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 (file)
index 926ad23..0000000
+++ /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.
-     * 
-     * <p>
-     * 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.
-     * </p>
-     * 
-     * @param connector
-     *            Child component for which service is requested.
-     */
-    void updateCaption(ComponentConnector connector);
-
-    /**
-     * Returns the children for this connector.
-     * <p>
-     * The children for this connector are defined as all
-     * {@link ComponentConnector}s whose parent is this
-     * {@link ComponentContainerConnector}.
-     * </p>
-     * 
-     * @return A collection of children for this connector. An empty collection
-     *         if there are no children. Never returns null.
-     */
-    public List<ComponentConnector> 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.
-     * <p>
-     * 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<ComponentConnector> 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);
-
-}
index f5dff60e4c92dbb7d5650efe9879d81047a69223..9c97b2dd8bf27d1125f5ad6e644890b746478338 100644 (file)
@@ -41,7 +41,7 @@ public class ConnectorHierarchyChangeEvent extends
     public static final Type<ConnectorHierarchyChangeHandler> TYPE = new Type<ConnectorHierarchyChangeHandler>();
 
     List<ComponentConnector> 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 (file)
index 0000000..375e479
--- /dev/null
@@ -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.
+     * 
+     * <p>
+     * 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.
+     * </p>
+     * 
+     * @param connector
+     *            Child component for which service is requested.
+     */
+    void updateCaption(ComponentConnector connector);
+
+    /**
+     * Returns the children for this connector.
+     * <p>
+     * The children for this connector are defined as all {@link HasComponents}s
+     * whose parent is this {@link HasComponentsConnector}.
+     * </p>
+     * 
+     * @return A collection of children for this connector. An empty collection
+     *         if there are no children. Never returns null.
+     */
+    public List<ComponentConnector> 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.
+     * <p>
+     * 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<ComponentConnector> 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);
+
+}
index 49e879a6817359c3eefb9402bff2eccba4bd8a86..9868bc329d25285dfb247518e5fd65b6b48c5644 100644 (file)
@@ -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)
index 20afb3de4b72f1c94b1440ab9c8f089f8eafcf6e..e070f2aabb6394018320871c7091c25783f71608 100644 (file)
@@ -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
  */
 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<ComponentConnector> childComponents;
-
-    private final boolean debugLogging = false;
-
-    /**
-     * Default constructor
-     */
-    public AbstractComponentContainerConnector() {
-        addConnectorHierarchyChangeHandler(this);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.vaadin.client.ComponentContainerConnector#getChildren()
-     */
-    @Override
-    public List<ComponentConnector> 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<ComponentConnector> 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 (file)
index 0000000..02d1293
--- /dev/null
@@ -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<ComponentConnector> childComponents;
+
+    /**
+     * Default constructor
+     */
+    public AbstractHasComponentsConnector() {
+        addConnectorHierarchyChangeHandler(this);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.vaadin.client.HasComponentsConnector#getChildren()
+     */
+    @Override
+    public List<ComponentConnector> 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<ComponentConnector> 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 (file)
index 0000000..d8f2ed9
--- /dev/null
@@ -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<ComponentConnector> 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;
+        }
+    }
+
+}
index d13b0793887179d773156039a15423b60bd8c3fd..c51422dc277afed8ec9280ccb195601b8ef9fadf 100644 (file)
@@ -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()));
     };
 
     /*
index 98969d881afbc87da048298072ee5e6e42719cb9..71ffeb738c461a9d8ca3c6fbd85b52432562c8f4 100644 (file)
@@ -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
index 67555e83318c2a08c69c84ecac5411f9a304baca..1bb7bfd5282c8b4ab9424be959e72bfe7bddb9c0 100644 (file)
@@ -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);
index cc2341e26b81f41aeb45b4d85995331409e7a2dc..5619fb27fb1913e6c4e2f10c4d51a74e16bb7fd4 100644 (file)
@@ -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 {
 
 }
index c21155e26d35dad1b463f48bc2bfe95c9cccd2b3..65736397cb6d951c8c781c69c8bd082aa9032b0e 100644 (file)
@@ -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
index 9642aaa268b56ffe74f6781622931bffa3a197e6..ae1c7e34559b754d751a48ece7614726c72a2a68 100644 (file)
@@ -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());
     }
 
 }
index c1048766fe9a8930ca6f1e04d9495daaf4cf6cfd..7fdd986d93c986f4bb84416ce1e8b22c99771455 100644 (file)
@@ -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
index 35e7020ce0e0fb1b7b8b040728277218510f96e1..ef1b117bcb320413854fceb314650bc3129be0f0 100644 (file)
@@ -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
index a51cccf35502c27881b32a570dc98234927e77e5..588fb5c5cf7e2ea9931745c4d807eafd04639cd6 100644 (file)
@@ -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<ComponentConnector> children = getChildComponents();
-        if (children.isEmpty()) {
-            return null;
-        } else {
-            return children.get(0);
-        }
-    }
-
     protected void onChildSizeChange() {
         ComponentConnector child = getContent();
         if (child == null) {
index 8b4c5d9f375556b7132f1aeac29bd3405c125dbd..4f1825e749b2fb5bd1beee99da75f5ac45d88123 100644 (file)
@@ -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