Package com.sencha.gxt.core.client.XTemplates

Examples of com.sencha.gxt.core.client.XTemplates.XTemplate


    SourceWriter sw = factory.createSourceWriter(context, pw);

    for (JMethod method : toGenerate.getOverridableMethods()) {
      TreeLogger l = logger.branch(Type.DEBUG, "Creating XTemplate method " + method.getName());
      final String template;
      XTemplate marker = method.getAnnotation(XTemplate.class);
      if (marker == null) {
        l.log(Type.ERROR, "Unable to create template for method " + method.getReadableDeclaration()
            + ", this may cause other failures.");
        continue;
      } else {
        if (marker.source().length() != 0) {
          if (marker.value().length() != 0) {
            l.log(Type.WARN, "Found both source file and inline template, using source file");
          }

          InputStream stream = getTemplateResource(context, method.getEnclosingType(), l, marker.source());
          if (stream == null) {
            l.log(Type.ERROR, "No data could be loaded - no data at path " + marker.source());
            throw new UnableToCompleteException();
          }
          template = Util.readStreamAsString(stream);
        } else if (marker.value().length() != 0) {
          template = marker.value();
        } else {
          l.log(Type.ERROR,
              "XTemplate annotation found with no contents, cannot generate method " + method.getName()
                  + ", this may cause other failures.");
          continue;
View Full Code Here


    SourceWriter sw = factory.createSourceWriter(context, pw);

    for (JMethod method : toGenerate.getMethods()) {
      TreeLogger l = logger.branch(Type.DEBUG, "Creating XTemplate method " + method.getName());
      final String template;
      XTemplate marker = method.getAnnotation(XTemplate.class);
      if (marker == null) {
        l.log(Type.ERROR, "Unable to create template for method " + method.getReadableDeclaration()
            + ", this may cause other failures.");
        continue;
      } else {
        if (marker.source().length() != 0) {
          if (marker.value().length() != 0) {
            l.log(Type.WARN, "Found both source file and inline template, using source file");
          }

          InputStream stream = getTemplateResource(context, toGenerate, l, marker.source());
          if (stream == null) {
            l.log(Type.ERROR, "No data could be loaded - no data at path " + marker.source());
            throw new UnableToCompleteException();
          }
          template = Util.readStreamAsString(stream);
        } else if (marker.value().length() != 0) {
          template = marker.value();
        } else {
          l.log(Type.ERROR,
              "XTemplate annotation found with no contents, cannot generate method " + method.getName()
                  + ", this may cause other failures.");
          continue;
View Full Code Here

    private Template createTemplate(Method method) {
      Configuration cfg = new Configuration();
      cfg.setObjectWrapper(ObjectWrapper.DEFAULT_WRAPPER);

      XTemplate xTemplate = method.getAnnotation(XTemplate.class);
      if (xTemplate == null) {
        throw new GwtTestException(
            "gwt-test-utils expects to find a @XTemplate annotation on method "
                + method.toString());
      }

      String templateName = method.toGenericString();

      if (xTemplate.source().length() > 0) {
        InputStream in = method.getDeclaringClass().getResourceAsStream(
            xTemplate.source());

        if (in == null) {
          throw new GwtTestException("Cannot find file @Template source file "
              + xTemplate.source() + " declared for method " + method);
        }
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        try {
          return new Template(templateName, br, cfg);
        } catch (IOException e) {
          throw new GwtTestException(
              "Error while trying to get template for method " + method);
        }
      } else {
        return Template.getPlainTextTemplate(templateName, xTemplate.value(),
            cfg);
      }

    }
View Full Code Here

TOP

Related Classes of com.sencha.gxt.core.client.XTemplates.XTemplate

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.