Revision: 6582
Author: [email protected]
Date: Mon Nov  2 10:18:58 2009
Log: Merge r6566 into releases/2.0.


http://code.google.com/p/google-web-toolkit/source/detail?r=6582

Modified:
  /releases/2.0/branch-info.txt
  /releases/2.0/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java

=======================================
--- /releases/2.0/branch-info.txt       Mon Nov  2 08:09:39 2009
+++ /releases/2.0/branch-info.txt       Mon Nov  2 10:18:58 2009
@@ -160,3 +160,6 @@
    Minor conflicts in Horizontal- and VerticalSplitPanels
    svn merge --ignore-ancestry -c 6578   
https://google-web-toolkit.googlecode.com/svn/trunk .

+tr...@6566 was merged into this branch
+  Improve the error message for 'GWT.create(UiBInder.class)' (as opposed  
to a subclass of UiBinder).
+  svn merge --ignore-ancestry -c 6566  
http://google-web-toolkit.googlecode.com/svn/trunk/ .
=======================================
---  
/releases/2.0/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java       
 
Thu Oct 29 15:26:24 2009
+++  
/releases/2.0/user/src/com/google/gwt/uibinder/rebind/UiBinderWriter.java       
 
Mon Nov  2 10:18:58 2009
@@ -272,8 +272,28 @@
      this.messages = new MessagesWriter(BINDER_URI, logger, templatePath,
          baseClass.getPackage().getName(), this.implClassName);

-    JClassType uiBinderType = baseClass.getImplementedInterfaces()[0];
+    // Check for possible misuse 'GWT.create(UiBinder.class)'
+    JClassType uibinderItself =
+      oracle.findType(UiBinder.class.getCanonicalName());
+    if (uibinderItself.equals(baseClass)) {
+      die("You must use a subtype of UiBinder in GWT.create(). E.g.,\n"
+          + "  interface Binder extends UiBinder<Widget, MyClass> {}\n"
+          + "  GWT.create(Binder.class);");
+    }
+
+    JClassType[] uiBinderTypes = baseClass.getImplementedInterfaces();
+    if (uiBinderTypes.length == 0) {
+      throw new RuntimeException("No implemented interfaces for "
+          + baseClass.getName());
+    }
+    JClassType uiBinderType = uiBinderTypes[0];
+
      JClassType[] typeArgs = uiBinderType.isParameterized().getTypeArgs();
+    if (typeArgs.length < 2) {
+      throw new RuntimeException(
+          "Root and owner type parameters are required for type %s"
+          + uiBinderType.getName());
+    }
      uiRootType = typeArgs[0];
      uiOwnerType = typeArgs[1];

@@ -788,7 +808,11 @@
    private BundleAttributeParser createBundleParser(JClassType bundleClass,
        XMLAttribute attribute) throws UnableToCompleteException {

-    final String templateResourceName = attribute.getName().split(":")[0];
+    final String[] templateResourceNames = attribute.getName().split(":");
+    if (templateResourceNames.length == 0) {
+      throw new RuntimeException("No template resource");
+    }
+    final String templateResourceName = templateResourceNames[0];
      warn("The %1$s mechanism is deprecated. Instead, declare the  
following "
          + "%2$s:with element as a child of your %2$s:UiBinder element: "
          + "<%2$s:with field='%3$s' type='%4$s.%5$s' />", BUNDLE_URI_SCHEME,

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to