From c661750fbc7149becd34548ac3a0a844df39b3b7 Mon Sep 17 00:00:00 2001
From: Artur Signell <artur.signell@itmill.com>
Date: Thu, 12 Jan 2012 16:22:25 +0000
Subject: #7614 Added getComponent(int) and getComponentIndex(Component) to
 CssLayout

svn changeset:22620/svn branch:6.8
---
 src/com/vaadin/ui/CssLayout.java | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/com/vaadin/ui/CssLayout.java b/src/com/vaadin/ui/CssLayout.java
index b952609b20..b9432df6b6 100644
--- a/src/com/vaadin/ui/CssLayout.java
+++ b/src/com/vaadin/ui/CssLayout.java
@@ -125,7 +125,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
         // see ticket #7668
         if (c.getParent() == this) {
             // When c is removed, all components after it are shifted down
-            if (index > components.indexOf(c)) {
+            if (index > getComponentIndex(c)) {
                 index--;
             }
             removeComponent(c);
@@ -275,4 +275,28 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
         removeListener(CLICK_EVENT, LayoutClickEvent.class, listener);
     }
 
+    /**
+     * Returns the index of the given component.
+     * 
+     * @param component
+     *            The component to look up.
+     * @return The index of the component or -1 if the component is not a child.
+     */
+    public int getComponentIndex(Component component) {
+        return components.indexOf(component);
+    }
+
+    /**
+     * Returns the component at the given position.
+     * 
+     * @param index
+     *            The position of the component.
+     * @return The component at the given index.
+     * @throws IndexOutOfBoundsException
+     *             If the index is out of range.
+     */
+    public Component getComponent(int index) throws IndexOutOfBoundsException {
+        return components.get(index);
+    }
+
 }
-- 
cgit v1.2.3