In your ElementParserToUse annontation why not pass the class instead
of classname which enforces some typesafety.
On 09/01/2010, at 3:30 AM, ggeorg <[email protected]>
wrote:
Hi Ray,
Please have a look at:
http://code.google.com/p/google-web-toolkit/issues/detail?id=4461
the attached patch is the simplest patch I could make. It adds support
for adding custom ElementParser(s) to UiBinder by tagging each widgets
that is using a custom parser with the @ElementParserToUse annotation,
e.g.: for GWT Mosaic's LayoutPanel the code is:
@ElementParserToUse(className =
"org.gwt.mosaic.ui.elementparsers.LayoutPanelParser")
public class LayoutPanel extends AbsolutePanel implements
HasLayoutManager,
HasAnimation {
...
}
----
After applying the patch, the UiBinderWriter.registerParsers() looks
like this:
private void registerParsers() {
// TODO(rjrjr): Allow third-party parsers to register themselves
// automagically
addElementParser("com.google.gwt.dom.client.Element",
"com.google.gwt.uibinder.elementparsers.DomElementParser");
// Register widget parsers.
addWidgetParser("UIObject");
addWidgetParser("HasText");
addWidgetParser("HasHTML");
addWidgetParser("HasWidgets");
addWidgetParser("HTMLPanel");
addWidgetParser("DockPanel");
addWidgetParser("StackPanel");
addWidgetParser("DisclosurePanel");
addWidgetParser("TabPanel");
addWidgetParser("MenuItem");
addWidgetParser("MenuBar");
addWidgetParser("RadioButton");
addWidgetParser("CellPanel");
addWidgetParser("CustomButton");
addWidgetParser("DialogBox");
addWidgetParser("LayoutPanel");
addWidgetParser("DockLayoutPanel");
addWidgetParser("StackLayoutPanel");
addWidgetParser("TabLayoutPanel");
// Register custom widget parsers... (almost automagically)
Collection<OwnerField> uiFields = ownerClass.getUiFields();
if (uiFields == null) {
return;
}
for (OwnerField uiField : uiFields) {
JClassType fieldType = uiField.getType().getRawType().isClass();
String uiClassName = fieldType.getQualifiedSourceName();
if (elementParsers.containsKey(uiClassName)) {
continue;
}
if (fieldType != null
&& fieldType.isAnnotationPresent(ElementParserToUse.class))
{
String parserClassName = fieldType.getAnnotation
(ElementParserToUse.class).className();
if (parserClassName != null && parserClassName.length() > 0) {
addElementParser(uiClassName, parserClassName);
}
}
}
}
Kind Regards,
George.
On Jan 7, 12:04 am, Ray Ryan <[email protected]> wrote:
How could I stop you? :-)
Would you making an issue tracker entry about this and putting the
patch
there?
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors