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();

Source Link

Usage

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

License:Apache License

public void beginWrappedProxy(SourceWriter writer, String wrappedProxySuperclassName) {
    writer.println();
    writer.println("public static class " + WRAPPED_CLASS_NAME);
    writer.println("extends " + wrappedProxySuperclassName + "<" + presenterInspector.getPresenterClassName()
            + "> " + "implements " + ClassCollection.delayedBindClassName + " {");
    writer.indent();/*from www.j  a va  2s. c  o m*/
}

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

License:Apache License

private void writeGetPlaceTitleMethodConstantText(SourceWriter writer) {
    writer.println();
    writer.println("protected void getPlaceTitle(GetPlaceTitleEvent event) {");
    writer.indent();/*from  w w  w .j  a  v  a2 s  .c om*/
    writer.println("event.getHandler().onSetPlaceTitle( \"" + title + "\" );");
    writer.outdent();
    writer.println("}");
}

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

License:Apache License

/**
 * Writes the {@code getTabDataInternal} method definition in the generated proxy.
 *
 * @param writer The {@code SourceWriter}
 *///  w w  w  .  jav a 2 s .  c  o  m
public void writeGetTabDataInternalMethod(SourceWriter writer) throws UnableToCompleteException {
    if (returnString) {
        // Presenter static method returning a string
        assert tabPriority != null;
        writer.println();
        writer.println("protected TabData getTabDataInternal(" + ginjectorInspector.getGinjectorClassName()
                + " ginjector) {");
        writer.indent();
        writer.print("return new TabDataBasic(");
        writer.print(presenterInspector.getPresenterClassName() + ".");
        writeTabInfoFunctionCall(writer);
        writer.println(", " + tabPriority + ");");
        writer.outdent();
        writer.println("}");
    } else {
        // Presenter static method returning tab data
        writer.println();
        writer.println("protected TabData getTabDataInternal(" + ginjectorInspector.getGinjectorClassName()
                + " ginjector) {");
        writer.indent();
        writer.print("return ");
        writer.print(presenterInspector.getPresenterClassName() + ".");
        writeTabInfoFunctionCall(writer);
        writer.println(";");
        writer.outdent();
        writer.println("}");
    }
}

From source file:com.kk_electronic.gwt.rebind.ClassMapGenerator.java

License:Open Source License

private void writeData(SourceWriter sw) throws UnableToCompleteException {
    sw.println();
    sw.println("{");
    sw.indent();/*  w w  w . java  2  s  .co  m*/
    for (JClassType classType : valueType.getSubtypes()) {
        String key = getKeyFromClass(classType);
        sw.println("map.put(" + key + "," + classType.getQualifiedSourceName() + ".class);");
        sw.println("reversemap.put(" + classType.getQualifiedSourceName() + ".class, " + key + ");");
    }
    sw.outdent();
    sw.println("}");
}

From source file:com.kk_electronic.gwt.rebind.FlexInjectorGenerator.java

License:Open Source License

private void writeConstructor(SourceWriter sw) throws UnableToCompleteException {
    sw.println();
    sw.println("@SuppressWarnings(\"unchecked\")");
    sw.println("public " + className + "() {");
    sw.indent();/*from   w ww.  j  a v a 2s  . co  m*/
    sw.println("FlexInjector fragment;");
    for (String key : getClasses().keySet()) {
        if (key != null) {
            sw.println("fragment = new fragment$" + key + "();");
            for (JClassType j : getClasses().get(key)) {
                sw.println("fragmentMap.put(" + j.getQualifiedSourceName() + ".class, fragment);");
            }
        } else {
            for (JClassType j : getClasses().get(key)) {
                writeFragment(sw, j);
            }
        }
    }
    sw.outdent();
    sw.println("}");
}

From source file:com.kk_electronic.gwt.rebind.RemoteServiceGenerator.java

License:Open Source License

private void writeMethod(SourceWriter sw, JClassType interfaze, JMethod method) {
    JParameter[] parameters = method.getParameters();
    sw.println();
    sw.print("private Class<?>[] " + method.getName().toUpperCase() + "_RETVAL");
    sw.print(" = new Class<?>[]{");
    writeTypeInfo(sw, parameters[parameters.length - 1].getType().isParameterized().getTypeArgs()[0]);
    sw.println("};");
    sw.println("@Override");
    sw.print("public void " + method.getName() + "(");
    for (int i = 0, c = parameters.length; i < c; i++) {
        if (i > 0) {
            sw.print(",");
        }//ww  w  . jav a 2 s  . co m
        sw.print(parameters[i].getType().getParameterizedQualifiedSourceName());
        sw.print(" ");
        sw.print(parameters[i].getName());
    }
    sw.println(") {");
    String callbackname = parameters[parameters.length - 1].getName();
    sw.print("   dispatcher.execute(" + callbackname + "," + method.getName().toUpperCase() + "_RETVAL,"
            + interfaze.getQualifiedSourceName() + ".class,\"" + escape(method.getName()) + "\"");
    for (int i = 0, c = parameters.length - 1; i < c; i++) {
        sw.print(",");
        sw.print(parameters[i].getName());
    }
    sw.println(");");
    sw.println("}");
}

From source file:com.rhizospherejs.gwt.rebind.MappingWriter.java

License:Open Source License

