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

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

Introduction

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

Prototype

void indent();

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();
    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();//from ww w.j a  va2  s . co m
    source.println("}");
}

From source file:com.gwtent.gen.LogableSourceCreator.java

License:Apache License

public String generate() throws UnableToCompleteException {
    JClassType classType;/*from   w w w  .j  a  v a 2  s .  c o  m*/
    try {
        logger.log(Type.DEBUG, "Start generate UNIT for " + typeName + " in " + this.getClass().getName());
        Calendar start = Calendar.getInstance();

        classType = typeOracle.getType(typeName);
        if (genExclusion(classType)) {
            return null;
        }

        SourceWriter source = getSourceWriter(classType, isUseLog(), 6);

        if ((source != null)) {
            source.indent();
            createSource(source, classType);
            source.outdent();
            source.commit(logger);
        }

        logger.log(Type.DEBUG, "Code commited, Unit name: " + getUnitName(classType) + " Time:"
                + (start.getTimeInMillis() - Calendar.getInstance().getTimeInMillis()));

        return getUnitName(classType);
    } catch (Throwable e) {
        this.logger.log(Type.ERROR, e.getMessage(), e);
        throw new UnableToCompleteException();
    }
}

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 ww w  .j  av a2  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.SourceVisitor.java

License:Apache License

@Override
protected void createSource(SourceWriter source, JClassType classType) {
    source.println("public " + getSimpleUnitName(classType) + "(){");
    source.indent();

    List<JClassType> types = allReflectionClasses();

    for (JClassType type : types) {
        ReflectionProxyGenerator gen = new ReflectionProxyGenerator();
        try {//from  w w  w.jav a  2  s.c om
            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);/*w  ww  .  jav  a  2s .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) {//from   ww  w. jav a2 s .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.NonLeafTabContentProxyOutputter.java

License:Apache License

private void writeGetTabDataInternalMethod(SourceWriter writer) throws UnableToCompleteException {
    if (tabLabel != null) {
        // Simple string tab label
        writer.println();/*  w  w w .  java2 s  .c o  m*/
        writer.println("protected TabData getTabDataInternal(" + ginjectorInspector.getGinjectorClassName()
                + " ginjector) {");
        writer.indent();
        writer.println("return new TabDataBasic(\"" + tabLabel + "\", " + tabPriority + ");");
        writer.outdent();
        writer.println("}");
    } else {
        tabInfoMethod.writeGetTabDataInternalMethod(writer);
    }
}

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

License:Apache License

private void writeProxyMethodStaticReturningString(SourceWriter writer) {
    writer.println();/*from ww  w.  ja va2 s  . c om*/
    writer.println("protected void getPlaceTitle(GetPlaceTitleEvent event) {");
    writer.indent();
    writer.print("String title = " + presenterInspector.getPresenterClassName() + ".");
    writePresenterMethodCall(writer);
    writer.println();
    writer.println("event.getHandler().onSetPlaceTitle( title );");
    writer.outdent();
    writer.println("}");
}

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

License:Apache License

private void writeProxyMethodStaticWithHandler(SourceWriter writer) {
    writer.println();//from  w ww . java 2 s  .  c om
    writer.println("protected void getPlaceTitle(GetPlaceTitleEvent event) {");
    writer.indent();
    writer.print(presenterInspector.getPresenterClassName() + ".");
    writePresenterMethodCall(writer);
    writer.println();
    writer.println("}");
}

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

License:Apache License

private void writeProxyMethodNonStaticReturnString(SourceWriter writer) {
    writer.println();//  w  ww.  jav a  2 s  .c o m
    writer.println("protected void getPlaceTitle(final GetPlaceTitleEvent event) {");
    writer.indent();
    writer.println("getPresenter( new NotifyingAsyncCallback<" + presenterInspector.getPresenterClassName()
            + ">(getEventBus()){");
    writer.indent();
    writer.indent();
    writer.println("public void success(" + presenterInspector.getPresenterClassName() + " p ) {");
    writer.indent();
    writer.print("String title = p.");
    writePresenterMethodCall(writer);
    writer.println();
    writer.println("event.getHandler().onSetPlaceTitle( title );");
    writer.outdent();
    writer.println(" }");
    writer.println("public void failure(Throwable t) { event.getHandler().onSetPlaceTitle(null); }");
    writer.outdent();
    writer.println("} );");
    writer.outdent();
    writer.println("}");
}