From 4ccfd5186b932b44bdc1c52f3cf3f1583a034265 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Tue, 7 Feb 2012 13:24:23 +0200 Subject: [PATCH] Fix file that was accidentally emptied in previous commit --- .../ui/VAbstractPaintableWidgetContainer.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidgetContainer.java b/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidgetContainer.java index e69de29bb2..ebdb05a6c8 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidgetContainer.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidgetContainer.java @@ -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 getChildren() { + Collection children = new ArrayList(); + + addDescendantPaintables(getWidgetForPaintable(), children, + VPaintableMap.get(getConnection())); + + return children; + } + + private static void addDescendantPaintables(Widget widget, + Collection 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); + } + } + } + } + +} -- 2.39.5