summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-03-04 12:28:11 +0200
committerArtur Signell <artur@vaadin.com>2012-03-04 12:31:22 +0200
commit016f5997ab5e30277f0cb17678ba0d81ba81fa97 (patch)
treec50ce2f926c62b10d4bf71450f1dd73ee533941e /src/com/vaadin
parent90e48f640cc23ae574aa59d122497b0f676e01fe (diff)
downloadvaadin-framework-016f5997ab5e30277f0cb17678ba0d81ba81fa97.tar.gz
vaadin-framework-016f5997ab5e30277f0cb17678ba0d81ba81fa97.zip
#5890 Added getComponentCount to ComponentContainer
Diffstat (limited to 'src/com/vaadin')
-rw-r--r--src/com/vaadin/ui/ComponentContainer.java8
-rw-r--r--src/com/vaadin/ui/Panel.java9
-rw-r--r--src/com/vaadin/ui/Root.java14
3 files changed, 31 insertions, 0 deletions
diff --git a/src/com/vaadin/ui/ComponentContainer.java b/src/com/vaadin/ui/ComponentContainer.java
index 1e1f0796ca..f2bfc723a5 100644
--- a/src/com/vaadin/ui/ComponentContainer.java
+++ b/src/com/vaadin/ui/ComponentContainer.java
@@ -70,6 +70,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.
*
* This should only be used in special cases, e.g when the state of a
diff --git a/src/com/vaadin/ui/Panel.java b/src/com/vaadin/ui/Panel.java
index 63b57866c7..c3bca2a5bb 100644
--- a/src/com/vaadin/ui/Panel.java
+++ b/src/com/vaadin/ui/Panel.java
@@ -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();
+ }
}
diff --git a/src/com/vaadin/ui/Root.java b/src/com/vaadin/ui/Root.java
index 3d9f734a2c..47f962bf3d 100644
--- a/src/com/vaadin/ui/Root.java
+++ b/src/com/vaadin/ui/Root.java
@@ -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