diff options
author | Henri Sara <henri.sara@itmill.com> | 2010-10-26 14:58:06 +0000 |
---|---|---|
committer | Henri Sara <henri.sara@itmill.com> | 2010-10-26 14:58:06 +0000 |
commit | 089f43092d7bf6f99e5abca56415d8cf6fcc3cf2 (patch) | |
tree | bfb23494c862d7072ffbdf127ca9518e149507cd /src | |
parent | a98ecb2b8d2949eec1b32a66eb8e1f5cddb5910d (diff) | |
download | vaadin-framework-089f43092d7bf6f99e5abca56415d8cf6fcc3cf2.tar.gz vaadin-framework-089f43092d7bf6f99e5abca56415d8cf6fcc3cf2.zip |
#4611 add getComponentCount() method for ComponentContainer implementations
svn changeset:15724/svn branch:6.5
Diffstat (limited to 'src')
-rw-r--r-- | src/com/vaadin/ui/AbsoluteLayout.java | 10 | ||||
-rw-r--r-- | src/com/vaadin/ui/AbstractOrderedLayout.java | 10 | ||||
-rw-r--r-- | src/com/vaadin/ui/CssLayout.java | 10 | ||||
-rw-r--r-- | src/com/vaadin/ui/CustomComponent.java | 10 | ||||
-rw-r--r-- | src/com/vaadin/ui/CustomLayout.java | 10 | ||||
-rw-r--r-- | src/com/vaadin/ui/GridLayout.java | 10 | ||||
-rw-r--r-- | src/com/vaadin/ui/Panel.java | 4 | ||||
-rw-r--r-- | src/com/vaadin/ui/PopupView.java | 10 | ||||
-rw-r--r-- | src/com/vaadin/ui/SplitPanel.java | 20 | ||||
-rw-r--r-- | src/com/vaadin/ui/TabSheet.java | 10 |
10 files changed, 100 insertions, 4 deletions
diff --git a/src/com/vaadin/ui/AbsoluteLayout.java b/src/com/vaadin/ui/AbsoluteLayout.java index eca11b7984..538cc26c77 100644 --- a/src/com/vaadin/ui/AbsoluteLayout.java +++ b/src/com/vaadin/ui/AbsoluteLayout.java @@ -51,6 +51,16 @@ public class AbsoluteLayout extends AbstractLayout { } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components + */ + public int getComponentCount() { + return components.size(); + } + + /** * Replaces one component with another one. The new component inherits the * old components position. */ diff --git a/src/com/vaadin/ui/AbstractOrderedLayout.java b/src/com/vaadin/ui/AbstractOrderedLayout.java index fd7e3a39d4..7bd52f8feb 100644 --- a/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -127,6 +127,16 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components + */ + public int getComponentCount() { + return components.size(); + } + + /** * Paints the content of this component. * * @param target diff --git a/src/com/vaadin/ui/CssLayout.java b/src/com/vaadin/ui/CssLayout.java index 4f8e00dec4..db5bae678b 100644 --- a/src/com/vaadin/ui/CssLayout.java +++ b/src/com/vaadin/ui/CssLayout.java @@ -148,6 +148,16 @@ public class CssLayout extends AbstractLayout { } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components + */ + public int getComponentCount() { + return components.size(); + } + + /** * Paints the content of this component. * * @param target diff --git a/src/com/vaadin/ui/CustomComponent.java b/src/com/vaadin/ui/CustomComponent.java index e06fb321e3..a598b5b3bb 100644 --- a/src/com/vaadin/ui/CustomComponent.java +++ b/src/com/vaadin/ui/CustomComponent.java @@ -175,6 +175,16 @@ public class CustomComponent extends AbstractComponentContainer { } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components (zero or one) + */ + public int getComponentCount() { + return (root != null ? 1 : 0); + } + + /** * This method is not supported by CustomComponent. * * @see com.vaadin.ui.ComponentContainer#replaceComponent(com.vaadin.ui.Component, diff --git a/src/com/vaadin/ui/CustomLayout.java b/src/com/vaadin/ui/CustomLayout.java index 1d08860b50..0c11ff6114 100644 --- a/src/com/vaadin/ui/CustomLayout.java +++ b/src/com/vaadin/ui/CustomLayout.java @@ -185,6 +185,16 @@ public class CustomLayout extends AbstractLayout { } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components + */ + public int getComponentCount() { + return slots.values().size(); + } + + /** * Gets the child-component by its location. * * @param location diff --git a/src/com/vaadin/ui/GridLayout.java b/src/com/vaadin/ui/GridLayout.java index ae678198f9..08e3168791 100644 --- a/src/com/vaadin/ui/GridLayout.java +++ b/src/com/vaadin/ui/GridLayout.java @@ -399,6 +399,16 @@ public class GridLayout extends AbstractLayout implements } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components + */ + public int getComponentCount() { + return components.size(); + } + + /** * Paints the contents of this component. * * @param target diff --git a/src/com/vaadin/ui/Panel.java b/src/com/vaadin/ui/Panel.java index 017855a9a0..4d00cddfdd 100644 --- a/src/com/vaadin/ui/Panel.java +++ b/src/com/vaadin/ui/Panel.java @@ -282,8 +282,8 @@ public class Panel extends AbstractComponentContainer implements Scrollable, } /** - * Gets the component container iterator for going trough all the components - * in the container. + * Gets the component container iterator for going through all the + * components in the container. * * @return the Iterator of the components inside the container. * @see com.vaadin.ui.ComponentContainer#getComponentIterator() diff --git a/src/com/vaadin/ui/PopupView.java b/src/com/vaadin/ui/PopupView.java index 506b5380a7..4e1f387504 100644 --- a/src/com/vaadin/ui/PopupView.java +++ b/src/com/vaadin/ui/PopupView.java @@ -227,6 +227,16 @@ public class PopupView extends AbstractComponentContainer { } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components (zero or one) + */ + public int getComponentCount() { + return (visibleComponent != null ? 1 : 0); + } + + /** * Not supported in this implementation. * * @see com.vaadin.ui.AbstractComponentContainer#removeAllComponents() diff --git a/src/com/vaadin/ui/SplitPanel.java b/src/com/vaadin/ui/SplitPanel.java index cc8a19aa3d..2fe5f43d97 100644 --- a/src/com/vaadin/ui/SplitPanel.java +++ b/src/com/vaadin/ui/SplitPanel.java @@ -74,8 +74,7 @@ public class SplitPanel extends AbstractLayout { int i = 0; public boolean hasNext() { - if (i < (firstComponent == null ? 0 : 1) - + (secondComponent == null ? 0 : 1)) { + if (i < getComponentCount()) { return true; } return false; @@ -231,6 +230,23 @@ public class SplitPanel extends AbstractLayout { } /** + * Gets the number of contained components. Consistent with the iterator + * returned by {@link #getComponentIterator()}. + * + * @return the number of contained components (zero, one or two) + */ + public int getComponentCount() { + int count = 0; + if (firstComponent != null) { + count++; + } + if (secondComponent != null) { + count++; + } + return count; + } + + /** * Paints the content of this component. * * @param target diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java index ffbacefce1..89a35ce69f 100644 --- a/src/com/vaadin/ui/TabSheet.java +++ b/src/com/vaadin/ui/TabSheet.java @@ -124,6 +124,16 @@ public class TabSheet extends AbstractComponentContainer { } /** + * Gets the number of contained components (tabs). Consistent with the + * iterator returned by {@link #getComponentIterator()}. + * + * @return the number of contained components + */ + public int getComponentCount() { + return components.size(); + } + + /** * Removes a component and its corresponding tab. * * If the tab was selected, the first eligible (visible and enabled) |