Package com.googlecode.gwt.test.exceptions

Examples of com.googlecode.gwt.test.exceptions.GwtTestUiBinderException


      return map;
   }

   private String computeUiChildMethodTagName(Method method) {
      if (!method.getName().startsWith("add")) {
         throw new GwtTestUiBinderException(
                  "Cannot compute tagname of @UiChild annotated method '"
                           + method.toGenericString()
                           + "': you have to fill the 'tagname' property of the @UiChild or to prefix your the method name with 'add'");
      }
      return method.getName().substring(3).toLowerCase();
View Full Code Here


   private void invokeUiChildMethod(T wrapped, List<IsWidget> childWidgets,
            UiChildMethodHolder uiChildMethodHolder) {
      if (uiChildMethodHolder.invocationLimit > -1
               && uiChildMethodHolder.invocationCount > uiChildMethodHolder.invocationLimit) {
         throw new GwtTestUiBinderException("@UiChild method '"
                  + uiChildMethodHolder.uiChildMethod.toGenericString()
                  + "' cannot be invoked more than " + uiChildMethodHolder.invocationLimit
                  + " times");
      } else if (childWidgets.size() != 1) {
         throw new GwtTestUiBinderException("@UiChild method '"
                  + uiChildMethodHolder.uiChildMethod.toGenericString()
                  + "' can only be applied to add one Widget, but " + childWidgets.size()
                  + " have been found");
      }

      try {
         uiChildMethodHolder.uiChildMethod.invoke(wrapped, childWidgets.get(0));
      } catch (Exception e) {
         throw new GwtTestUiBinderException(
                  "An exception has been thrown during invocation of @UiChild method: "
                           + uiChildMethodHolder.uiChildMethod.toGenericString(), e);
      }
      uiChildMethodHolder.invocationCount++;
   }
View Full Code Here

         if (clazz == TabLayoutPanel.class) {
            String barHeight = (String) attributes.get("barHeight");

            if (barHeight == null) {
               throw new GwtTestUiBinderException(
                        "Missing mandatory attribute 'barHeight' in a TabLayoutPanel declared in "
                                 + owner.getClass().getSimpleName() + ".ui.xml file");
            }

            String unit = (String) attributes.get("unit");
View Full Code Here

            continue;
         } else if (entry.getKey().getName().equals(uiFieldValue)
                  || (uiFieldValue == null && entry.getKey().getType() == clazz)) {
            Object providedObject = GwtReflectionUtils.getPrivateFieldValue(owner, entry.getKey());
            if (providedObject == null) {
               throw new GwtTestUiBinderException(
                        "The UiField(provided=true) '"
                                 + entry.getKey().getDeclaringClass().getSimpleName()
                                 + "."
                                 + entry.getKey().getName()
                                 + "' has not been initialized before calling 'UiBinder.createAndBind(..)' method");
View Full Code Here

            sb.delete(sb.length() - 2, sb.length() - 1);
         }

         sb.append(");'");

         throw new GwtTestUiBinderException(sb.toString(), e);
      }
   }
View Full Code Here

   <T> T createUiComponent(Class<UiBinder<?, ?>> uiBinderClass, Object owner) {
      @SuppressWarnings("unchecked")
      Class<T> rootComponentClass = (Class<T>) getRootElementClass(uiBinderClass);
      InputStream uiXmlStream = getUiXmlFile(owner.getClass(), uiBinderClass);
      if (uiXmlStream == null) {
         throw new GwtTestUiBinderException("Cannot find the .ui.xml file corresponding to '"
                  + owner.getClass().getName() + "'");
      }

      UiXmlContentHandler<T> contentHandler = new UiXmlContentHandler<T>(rootComponentClass, owner);

      XMLReader saxReader = XmlUtils.newXMLReader();

      try {
         saxReader.setContentHandler(contentHandler);
         saxReader.parse(new InputSource(uiXmlStream));
      } catch (Exception e) {
         if (GwtTestException.class.isInstance(e)) {
            throw (GwtTestException) e;
         } else {
            throw new GwtTestUiBinderException("Error while parsing '"
                     + owner.getClass().getSimpleName() + ".ui.xml'", e);
         }
      } finally {
         try {
            uiXmlStream.close();
View Full Code Here

            return (Class<?>) pType.getActualTypeArguments()[0];
         }
      }

      throw new GwtTestUiBinderException("The UiBinder subinterface '" + uiBinderClass.getName()
               + "' is not parameterized. Please add its generic types.");
   }
View Full Code Here

   public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
      if (method.getName().equals("createAndBindUi")) {
         return createAndBindUi(args[0]);
      } else {
         throw new GwtTestUiBinderException("Not managed method for UiBinder : " + method.getName());
      }
   }
View Full Code Here

      String anotherEventHandlerClassName = eventTypeClass.getName() + ".Handler";
      try {
         return (Class<EventHandler>) GwtReflectionUtils.getClass(anotherEventHandlerClassName);
      } catch (ClassNotFoundException e) {
         // should never happen
         throw new GwtTestUiBinderException("Cannot find handler class for event type '"
                  + eventTypeClass.getName() + "'. By convention, it should be '"
                  + eventHandlerClassName + "' or '" + anotherEventHandlerClassName + "'");
      }
   }
View Full Code Here

TOP

Related Classes of com.googlecode.gwt.test.exceptions.GwtTestUiBinderException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.