Package com.google.gwt.angular.client

Examples of com.google.gwt.angular.client.NgDepends


  private static ModuleGenerator instance;
 
  public String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException {
    JClassType type = context.getTypeOracle().findType(typeName);
   
    NgDepends deps = type.getAnnotation(NgDepends.class);
    String simpleName = type.getName() + AngularConventions.MODULEIMPL;
    ClassSourceFileComposerFactory fac = new ClassSourceFileComposerFactory(
        type.getPackage().getName(), simpleName);
   
    fac.addImport(GWT.class.getName());
    fac.addImport(Util.class.getName());
    fac.addImplementedInterface(AngularModule.class.getName());
    fac.setSuperclass(AngularModuleBase.class.getName());
   
    PrintWriter pw = context.tryCreate(logger, type.getPackage().getName(),
        simpleName);
   
    SourceWriter sw = null;
    String implTypeName = type.getQualifiedSourceName() + AngularConventions.MODULEIMPL;
 
    if (pw != null) {
      sw = fac.createSourceWriter(context, pw);
    }
    if (sw == null) {
      return implTypeName;
    }
    sw.indent();
   
    // constructor
    sw.println("public " + simpleName + "() {");
    sw.indent();
    // init(GWT.create(dep1), GWT.create(dep2))
    sw.print("init(");
    if (deps != null) {
      boolean first = true;
      for (Class<?> clazz : deps.value()) {
        if (clazz.getAnnotation(NgInject.class) != null) {
          if (!first) {
            sw.print(",");
          } else {
            first = false;
          }
          sw.print("GWT.create(" + clazz.getName() + ".class)");
        }
      }
    }
    sw.println(");");
 
    sw.outdent();
    sw.println("}");
    sw.println();
   
    // native init
    sw.println("public native void init(Object... args) /*-{");
    String modName = type.getSimpleSourceName();
    NgName ngName = type.getAnnotation(NgName.class);
    if (ngName != null) {
      modName = ngName.value();
    }
    sw.println("var module = $wnd.angular.module('" + modName + "', []);");
    if (deps != null) {
      int i = 0;
      for (Class<?> clazz : deps.value()) {
        NgInject ngInject = clazz.getAnnotation(NgInject.class);
        final String compInstance = "args[" + i++ + "]";
       
        // automatically adding inject based on classname to filters that are not annotated
        if (Filter.class.isAssignableFrom(clazz)) {
View Full Code Here

TOP

Related Classes of com.google.gwt.angular.client.NgDepends

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.