Examples of ClassSourceFileComposerFactory


Examples of com.google.gwt.user.rebind.ClassSourceFileComposerFactory

        }

        List<ConnectorBundle> bundles = buildBundles(logger,
                context.getTypeOracle());

        ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(
                packageName, className);
        composer.setSuperclass(requestedType);

        SourceWriter w = composer.createSourceWriter(context, printWriter);

        w.println("public void init() {");
        w.indent();

        for (ConnectorBundle bundle : bundles) {
View Full Code Here

Examples of com.google.gwt.user.rebind.ClassSourceFileComposerFactory

                logger, packageName, className
        );
        if (printWriter == null) {
            return null;
        }
        ClassSourceFileComposerFactory composerFactory =
                new ClassSourceFileComposerFactory(packageName, className);
        composerFactory.addImport("com.google.gwt.core.client.GWT");
        for (String interfaceName : interfaceNames) {
            composerFactory.addImplementedInterface(interfaceName);
        }

        composerFactory.addImport("org.timepedia.exporter.client.Exporter");
        return composerFactory.createSourceWriter(context, printWriter);
    }
View Full Code Here

Examples of com.google.gwt.user.rebind.ClassSourceFileComposerFactory

  }

  private void writeInterface(TypeLiteral<?> ginjectorInterface, String packageName,
      String implClassName, PrintWriter printWriter, GinjectorBindings rootBindings)
      throws UnableToCompleteException {
    ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName,
        implClassName);

    SourceWriter writer = null;

    try {
      composerFactory.addImplementedInterface(ReflectUtil.getSourceName(ginjectorInterface));

      writer = composerFactory.createSourceWriter(ctx, printWriter);

      String rootInjectorClass = ginjectorNameGenerator.getClassName(rootBindings);
      String rootFieldName = ginjectorNameGenerator.getFieldName(rootBindings);
      writer.beginJavaDocComment();
      writer.print("Top-level injector instance for injector " + rootBindings.getModule() + ".");
View Full Code Here

Examples of com.google.gwt.user.rebind.ClassSourceFileComposerFactory

    if (printWriter == null) {
      // We already created this Ginjector.
      return;
    }

    ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName,
        implClassName);
    SourceWriter writer = composerFactory.createSourceWriter(ctx, printWriter);

    FragmentMap fragments = new FragmentMap(bindings, packageName, implClassName,
        fragmentOutputterFactory);

    outputBindings(bindings, fragments, writer);
View Full Code Here

Examples of com.google.gwt.user.rebind.ClassSourceFileComposerFactory

      logger.log(TreeLogger.Type.ERROR, "The fragment " + fragmentPackageName + "." +
          fragmentClassName + " already exists.");
      throw new IllegalStateException("The fragment " + fragmentClassName + " already exists.");
    }

    ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(
        fragmentPackageName.toString(), fragmentClassName);

    composerFactory.addImport(GWT.class.getCanonicalName());
    composerFactory.addImport(ginjectorPackageName + "." + ginjectorClassName);
    writer = composerFactory.createSourceWriter(ctx, printWriter);

    injectorWriteContext = ginjectorFragmentContextFactory.create(bindings, fragmentPackageName,
        writer);
  }
View Full Code Here

Examples of com.google.gwt.user.rebind.ClassSourceFileComposerFactory

    String moduleName = createModule(logger, context, requestedType, packageName, requestedName);

    String ginjectorName =
        createGinjector(logger, context, packageName, requestedName, newClassName, moduleName);

    ClassSourceFileComposerFactory composerFactory =
        new ClassSourceFileComposerFactory(packageName, newClassName);
    composerFactory.setSuperclass(requestedType.getQualifiedSourceName());
    composerFactory.addImport(GWT.class.getCanonicalName());
    SourceWriter writer = composerFactory
        .createSourceWriter(context, context.tryCreate(logger, packageName, newClassName));
    writer.println("public void initialize() {");
    writer.indent();
    writer.println(
        "((" +  ginjectorName + ") GWT.create(" + ginjectorName + ".class)).injectMembers(this);");
View Full Code Here

