]> source.dussan.org Git - vaadin-framework.git/commitdiff
#5890 Added getComponentCount to ComponentContainer
authorArtur Signell <artur@vaadin.com>
Sun, 4 Mar 2012 10:28:11 +0000 (12:28 +0200)
committerArtur Signell <artur@vaadin.com>
Sun, 4 Mar 2012 10:31:22 +0000 (12:31 +0200)
src/com/vaadin/ui/ComponentContainer.java
src/com/vaadin/ui/Panel.java
src/com/vaadin/ui/Root.java

index 1e1f0796cadead6517175bca2ba0d5d47138f705..f2bfc723a5a06388a764d29629f850d0304586d7 100644 (file)
@@ -69,6 +69,14 @@ public interface ComponentContainer extends Component {
      */
     public Iterator<Component> getComponentIterator();
 
+    /**
+     * Gets the number of children this {@link ComponentContainer} has. This
+     * must be symmetric with what {@link #getComponentIterator()} returns.
+     * 
+     * @return The number of child components this container has.
+     */
+    public int getComponentCount();
+
     /**
      * Causes a repaint of this component, and all components below it.
      * 
index 63b57866c70025fd1a165e15dd7fe1194b88e10a..c3bca2a5bb51626b90a4679d68a564b1285a4767 100644 (file)
@@ -661,4 +661,13 @@ public class Panel extends AbstractComponentContainer implements Scrollable,
         super.focus();
     }
 
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.vaadin.ui.ComponentContainer#getComponentCount()
+     */
+    public int getComponentCount() {
+        // This is so wrong... (#2924)
+        return content.getComponentCount();
+    }
 }
index 3d9f734a2cd19c515ef684fb0f840d18141fc298..47f962bf3d77cde5d6a775d0e03419087931afa2 100644 (file)
@@ -632,10 +632,24 @@ public abstract class Root extends AbstractComponentContainer implements
         }
     }
 
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.vaadin.ui.ComponentContainer#getComponentIterator()
+     */
     public Iterator<Component> getComponentIterator() {
         return Collections.singleton((Component) getContent()).iterator();
     }
 
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.vaadin.ui.ComponentContainer#getComponentCount()
+     */
+    public int getComponentCount() {
+        return getContent() == null ? 0 : 1;
+    }
+
     /**
      * Sets the application to which this root is assigned. It is not legal to
      * change the application once it has been set nor to set a