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, Object... args);

Source Link

Document

Emit a printf-style string.

Usage

From source file:fr.putnami.pwt.core.model.rebind.ModelCreator.java

License:Open Source License

private void appendTrueValidator(SourceWriter w, JField field) {
    AssertTrue trueAnnotation = field.getAnnotation(AssertTrue.class);
    if (trueAnnotation != null) {
        w.println(", new AssertTrueValidator(\"%s\")", trueAnnotation.message());
    }//from w  w  w.  j  av  a2s  . c  om
}

From source file:fr.putnami.pwt.core.model.rebind.ModelCreator.java

License:Open Source License

private void generateConstructor(TreeLogger logger, SourceWriter srcWriter) {
    int lastIndex = this.proxyModelQualifiedName.lastIndexOf('.');
    String className = lastIndex == -1 ? this.proxyModelQualifiedName
            : this.proxyModelQualifiedName.substring(lastIndex + 1, this.proxyModelQualifiedName.length());
    srcWriter.println("public %s(){", className);
    srcWriter.indent();//w  ww  . j  av  a2  s. c om

    if (this.subModels.get(this.parentType) != null) {
        srcWriter.println("super(%s.INSTANCE, %s.class);", this.subModels.get(this.parentType),
                this.beanType.getSimpleSourceName());
        srcWriter.println();
    } else {
        srcWriter.println("super(%s.class);", this.beanType.getSimpleSourceName());
        srcWriter.println();
    }

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

From source file:fr.putnami.pwt.core.model.rebind.ModelCreator.java

License:Open Source License

private void generateCreate(TreeLogger logger, SourceWriter srcWriter) {
    srcWriter.println("public %s newInstance() {", this.beanType.getSimpleSourceName());
    srcWriter.indent();/*from   ww  w .ja  v a  2 s .c  om*/
    if (!this.beanType.isAbstract()) {
        srcWriter.println("return new %s();", this.beanType.getSimpleSourceName());
    } else {
        srcWriter.println("throw new RuntimeException(\"Can not instantiate the abstract class %s\");",
                this.beanType.getSimpleSourceName());
    }
    srcWriter.outdent();
    srcWriter.println("}");
}

From source file:fr.putnami.pwt.core.model.rebind.ModelCreator.java

License:Open Source License

private void generateInternalGet(TreeLogger logger, SourceWriter srcWriter) {
    srcWriter.println("protected <P> P internalGet(%s bean, String fieldName){",
            this.beanType.getSimpleSourceName());
    srcWriter.indent();/*from ww w .j a  v  a  2  s  .  c o  m*/
    for (String propertyName : this.propertyTypes.keySet()) {
        JType propertyType = this.propertyTypes.get(propertyName);
        JPrimitiveType primitiveType = propertyType.isPrimitive();
        JMethod getter = this.getters.get(propertyName);
        if (getter != null) {
            if (primitiveType != null) {
                String boxedName = primitiveType.getQualifiedBoxedSourceName();
                boxedName = boxedName.substring(boxedName.lastIndexOf(".") + 1, boxedName.length());
                srcWriter.println(
                        "if(\"%s\".equals(fieldName)){  return (P) PrimitiveUtils.castTo%s(bean.%s()); }",
                        propertyName, boxedName, getter.getName());
            } else {
                srcWriter.println("if(\"%s\".equals(fieldName)){  return (P) bean.%s(); }", propertyName,
                        getter.getName());
            }
        } else if (this.publicFields.containsKey(propertyName)) {
            if (primitiveType != null) {
                String boxedName = primitiveType.getQualifiedBoxedSourceName();
                boxedName = boxedName.substring(boxedName.lastIndexOf(".") + 1, boxedName.length());
                srcWriter.println(
                        "if(\"%s\".equals(fieldName)){  return (P) PrimitiveUtils.castTo%s(bean.%s); }",
                        propertyName, boxedName, propertyName);
            } else {
                srcWriter.println("if(\"%s\".equals(fieldName)){  return (P) bean.%s; }", propertyName,
                        propertyName);
            }
        }
    }
    srcWriter.println();
    srcWriter.println("return null;");
    srcWriter.outdent();
    srcWriter.println("}");
}

From source file:fr.putnami.pwt.core.model.rebind.ModelCreator.java

License:Open Source License

private void generateInternalSet(TreeLogger logger, SourceWriter srcWriter) {
    srcWriter.println("protected <P> void internalSet(%s bean, String fieldName, P value){",
            this.beanType.getSimpleSourceName());
    srcWriter.indent();/*from   w  w w.  j  a v  a 2s.  co m*/
    for (String propertyName : this.propertyTypes.keySet()) {
        JType propertyType = this.propertyTypes.get(propertyName);
        JPrimitiveType primitiveType = propertyType.isPrimitive();
        JMethod setter = this.setters.get(propertyName);
        if (setter != null) {
            if (primitiveType != null) {
                srcWriter.println(
                        "if(\"%s\".equals(fieldName)){  bean.%s((%s) PrimitiveUtils.asPrimitive((%s)value)); }",
                        propertyName, setter.getName(), propertyType.getSimpleSourceName(),
                        primitiveType.getQualifiedBoxedSourceName());
            } else {
                srcWriter.println("if(\"%s\".equals(fieldName)){  bean.%s((%s) value); }", propertyName,
                        setter.getName(), propertyType.getSimpleSourceName());
            }
        } else if (this.publicFields.containsKey(propertyName)) {
            if (primitiveType != null) {
                srcWriter.println(
                        "if(\"%s\".equals(fieldName)){ bean.%s = PrimitiveUtils.asPrimitive((%s) value); }",
                        propertyName, propertyName, primitiveType.getQualifiedBoxedSourceName());
            } else {
                srcWriter.println("if(\"%s\".equals(fieldName)){  bean.%s = (%s) value; }", propertyName,
                        propertyName, propertyType.getSimpleSourceName());
            }
        }
    }
    srcWriter.outdent();
    srcWriter.println("}");
}

From source file:fr.putnami.pwt.core.widget.rebind.UiBinderLocalizedCreator.java

License:Open Source License

private void generateProxy(TreeLogger logger, SourceWriter srcWriter) {

    srcWriter.println("@UiTemplate(\"%s\")", this.templateName);
    srcWriter.println("interface Binder extends UiBinder<%s, %s> {", this.widgetType.getSimpleSourceName(),
            this.targetType.getSimpleSourceName());
    srcWriter.indent();//from w w w  .j  av a  2s.  com
    srcWriter.println("UiBinder<%s, %s> BINDER = GWT.create(Binder.class);",
            this.widgetType.getSimpleSourceName(), this.targetType.getSimpleSourceName());
    srcWriter.outdent();
    srcWriter.println("}");
    srcWriter.println();
    srcWriter.println("@Override");
    srcWriter.println("public %s createAndBindUi(%s owner) {", this.widgetType.getSimpleSourceName(),
            this.targetType.getSimpleSourceName());
    srcWriter.indent();
    srcWriter.println("return Binder.BINDER.createAndBindUi(owner);");
    srcWriter.outdent();
    srcWriter.println("}");
}

From source file:io.reinert.requestor.rebind.JsonAutoBeanGenerator.java

License:Apache License

private void generateFactoryInterface(SourceWriter w, Iterable<String> typeNames) {
    w.println("interface %s extends AutoBeanFactory {", factoryTypeName);
    for (String typeName : typeNames) {
        w.println("    AutoBean<%s> %s();", typeName, replaceDotByUpperCase(firstCharToLowerCase(typeName)));
    }//  ww  w .j a v a2 s .  c  o m
    w.println("}");
}

From source file:io.reinert.requestor.rebind.JsonAutoBeanGenerator.java

License:Apache License

private String generateListWrapperInterface(SourceWriter w, JClassType type) {
    String wrapperTypeName = getListWrapperTypeName(type);

    w.println("interface %s {", wrapperTypeName);
    w.println("    List<%s> getResult();", type.getQualifiedSourceName());
    w.println("    void setResult(List<%s> result);", type.getQualifiedSourceName());
    w.println("}");

    return wrapperTypeName;
}

From source file:io.reinert.requestor.rebind.JsonAutoBeanGenerator.java

License:Apache License

private String generateSetWrapperInterface(SourceWriter w, JClassType type) {
    String wrapperTypeName = getSetWrapperTypeName(type);

    w.println("interface %s {", wrapperTypeName);
    w.println("    Set<%s> getResult();", type.getQualifiedSourceName());
    w.println("    void setResult(Set<%s> result);", type.getQualifiedSourceName());
    w.println("}");

    return wrapperTypeName;
}