Thomas Broyer has posted comments on this change.

Change subject: Log warning when wrongly using RootPanel
......................................................................


Patch Set 1: Code-Review-1

(2 comments)

I can't count the number of times I had to point to “the "Using a LayoutPanel without RootLayoutPanel" recipe at http://www.gwtproject.org/doc/latest/DevGuideUiPanels.html#Recipes” and this patch is only an incomplete fix to that. A bunch of people were adding CellBrowser and/or DataGrid to non-ProvidesResize widgets (such as HTMLPanel, within a UiBinder template), or even DockLayoutPanel. Adding LayoutPanel to RootPanel isn't the most common error (by far).

If you want to add a "decent" log warning users of such misuses, you want to hook into onAttach and warn them if (within a small delay) the parent is not a ProvidesResize (with a special case for HeaderPanel's middle widget maybe) and the size has not been set explicitly:

 if (!GWT.isProdMode()) {
    Schedule.get().scheduleDeferred(new ScheduledCommand() {
       @Override
       public void execute() {
          if (getParent() instanceof ProvidesResize
|| (getParent() instanceof HeaderPanel && ((HeaderPanel) getparent()).getContentWidget() == Widget.this) {
             return;
          }
          if (getElement().getStyle().getWidth().isEmpty()
              || getElement().getStyle.getHeight().isEmpty()) {
GWT.log("Layout panel added to a non-ProvidesResize and not given an explicit size");
          }
       }
    });
 }

....................................................
File user/src/com/google/gwt/user/client/ui/RootPanel.java
Line 309:       if (w instanceof LayoutPanel) {
I think DockLayoutPanel and SplitLayoutPanel (and possibly TabLayoutPanel) are much more common than LayoutPanel.


Line 310: GWT.log("Adding a LayoutPanel to RootPanel, did you mean RootLayoutPanel instead?"); Adding a LayoutPanel and setting its size explicitly is not a problem. Not something I'd recommend but perfectly "legal", and we have flags to turn off more debatable warnings (user.agent.runtimeWarning, gwt.suppressNonStaticFinalFieldWarnings)


--
To view, visit https://gwt-review.googlesource.com/3637
To unsubscribe, visit https://gwt-review.googlesource.com/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: If3b8a559edef046b4c2e9ad3e5ac5840a193428f
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Daniel Kurka <[email protected]>
Gerrit-Reviewer: Daniel Kurka <[email protected]>
Gerrit-Reviewer: Leeroy Jenkins <[email protected]>
Gerrit-Reviewer: Thomas Broyer <[email protected]>
Gerrit-HasComments: Yes

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
--- You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to