Examples of com.google.gwt.user.rebind.ClassSourceFileComposerFactory

  }

  private String createGinjector(TreeLogger logger, GeneratorContext context, String packageName,
      String requestedName, String newClassName, String moduleName) {
    String ginjectorName = requestedName + "Ginjector";
    ClassSourceFileComposerFactory ginjectorFactory =
        new ClassSourceFileComposerFactory(packageName, ginjectorName);
    ginjectorFactory.makeInterface();
    ginjectorFactory.addImplementedInterface(Ginjector.class.getCanonicalName());
    ginjectorFactory.addImport(GinModules.class.getCanonicalName());
    ginjectorFactory.addAnnotationDeclaration("@GinModules(" + moduleName + ".class)");
    SourceWriter ginjectorWriter = ginjectorFactory.createSourceWriter(context,
        context.tryCreate(logger, packageName, ginjectorName));
    ginjectorWriter.println("void injectMembers(" + newClassName + " obj);");
    ginjectorWriter.commit(logger);
    return ginjectorName;
  }
View Full Code Here

Examples of com.google.gwt.user.rebind.ClassSourceFileComposerFactory

  }

  private String createModule(TreeLogger logger, GeneratorContext context, JClassType requestedType,
      String packageName, String requestedName) {
    String moduleName = requestedName + "Module";
    ClassSourceFileComposerFactory moduleFactory =
        new ClassSourceFileComposerFactory(packageName, moduleName);
    moduleFactory.setSuperclass(AbstractGinModule.class.getCanonicalName());
    moduleFactory.addImport(Names.class.getCanonicalName());
    SourceWriter moduleWriter = moduleFactory.createSourceWriter(context,
        context.tryCreate(logger, packageName, moduleName));

    moduleWriter.println("public void configure() {");
    moduleWriter.indent();
    for (JMethod method : requestedType.getMethods()) {
View Full Code Here

Examples of com.google.gwt.user.rebind.ClassSourceFileComposerFactory

    // Pick a name for the generated class to not conflict.
    String generatedSimpleSourceName = sourceType.getSimpleSourceName()
        + "GadgetImpl";

    // Begin writing the generated source.
    ClassSourceFileComposerFactory f = new ClassSourceFileComposerFactory(
        sourceType.getPackage().getName(), generatedSimpleSourceName);
    f.addImport(GWT.class.getName());
    f.setSuperclass(typeName);

    // All source gets written through this Writer
    PrintWriter out = context.tryCreate(logger,
        sourceType.getPackage().getName(), generatedSimpleSourceName);

    // If an implementation already exists, we don't need to do any work
    if (out != null) {

      JClassType userPrefsType = GadgetUtils.getUserPrefsType(logger,
          typeOracle, sourceType);

      // We really use a SourceWriter since it's convenient
      SourceWriter sw = f.createSourceWriter(context, out);
      sw.println("public " + generatedSimpleSourceName + "() {");
      sw.indent();
      sw.println("initializeFeatures();");
      sw.println("init((" + userPrefsType.getQualifiedSourceName()
          + ")GWT.create(" + userPrefsType.getQualifiedSourceName()
          + ".class));");
      sw.outdent();
      sw.println("}");

      generateFeatureInitializers(logger, typeOracle, sw, sourceType);

      // Write out the manifest
      String manifestName = typeName;
      if (!GadgetUtils.useLongManifestName(logger, typeOracle, sourceType)) {
        int lastIndex = manifestName.lastIndexOf('.');
        if (lastIndex != -1) {
          manifestName = manifestName.substring(lastIndex + 1);
        }
      }
      OutputStream manifestOut = context.tryCreateResource(logger, manifestName
          + ".gadget.xml");
      if (manifestOut == null) {
        logger.log(TreeLogger.ERROR, "Gadget manifest was already created",
            null);
        throw new UnableToCompleteException();
      }

      generateGadgetManifest(logger, typeOracle, sourceType, new PrintWriter(
          new OutputStreamWriter(manifestOut)));
      context.commitResource(logger, manifestOut);

      sw.commit(logger);
    }

    return f.getCreatedClassName();
  }
View Full Code Here

Examples of com.google.gwt.user.rebind.ClassSourceFileComposerFactory

        JClassType superclass = oracle.findType(
                BaseElementIdHandler.class.getName()).isClass();
        assert superclass != null : "No BaseElementIdHandler type";

        ClassSourceFileComposerFactory factory = new ClassSourceFileComposerFactory(
                packageName, simpleSourceName);
        factory.setSuperclass(superclass.getQualifiedSourceName() + "<"
                + parser.getOwnerType().getParameterizedQualifiedSourceName()
                + ">");
        factory.addImplementedInterface(typeName);

        SourceWriter sw = factory.createSourceWriter(context, pw);
        writeGenerateAndSetIds(sw, parser.getOwnerType(), statements);
        sw.commit(logger);

        return factory.getCreatedClassName();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.