thx a lot for this little gem, Per, this made my day!

Apparently simple things seem so complicated in GWT at times, awful...
 
Uwe


Am Freitag, 17. Dezember 2010 19:32:51 UTC+1 schrieb Per Gustås:
>
> Hi Aldo, 
>
> another approach is not to use a SimplePanel at all. But rather to 
> implement something like a SimpleLayoutPanel yourself. 
> It will work fine with xxxLayout components embedded within it. (I 
> really think it is something Google missed to include in GWT 2.1.) 
>
> Please see below for one implementation that has worked fine for me. 
>
> regards 
> Per 
>
> ------------- 
> package se.perper.util; 
>
> import com.google.gwt.user.client.ui.HasOneWidget; 
> import com.google.gwt.user.client.ui.IsWidget; 
> import com.google.gwt.user.client.ui.LayoutPanel; 
> import com.google.gwt.user.client.ui.Widget; 
>
> public class SimpleLayoutPanel extends LayoutPanel implements 
> HasOneWidget { 
>
>         Widget widget; 
>
>         @Override 
>         public void setWidget(IsWidget w) { 
>                 setWidget(asWidgetOrNull(w)); 
>         } 
>
>         @Override 
>         public Widget getWidget() { 
>                 return widget.asWidget(); 
>         } 
>
>         @Override 
>         public void setWidget(Widget w) { 
>                 // Validate 
>             if (w == widget) { 
>               return; 
>             } 
>
>             // Detach new child. 
>             if (w != null) { 
>               w.removeFromParent(); 
>             } 
>
>             // Remove old child. 
>             if (widget != null) { 
>               remove(widget); 
>             } 
>
>             // Logical attach. 
>             widget = w; 
>
>             if (w != null) { 
>              add(w); 
>             } 
>         } 
> }; 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/FF7otNPtu1UJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to