summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2012-01-12 16:22:25 +0000
committerArtur Signell <artur.signell@itmill.com>2012-01-12 16:22:25 +0000
commitc661750fbc7149becd34548ac3a0a844df39b3b7 (patch)
tree106b35552b6e57de5089d66265a7bb1003d90fee /src
parentfa81141d2230f37af17b20718a82709e004160be (diff)
downloadvaadin-framework-c661750fbc7149becd34548ac3a0a844df39b3b7.tar.gz
vaadin-framework-c661750fbc7149becd34548ac3a0a844df39b3b7.zip
#7614 Added getComponent(int) and getComponentIndex(Component) to CssLayout
svn changeset:22620/svn branch:6.8
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/ui/CssLayout.java26
1 files changed, 25 insertions, 1 deletions
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);
+ }
+
}