Example usage for com.google.gwt.user.rebind StringSourceWriter toString

List of usage examples for com.google.gwt.user.rebind StringSourceWriter toString

Introduction

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

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:com.bramosystems.oss.player.core.rebind.PlatformPropertyGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, SortedSet<String> possibleValues, String fallback,
        SortedSet<ConfigurationProperty> configProperties) throws UnableToCompleteException {
    StringSourceWriter sw = new StringSourceWriter();
    sw.println("{");
    sw.indent();/*from w w  w  . ja v  a2  s  .c o m*/
    sw.println("var pltf = navigator.platform.toLowerCase();");
    Iterator<String> it = possibleValues.iterator();
    if (it.hasNext()) {
        fillCode(sw, it.next());
        sw.print("else ");
        while (it.hasNext()) {
            fillCode(sw, it.next());
            sw.print("else ");
        }
        sw.println("{");
        sw.indent();
        sw.print("return 'other';");
        sw.outdent();
        sw.print("}");
    }
    sw.outdent();
    sw.println("}");
    return sw.toString();
}

From source file:com.googlecode.mgwt.useragent.rebind.UserAgentPropertyGenerator.java

License:Apache License

@Override
public String generate(TreeLogger logger, SortedSet<String> possibleValues, String fallback,
        SortedSet<ConfigurationProperty> configProperties) {
    assertUserAgents(logger, possibleValues);

    StringSourceWriter body = new StringSourceWriter();
    body.println("{");
    body.indent();/*w ww.ja  v a  2 s . c  o  m*/
    writeUserAgentPropertyJavaScript(body, possibleValues, fallback);
    body.outdent();
    body.println("}");

    return body.toString();
}

From source file:com.guit.rebind.binder.BinderContextImpl.java

License:Apache License

@Override
public void addAfterHandler(StringSourceWriter writer) {
    afterHandler.println(writer.toString());
}

From source file:com.guit.rebind.binder.BinderContextImpl.java

License:Apache License

@Override
public void addAfterWrappers(StringSourceWriter writer) {
    afterWrappers.println(writer.toString());
}

From source file:com.guit.rebind.binder.BinderContextImpl.java

License:Apache License

@Override
public void addBeforeHandler(StringSourceWriter writer) {
    beforeHandler.println(writer.toString());
}

From source file:com.guit.rebind.binder.BinderContextImpl.java

License:Apache License

@Override
public void addBeforeWrappers(StringSourceWriter writer) {
    beforeWrappers.println(writer.toString());
}

From source file:com.guit.rebind.binder.BinderContextImpl.java

License:Apache License

@Override
public String build(StringSourceWriter writer) {
    StringSourceWriter build = new StringSourceWriter();

    build.print(beforeWrappers.toString());
    for (SourceWriter w : wrappersBefore) {
        build.print(w.toString());/*from   w w w  .jav  a 2s.  c  o m*/
    }
    build.print(beforeHandler.toString());
    build.print(writer.toString());
    build.print(afterHandler.toString());
    for (SourceWriter w : wrappersAfter) {
        build.print(w.toString());
    }
    build.print(afterWrappers.toString());

    return build.toString();
}

From source file:com.surevine.chat.view.linker.IE6ImagePropertyProviderGenerator.java

License:Open Source License

@Override
public String generate(TreeLogger logger, SortedSet<String> possibleValues, String fallback,
        SortedSet<ConfigurationProperty> configProperties) throws UnableToCompleteException {
    StringSourceWriter body = new StringSourceWriter();

    body.println("{");
    body.indent();//  ww  w  . ja  v  a2  s  .c  o  m
    body.println("try {");
    body.indent();
    body.println("if(disableIE6PNGFix) { return 'false' };");
    body.println();
    body.println("var ua = navigator.userAgent.toLowerCase();");
    body.println();
    body.println("if(disableIE6PNGFixUAs && disableIE6PNGFixUAs.length) {");
    body.indent();
    body.println("for (var i = 0; i < disableIE6PNGFixUAs.length; ++i) {");
    body.indent();
    body.println("if(ua.indexOf(disableIE6PNGFixUAs[i]) != -1) { return 'false'; }");
    body.outdent();
    body.println("}");
    body.outdent();
    body.println("}");
    body.outdent();
    body.println("} catch(e) { } // Ignore");
    body.println();
    body.println("return 'true';");
    body.outdent();
    body.println("}");

    return body.toString();
}

From source file:org.cruxframework.crux.core.rebind.crossdevice.DeviceFeaturesPropertyGenerator.java

License:Apache License

public String generate(TreeLogger logger, SortedSet<String> possibleValues, String fallback,
        SortedSet<ConfigurationProperty> configProperties) throws UnableToCompleteException {
    for (String value : possibleValues) {
        if (!VALID_VALUES.contains(value)) {
            throw new CruxGeneratorException(
                    "Property device.features can not be assigned to value [" + value + "].");
        }//w w w .ja  v a  2s.  c om
    }
    StringSourceWriter body = new StringSourceWriter();
    body.println("{");
    body.indent();
    writeDeviceFeaturesPropertyJavaScript(body);
    body.outdent();
    body.println("}");

    return body.toString();
}

From source file:org.parallax3d.parallax.platforms.gwt.generator.SourceTextResourceGenerator.java

License:Open Source License

public String createAssignment(TreeLogger logger, ResourceContext context, JMethod method)
        throws UnableToCompleteException {
    URL[] resources = ResourceGeneratorUtil.findResources(logger, context, method);
    if (resources.length != 1) {
        logger.log(TreeLogger.ERROR, "Exactly one resource must be specified", (Throwable) null);
        throw new UnableToCompleteException();
    } else {/*w w w  .  j  a va 2  s.  c o m*/
        URL resource = resources[0];
        StringSourceWriter sw = new StringSourceWriter();
        sw.println("new " + SourceTextResource.class.getName() + "() {");
        sw.indent();
        if (!AbstractResourceGenerator.STRIP_COMMENTS) {
            sw.println("// " + resource.toExternalForm());
        }

        sw.println("public String getText() {");
        sw.indent();
        String toWrite = Util.readURLAsString(resource);
        if (toWrite.length() > 16383) {
            this.writeLongString(sw, toWrite);
        } else {
            sw.println("return \"" + Generator.escape(toWrite) + "\";");
        }

        sw.outdent();
        sw.println("}");
        sw.println("public String getName() {");
        sw.indent();
        sw.println("return \"" + method.getName() + "\";");
        sw.outdent();
        sw.println("}");
        sw.outdent();
        sw.println("}");
        return sw.toString();
    }
}