Reviewers: rjrjr,
Description:
Addresses
http://code.google.com/p/google-web-toolkit/issues/detail?id=5879
I've added new overloaded methods for all the use cases of UiBinder that
I could find. My mistake when I said that changing the existing methods
won't break the existing code, it would break the existing subclases.
I didn't write almost any test because I think all the new code is "too
simple to break", it's just a forwarding to the Widget method, that is
already tested. A second reason is because this tests would be
GWTTestCase tests. Anyway, if you think it would be good, I don't mind
at all to write them.
I didn't use the convenience method Widget.asWidgetOrNull(IsWidget), as
I've seen elsewhere, because I don't see the point of swallow a null
ref, that would be either a waste of CPU cycles in the best case or a
NPE who knows where. I prefer to call asWidget() directly in order to
check for a null ref and "fail fast". But, again, if is ok to swallow
the null references for any reason, please, let me know :)
One thing I don't like is that this patch will make the API is a little
bit inconsistent. I mean, I've only provided the IsWidget methods that
the UiBinder needs, so now there are some classes that provide both,
Widget and IsWidget, ways to do things, but the rest of the methods only
have the Widget way. What do you think?
Here is a detailed list of all the changes I've made. Let me know if I
missed something:
CellPanel:
setCellHeight(IsWidget,String)
setCellHorizontalAlignment(IsWidget, HorizontalAlignmentConstant)
setCellVerticalAlignment(IsWidget, VerticalAlignmentConstant)
setCellWidth(IsWidget, String)
HTMLPanel:
The UiBinder uses the deprecated method
HTMLPanel.addAndReplaceElement(Widget,com.google.gwt.user.client.Element),
so I overloaded that one.
addAndReplaceElement(IsWidget,com.google.gwt.user.client.Element)
AbsolutePanel
add(IsWidget,int int)
DockLayoutPanel
addNorth(IsWidget,doub)
addEast(IsWidget,double)
addWest(IsWidget,double)
addSouth(IsWidget,double)
LayoutPanel
setWidgetBottomHeight(Widget,double, Unit, double, Unit)
setWidgetLeftRight(Widget,double, Unit, double, Unit)
setWidgetLeftWidth(Widget,double, Unit, double, Unit)
setWidgetLeftWidth(Widget,double, Unit, double, Unit)
setWidgetTopBottom(Widget,double, Unit, double, Unit)
setWidgetTopHeight(Widget,double, Unit, double, Unit)
StackLayoutPanel
add(IsWidget, String, boolean, double)
add(IsWidget, IsWidget, double)
DockPanel
add(IsWidget,DockLayoutConstant)
HTMLTable (Grid)
setWidget(int,int,IsWidget)
DisclosurePanel
now implements HasWidgets.ForIsWidget
add(IsWidget)
remove(IsWidget)
Tree
I've created HasTreeItems.ForIsWidget.
Now Tree implements HasTreeItems.ForIsWidget
addItem(IsWidget)
Due to the HasTreeItemsParser enforces the children of a Tree to be
either a TreeItem or a Widget and fails in case of a IsWidget
implementation, I've corrected that and I've registered a
MockJavaResource of the IsWidget interface in the UiJavaResources class,
this way, in the tests, the parser can check if the child being parsed
is assignable to IsWidget or not, and then proceed.
I've added a test for the IsWidget case
CaptionPanel
now implements HasWidgets.ForIsWidget
add(IsWidget)
remove(IsWidget)
Please review this at http://gwt-code-reviews.appspot.com/1295806/show
Affected files:
user/src/com/google/gwt/uibinder/elementparsers/HasTreeItemsParser.java
user/src/com/google/gwt/user/client/ui/AbsolutePanel.java
user/src/com/google/gwt/user/client/ui/CaptionPanel.java
user/src/com/google/gwt/user/client/ui/CellPanel.java
user/src/com/google/gwt/user/client/ui/DisclosurePanel.java
user/src/com/google/gwt/user/client/ui/DockLayoutPanel.java
user/src/com/google/gwt/user/client/ui/DockPanel.java
user/src/com/google/gwt/user/client/ui/HTMLPanel.java
user/src/com/google/gwt/user/client/ui/HTMLTable.java
user/src/com/google/gwt/user/client/ui/HasTreeItems.java
user/src/com/google/gwt/user/client/ui/LayoutPanel.java
user/src/com/google/gwt/user/client/ui/StackLayoutPanel.java
user/src/com/google/gwt/user/client/ui/Tree.java
user/test/com/google/gwt/uibinder/elementparsers/HasTreeItemsParserTest.java
user/test/com/google/gwt/uibinder/test/UiJavaResources.java
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors