Example usage for com.google.gwt.user.rebind SourceWriter println

List of usage examples for com.google.gwt.user.rebind SourceWriter println

Introduction

In this page you can find the example usage for com.google.gwt.user.rebind SourceWriter println.

Prototype

void println(String s);

Source Link

Usage

From source file:com.gwtent.gen.aop.AOPCreator.java

License:Apache License

private void createMethodInvocationChain(SourceWriter source) {
    source.println("private MethodInvocationLinkedAdapter createMethodInvocationChain(Method method) {");
    source.indent();//  ww w  .jav  a  2s. c  o m
    source.println("List<MethodInterceptor> interceptors = new ArrayList<MethodInterceptor>();");
    source.println("for (Method adviceMethod : InterceptorMap.interceptors.get(method)){");
    source.println("   interceptors.add(AdviceInstanceProvider.INSTANCE.getInstance(adviceMethod));");
    source.println("}");
    source.println("interceptors.add(new MethodInterceptorFinalAdapter());");
    source.println("return new MethodInvocationLinkedAdapter(method, this, interceptors);");
    source.outdent();
    source.println("}");
}

From source file:com.gwtent.gen.reflection.GeneratorHelper.java

License:Apache License

/**
 * generator metaData/*from  w ww. j a  va 2  s  .c  o  m*/
 * @param dest field or method or class
 * @param source source to print code
 * @param metaData 
 */
public static void addMetaDatas(String dest, SourceWriter source,
        com.google.gwt.core.ext.typeinfo.HasMetaData metaData) {
    String[] tags = metaData.getMetaDataTags();
    for (int j = 0; j < tags.length; j++) {
        String[][] metas = metaData.getMetaData(tags[j]);
        for (int k = 0; k < metas.length; k++) {
            source.println(dest + ".addMetaData(\"" + tags[j] + "\", "
                    + GeneratorHelper.stringArrayToCode(metas[k]) + ");");
        }
    }
}

From source file:com.gwtent.gen.reflection.ReflectAllInOneCreator.java

License:Apache License

@Override
public void createSource(SourceWriter source, JClassType classType) {
    //ClassType -->> the interface name created automatically
    Map<JClassType, String> typeNameMap = new HashMap<JClassType, String>();

    genAllClasses(source, typeNameMap);//from w w  w.  j a  va 2  s. c om

    //      source.println("public " + getSimpleUnitName(classType) + "(){");
    //      source.indent();
    //      
    //      for (String classname : allGeneratedClassNames){
    //         source.println("new " + classname + "();");
    //      }
    //      source.outdent();
    //      source.println("}");

    source.println("public com.gwtent.reflection.client.Type doGetType(String name) {");
    source.indent();
    //source.println("com.gwtent.reflection.client.Type resultType = super.doGetType(name);");
    //source.println("if (resultType != null) {return resultType;}");

    for (JClassType type : typeNameMap.keySet()) {
        source.println("if (name.equals( \"" + type.getQualifiedSourceName() + "\")){return GWT.create("
                + typeNameMap.get(type) + ".class);}");
    }
    source.println();
    source.println("return null;");

    source.outdent();
    source.print("}");

}

From source file:com.gwtent.gen.reflection.ReflectAllInOneCreator.java

License:Apache License

private void genAllClasses(SourceWriter sourceWriter, Map<JClassType, String> typeNameMap) {
    for (JClassType type : candidateList) {
        String className = type.getPackage().getName().replace('.', '_') + '_'
                + getSimpleUnitNameWithOutSuffix(type) + "_GWTENTAUTO_ClassType"; //type.getPackage().getName().replace('.', '_') + '_' + type.getSimpleSourceName().replace('.', '_'); //getSimpleUnitName(type);

        sourceWriter.println("@ReflectionTarget(value=\"" + type.getQualifiedSourceName() + "\")");
        sourceWriter.println(//from   w w  w .j  ava 2 s  .c om
                "public static interface " + className + " extends com.gwtent.reflection.client.ClassType {}");

        typeNameMap.put(type, className);
    }
}

From source file:com.gwtent.gen.reflection.SourceVisitor.java

License:Apache License

@Override
protected void createSource(SourceWriter source, JClassType classType) {
    source.println("public " + getSimpleUnitName(classType) + "(){");
    source.indent();/*from   ww w.  j ava 2 s  .  co  m*/

    List<JClassType> types = allReflectionClasses();

    for (JClassType type : types) {
        ReflectionProxyGenerator gen = new ReflectionProxyGenerator();
        try {
            String classname = gen.generate(this.logger, context, type.getQualifiedSourceName());
            source.println("new " + classname + "();");
        } catch (UnableToCompleteException e) {
            throw new CheckedExceptionWrapper(e);
        }
    }

    source.outdent();
    source.println("}");
}

From source file:com.gwtplatform.dispatch.rebind.VelocityGenerator.java

License:Apache License

@Override
public String generate(TreeLogger treeLogger, GeneratorContext generatorContext, String typeName)
        throws UnableToCompleteException {
    logger = new Logger(treeLogger);
    typeOracle = generatorContext.getTypeOracle();
    type = getType(typeName);/*from  w ww.j a  v a 2 s . c o  m*/

    PrintWriter printWriter = tryCreatePrintWriter(generatorContext);
    if (printWriter == null) {
        return typeName + SUFFIX;
    }

    injector = Guice.createInjector(new RebindModule(logger, generatorContext));
    serializerProviderGenerator = injector.getInstance(SerializerProviderGenerator.class);
    generatorFactory = injector.getInstance(GeneratorFactory.class);

    registerPrimitiveTypes();
    generateRestServices();
    generateRestGinModule();
    generateSerializerProvider();

    ClassSourceFileComposerFactory composer = initComposer();
    SourceWriter sourceWriter = composer.createSourceWriter(generatorContext, printWriter);
    sourceWriter.indent();
    sourceWriter.println("@Override");
    sourceWriter.println("public void onModuleLoad() {}");
    sourceWriter.outdent();
    sourceWriter.commit(treeLogger);

    return typeName + SUFFIX;
}

From source file:com.gwtplatform.mvp.rebind.ApplicationControllerGenerator.java

License:Apache License

private void writeInit(SourceWriter sw, String generatorName, JClassType preBootstrapper,
        JClassType bootstrapper) {//  w  ww .j  a v a2s.  c o  m
    sw.println(OVERRIDE);
    sw.println(INJECT_METHOD);
    sw.indent();

    if (preBootstrapper != null) {
        sw.println(ONPREBOOTSTRAP, preBootstrapper.getSimpleSourceName());
        sw.println();
        sw.println(SCHEDULE_DEFERRED_1);
        sw.indent();
        sw.println(OVERRIDE);
        sw.println(SCHEDULE_DEFERRED_2);
        sw.indent();
    }

    sw.println(String.format(DELAYED_BIND, DelayedBindRegistry.class.getSimpleName(), generatorName));
    sw.println();

    sw.println(String.format(ONBOOTSTRAP, generatorName, bootstrapper.getSimpleSourceName()));

    sw.outdent();
    sw.println("}");

    if (preBootstrapper != null) {
        sw.outdent();
        sw.println("});");
        sw.outdent();
        sw.println("}");
    }

    sw.println(OVERRIDE);
    sw.println(ONMODULE_LOAD);
    sw.indent();
    sw.println(INIT);
    sw.outdent();
    sw.println("}");
}

From source file:com.gwtplatform.mvp.rebind.GinjectorGenerator.java

License:Apache License

private void writeMandatoryGetter(SourceWriter sourceWriter) {
    sourceWriter.println(SINGLETON_DECLARATION);
    sourceWriter.println();/*  www  .j  a v a  2 s. c  o m*/

    String eventBusName = EventBus.class.getSimpleName();
    sourceWriter.println(String.format(GETTER_METHOD, eventBusName, eventBusName));
    sourceWriter.println();

    String placeManagerName = PlaceManager.class.getSimpleName();
    sourceWriter.println(String.format(GETTER_METHOD, placeManagerName, placeManagerName));

    sourceWriter.println();
    String bootstrapperName = boostrapper.getSimpleSourceName();
    sourceWriter.println(String.format(GETTER_METHOD, bootstrapperName, bootstrapperName));
}

From source file:com.gwtplatform.mvp.rebind.NonLeafTabContentProxyOutputter.java

License:Apache License

private void writeRequestTabHandler(SourceWriter writer) {
    writer.println("requestTabsEventType = " + tabContainerClassName + "." + requestTabsFieldName + ";");
    if (changeTabFieldName != null) {
        writer.println("changeTabEventType = " + tabContainerClassName + "." + changeTabFieldName + ";");
    }// ww  w  .j av  a 2s  .c  o m
    writer.println("tabData = getTabDataInternal(ginjector);");
    writer.println("targetHistoryToken = \"" + getTargetNameToken() + "\";");
    writer.println("addRequestTabsHandler();");
}

From source file:com.gwtplatform.mvp.rebind.PresenterInspector.java

License:Apache License

/**
 * Writes the assignation into the {@code provider} field of
 * {@link com.gwtplatform.mvp.client.proxy.ProxyImpl ProxyImpl}.
 */// w  ww. ja  v  a  2s .co m
public void writeProviderAssignation(SourceWriter writer) {

    if (customProviderAnnotation != null) {
        JClassType customProvider = oracle.findType(customProviderAnnotation.value().getName());
        writer.println("presenter = new " + customProvider.getQualifiedSourceName() + "( ginjector."
                + getPresenterMethodName + "() );");

    } else if (proxyStandardAnnotation != null) {
        writer.println("presenter = new StandardProvider<" + presenterClassName + ">( ginjector."
                + getPresenterMethodName + "() );");
    } else if (proxyCodeSplitAnnotation != null) {
        writer.println("presenter = new CodeSplitProvider<" + presenterClassName + ">( ginjector."
                + getPresenterMethodName + "() );");
    } else {
        assert proxyCodeSplitBundleAnnotation != null;
        writer.print("presenter = new CodeSplitBundleProvider<" + presenterClassName + ", " + bundleClassName
                + ">(ginjector." + getPresenterMethodName + "(), ");
        if (ginjectorInspector.isGenerated()) {
            writer.print(bundleClassName + "." + presenterClass.getSimpleSourceName().toUpperCase() + ");");
        } else {
            writer.print(proxyCodeSplitBundleAnnotation.id() + ");");
        }
    }
}