public void write() {
    SourceWriter sw = getSourceWriter();
    writeModelBridgeFactoryMethod(sw);//  w  ww . java2s. c  o m
    sw.println();
    writeMetaModelFactoryInterfaceImpl(sw);
    sw.println();
    writeModelBridgeImpl(sw);
    sw.println();
    writeMetaModelFactoryImpl(sw);
    sw.commit(logger);
}

From source file:com.seanchenxi.gwt.storage.rebind.StorageKeyProviderGenerator.java

License:Apache License

private void writeMethods(SourceWriter sw) throws UnableToCompleteException {
    final String keyParamName = "key";
    final String varKeyValueName = "keyValue";
    for (StorageKeyProviderMethod method : model.getMethods()) {
        final String returnName = method.getReturnType().getParameterizedQualifiedSourceName();
        final String parameters = method.isDynamicKey()
                ? (method.getKeyValueType().getQualifiedSourceName() + " " + keyParamName)
                : "";
        final String keyPrefix = method.getKeyPrefix();
        final String keySuffix = method.getKeySuffix();

        sw.println();
        sw.println("public %s %s(%s) {", returnName, method.getName(), parameters);
        sw.indent();/*ww  w .ja  v  a 2 s. co  m*/
        String keyClazz = method.getKeyClazz().getQualifiedSourceName();
        if (method.isDynamicKey()) {
            String keyPrefixStr = "";
            String keySuffixStr = "";
            if (keyPrefix != null && !keyPrefix.trim().isEmpty()) {
                keyPrefixStr = "\"" + keyPrefix + "\" + ";
            }
            if (keySuffix != null && !keySuffix.trim().isEmpty()) {
                keySuffixStr = " + \"" + keySuffix + "\"";
            }
            sw.println("String %s = %sString.valueOf(key)%s;", varKeyValueName, keyPrefixStr, keySuffixStr);
            sw.println("return createIfAbsent(%s, %s.class);", varKeyValueName, keyClazz);
        } else {
            String staticKeyValue = method.getStaticKeyValue();
            if (keyPrefix != null && !keyPrefix.trim().isEmpty()) {
                staticKeyValue = keyPrefix + staticKeyValue;
            }
            if (keySuffix != null && !keySuffix.trim().isEmpty()) {
                staticKeyValue += keySuffix;
            }
            sw.println("return createIfAbsent(\"%s\", %s.class);", staticKeyValue, keyClazz);
        }
        sw.outdent();
        sw.println("}");
    }
}

From source file:de.csenk.gwt.commons.bean.rebind.observe.impl.ObservableBeanFactoryCreator.java

License:Apache License

/**
 * @return/* w  w  w .j a v  a2  s . c  om*/
 */
public String create() {
    final String packageName = sourceType.getPackage().getName();

    final PrintWriter targetTypePrintWriter = context.tryCreate(logger, packageName, simpleTargetTypeName);
    if (targetTypePrintWriter == null) {
        return packageName + "." + simpleTargetTypeName;
    }

    final ClassSourceFileComposerFactory beanFactoryFactory = new ClassSourceFileComposerFactory(packageName,
            simpleTargetTypeName);
    beanFactoryFactory.setSuperclass(AbstractObservableBeanFactory.class.getCanonicalName());
    beanFactoryFactory.addImplementedInterface(sourceType.getQualifiedSourceName());

    beanFactoryFactory.addImport(AutoBean.class.getCanonicalName());
    beanFactoryFactory.addImport(GWT.class.getCanonicalName());

    final SourceWriter beanFactoryWriter = beanFactoryFactory.createSourceWriter(context,
            targetTypePrintWriter);
    try {
        beanFactoryWriter.println();

        for (ObservableBeanModel beanModel : model.getBeans().values()) {
            writeObservableBean(beanModel);
        }

        writeAutoBeanFactory(sourceType.getOracle(), beanFactoryWriter);
        writeFactoryMethods(beanFactoryWriter);
    } finally {
        beanFactoryWriter.commit(logger);
    }

    return beanFactoryFactory.getCreatedClassName();
}

From source file:de.csenk.gwt.commons.bean.rebind.observe.impl.ObservableBeanFactoryCreator.java

License:Apache License

/**
 * @param beanModel //from  ww  w. ja v  a  2s  .co  m
 * 
 */
private void writeObservableBean(ObservableBeanModel beanModel) {
    final String packageName = beanModel.getType().getPackage().getName();

    final PrintWriter targetTypePrintWriter = context.tryCreate(logger, packageName,
            beanModel.getSimpleImplementationTypeName());
    if (targetTypePrintWriter == null) {
        return;
    }

    final ClassSourceFileComposerFactory beanFactory = new ClassSourceFileComposerFactory(packageName,
            beanModel.getSimpleImplementationTypeName());
    beanFactory.setSuperclass(String.format("%s<%s>", AbstractObservableBean.class.getSimpleName(),
            beanModel.getType().getQualifiedSourceName()));

    beanFactory.addImport(AbstractObservableBean.class.getCanonicalName());
    beanFactory.addImport(AbstractObservableProperty.class.getCanonicalName());
    beanFactory.addImport(PropertyValueChangeEvent.class.getCanonicalName());

    final SourceWriter beanWriter = beanFactory.createSourceWriter(context, targetTypePrintWriter);
    try {
        beanWriter.println();

        writeBeanShimField(beanWriter, beanModel);
        writeConstructor(beanWriter, beanModel);
        writeAsMethod(beanWriter, beanModel);
    } finally {
        beanWriter.commit(logger);
    }
}