Hi Daniel,
I think if you do not inject it into a field, you don't need the custom
parser to be registered at all, but I am not sure about that.
I will check your code later today.
Thanks,
George.
On 01/20/2010 02:01 AM, Daniel Dietrich wrote:
Hi George,
in your solution parsing of an annotated widget will not be custom
if the widget is not injected into a field, right?
Here's a different idea:
http://cafebab3.blogspot.com/2010/01/non-intrusive-gwt-2-mod-2nd-part.html
Perhaps it is useful for you...
Kind regards
Daniel
On 8 Jan., 17:30, 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