Ejemplo n.º 1
0
    private Field getUniqueUiField(String alias) {
      Set<Field> resourceFields = GwtReflectionUtils.getFields(owner.getClass());
      if (resourceFields.size() == 0) {
        return null;
      }

      Field result = null;

      for (Field f : resourceFields) {
        if (alias.equals(f.getName()) && f.isAnnotationPresent(UiField.class)) {
          if (result != null) {
            throw new GwtTestUiBinderException(
                "There are more than one '"
                    + f.getName()
                    + "' @UiField in class '"
                    + owner.getClass().getName()
                    + "' or its superclass");
          }

          result = f;
        }
      }

      return result;
    }
Ejemplo n.º 2
0
    private void collectMultipleImports(
        String importValue, Map<String, Object> resources, Object owner) {

      try {
        String className = importValue.substring(0, importValue.lastIndexOf('.'));

        Class<?> clazz = GwtReflectionUtils.getClass(className);

        // this code handles classes and enums fine
        for (Field field : GwtReflectionUtils.getFields(clazz)) {
          if (Modifier.isStatic(field.getModifiers())
              && !Modifier.isPrivate(field.getModifiers())
              && !Modifier.isProtected(field.getModifiers())) {
            // register static field value in UiResourcesManager inner map
            Object value = GwtReflectionUtils.getStaticFieldValue(clazz, field.getName());
            resources.put(field.getName(), value);
          }
        }

      } catch (Exception e) {
        throw new GwtTestUiBinderException(
            "Error while trying to import multiple ui fields '" + importValue + "'", e);
      }
    }