Package com.googlecode.gwt.test.exceptions

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


         if (value instanceof TextResource) {
            text = ((TextResource) value).getText();
         } else if (value instanceof String) {
            text = (String) value;
         } else {
            throw new GwtTestUiBinderException("Error in " + owner.getClass().getSimpleName()
                     + ".ui.xml : <ui:text> tag declared without 'from' attribute");
         }
      }
View Full Code Here


   }

   T build() {
      if (rootComponent == null) {
         if (currentTag == null) {
            throw new GwtTestUiBinderException(owner.getClass().getName()
                     + " does not declare a root widget in its corresponding .ui.xml file");
         } else {
            throw new GwtTestUiBinderException(
                     "Cannot build UiBinder component while the parsing of '"
                              + owner.getClass().getSimpleName() + ".ui.xml' is not finished");
         }

      } else if (!rootComponentClass.isInstance(rootComponent)) {
         throw new GwtTestUiBinderException("Error in '" + owner.getClass().getSimpleName()
                  + ".ui.xml' configuration : root component is expected to be an instance of '"
                  + rootComponentClass.getName() + "' but is actually an instance of '"
                  + rootComponent.getClass().getName() + "'");
      }
View Full Code Here

      }

      if (parentTag == null) {
         // parsing is finished, this must be the root component
         if (rootComponent != null) {
            throw new GwtTestUiBinderException("UiBinder template '" + owner.getClass().getName()
                     + "' should declare only one root widget in its corresponding .ui.xml file");
         } else {
            rootComponent = currentObject;
         }
      } else {
View Full Code Here

         Class<?> clazz = null;
         try {
            clazz = GwtReflectionUtils.getClass(className);
         } catch (ClassNotFoundException e) {
            throw new GwtTestUiBinderException("Cannot find class '" + className
                     + "' declared in file '" + owner.getClass().getSimpleName() + ".ui.xml");
         }

         if (UIObject.class.isAssignableFrom(clazz) || IsWidget.class.isAssignableFrom(clazz)) {

            UiObjectTag<Object> uibinderTag = DefaultUiWidgetTagFactory.get().createUiObjectTag(
                     clazz, attributes);

            uibinderTag.startTag(clazz, attributes, parentTag, owner);

            return uibinderTag;
         } else {
            throw new GwtTestUiBinderException("Not managed UiBinder type '" + clazz
                     + "' declared in file '" + owner.getClass().getSimpleName() + ".ui.xml"
                     + "', only implementation of '" + IsWidget.class.getName()
                     + "' or subclass of '" + UIObject.class.getName() + "' are allowed");
         }
      } else if (UiBinderXmlUtils.isResourceTag(nameSpaceURI, localName)) {
View Full Code Here

   private Object extractResource(String group, UiResourceManager resourceManager, Object owner) {
      String[] splitted = group.split("\\.");
      String resourceAlias = splitted[0];
      Object resource = resourceManager.getUiResource(resourceAlias);
      if (resource == null) {
         throw new GwtTestUiBinderException("Error in file '" + owner.getClass().getSimpleName()
                  + ".ui.xml' : no resource declared for alias '" + resourceAlias + "'");
      }

      if (splitted.length == 1) {
         return resource;
      }

      // handle "alias.myDataResource.getUrl"
      try {
         for (int i = 1; i < splitted.length; i++) {
            if (CssResource.class.isInstance(resource)) {
               // special case of css styles
               return splitted[i];
            } else {
               resource = GwtReflectionUtils.callPrivateMethod(resource, splitted[i]);
            }
         }

         return resource;

      } catch (Exception e) {
         if (GwtTestException.class.isInstance(e)) {
            throw (GwtTestException) e;
         } else {
            throw new GwtTestUiBinderException("Error while calling property '"
                     + group.substring(group.indexOf('.') + 1) + "' on object of type '"
                     + resourceManager.getUiResource(resourceAlias).getClass().getName() + "'", e);
         }
      }
   }
View Full Code Here

      }

      private Widget getCustomHeaderWidget(List<IsWidget> childWidgets) {
         switch (childWidgets.size()) {
            case 0:
               throw new GwtTestUiBinderException(
                        "Error while setting a customHeader to a UiBinder DisclosurePanel : no widget added");
            case 1:
               return childWidgets.get(0).asWidget();
            default:
               throw new GwtTestUiBinderException(
                        "Error while setting a customHeader to a UiBinder DisclosurePanel : too many widgets ("
                                 + childWidgets.size() + ")");
         }
      }
View Full Code Here

            return GwtReflectionUtils.instantiateClass(ctr, parent, disclosurePanelOpen,
                     disclosurePanelClosed, text);
         } catch (Exception e) {
            // should never happen
            throw new GwtTestUiBinderException(
                     "Error while instanciating DisclosurePanel.DefaultHeader to handle <header> tag",
                     e);
         }
      }
View Full Code Here

      } else if (HasHTML.class.isInstance(wrapped)) {
         getElement(wrapped).appendChild(element);
      } else {
         String elementToString = (namespaceURI != null && namespaceURI.length() > 0)
                  ? namespaceURI + ":" + element.getTagName() : element.getTagName();
         throw new GwtTestUiBinderException("Found unexpected child element : <" + elementToString
                  + "> in " + wrapped.getClass().getName());
      }
   }
View Full Code Here

      if (wrapped instanceof UIObject) {
         return ((UIObject) wrapped).getElement();
      } else if (wrapped instanceof IsWidget) {
         return ((IsWidget) wrapped).asWidget().getElement();
      } else {
         throw new GwtTestUiBinderException(
                  "Cannot retrieve the Element instance in instances of '"
                           + wrapped.getClass().getName() + "', you have to override "
                           + this.getClass() + ".getElement(..) protected method");
      }
   }
View Full Code Here

   protected T instanciate(Class<? extends T> clazz, Map<String, Object> attributes, Object owner) {
      try {
         Constructor<? extends T> defaultCons = clazz.getDeclaredConstructor();
         return GwtReflectionUtils.instantiateClass(defaultCons);
      } catch (NoSuchMethodException e) {
         throw new GwtTestUiBinderException(
                  clazz.getName()
                           + " has no default (zero args) constructor. You have to register a custom "
                           + UiObjectTagFactory.class.getSimpleName()
                           + " by calling the protected method 'addUiObjectTagFactory' of your test class and override the 'instanciate(Class<T>) method in it");
      }
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.