]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix file that was accidentally emptied in previous commit
authorLeif Åstrand <leif@vaadin.com>
Tue, 7 Feb 2012 11:24:23 +0000 (13:24 +0200)
committerLeif Åstrand <leif@vaadin.com>
Tue, 7 Feb 2012 11:24:23 +0000 (13:24 +0200)
src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidgetContainer.java

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ebdb05a6c8f402cbfea06851f67100401648b216 100644 (file)
@@ -0,0 +1,51 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.terminal.gwt.client.ui;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import com.google.gwt.user.client.ui.HasWidgets;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.terminal.gwt.client.VPaintableMap;
+import com.vaadin.terminal.gwt.client.VPaintableWidget;
+import com.vaadin.terminal.gwt.client.VPaintableWidgetContainer;
+
+public abstract class VAbstractPaintableWidgetContainer extends
+        VAbstractPaintableWidget implements VPaintableWidgetContainer {
+
+    /**
+     * Default constructor
+     */
+    public VAbstractPaintableWidgetContainer() {
+    }
+
+    public Collection<VPaintableWidget> getChildren() {
+        Collection<VPaintableWidget> children = new ArrayList<VPaintableWidget>();
+
+        addDescendantPaintables(getWidgetForPaintable(), children,
+                VPaintableMap.get(getConnection()));
+
+        return children;
+    }
+
+    private static void addDescendantPaintables(Widget widget,
+            Collection<VPaintableWidget> paintables, VPaintableMap paintableMap) {
+        // FIXME: Store hierarchy instead of doing lookup every time
+
+        if (widget instanceof HasWidgets) {
+            for (Widget child : (HasWidgets) widget) {
+                VPaintableWidget paintable = paintableMap.getPaintable(child);
+                if (paintable != null) {
+                    // If child is a paintable, add it to the collection
+                    paintables.add(paintable);
+                } else {
+                    // Else keep looking for paintables inside the child widget
+                    addDescendantPaintables(child, paintables, paintableMap);
+                }
+            }
+        }
+    }
+
+}