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:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java

License:Apache License

/**
 * @param srcWriter//from  w ww .  j  av a 2 s  .c o  m
 */
private void generateProxyWrapperStartMethod(SourceWriter srcWriter) {
    srcWriter.println();
    srcWriter.println("private boolean __startMethodCall(String methodDesc, boolean blocksScreen){");
    srcWriter.indent();

    srcWriter.println("boolean ret = !__syncProcessingMethods.containsKey(methodDesc);");
    srcWriter.println("if (ret){");
    srcWriter.indent();
    srcWriter.println("__syncProcessingMethods.put(methodDesc, true);");
    srcWriter.println("if (blocksScreen) Screen.blockToUser();");
    srcWriter.outdent();
    srcWriter.println("}");

    srcWriter.println("return ret;");

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

From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java

License:Apache License

/**
 * @param srcWriter/*  w w w.  j a  va 2  s  .  c o  m*/
 */
private void generateProxyWrapperUpdateTokenMethod(SourceWriter srcWriter) {
    srcWriter.println();
    srcWriter.println("private void __updateMethodToken(String methodDesc, String token){");
    srcWriter.indent();

    srcWriter.println("__syncProcessingMethods.put(methodDesc, false);");

    srcWriter.println("if (this.__hasParameters){");
    srcWriter.indent();
    srcWriter.println("super.setServiceEntryPoint(__baseEntrypoint + \"&"
            + CruxSynchronizerTokenService.CRUX_SYNC_TOKEN_PARAM + "=\" + token);");
    srcWriter.outdent();
    srcWriter.println("}else{");
    srcWriter.indent();
    srcWriter.println("super.setServiceEntryPoint(__baseEntrypoint + \"?"
            + CruxSynchronizerTokenService.CRUX_SYNC_TOKEN_PARAM + "=\" + token);");
    srcWriter.outdent();
    srcWriter.println("}");

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

From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java

License:Apache License

/**
 * @param srcWriter/*w  w  w .ja v a2  s.  com*/
 */
private void generateSetServiceEntryPointMethod(SourceWriter srcWriter) {
    srcWriter.println();
    srcWriter.println("public void setServiceEntryPoint(String entryPoint){");
    srcWriter.indent();

    srcWriter.println("__baseEntrypoint = entryPoint;");
    srcWriter.println("super.setServiceEntryPoint(entryPoint);");

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

From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java

License:Apache License

/**
 * @param srcWriter/*from w w  w .j ava 2  s  .c o  m*/
 */
private void generateWrapperProxyContructor(SourceWriter srcWriter) {
    srcWriter.println("public " + getProxyWrapperSimpleName() + "() {");
    srcWriter.indent();

    srcWriter.println("super();");
    srcWriter.println(
            "this.__hasParameters = (getServiceEntryPoint()!=null?getServiceEntryPoint().indexOf('?')>0:false);");
    if (this.hasSyncTokenMethod) {
        srcWriter.println("this.__baseEntrypoint = getServiceEntryPoint();");
        srcWriter.println(
                "this.__syncTokenService = (CruxSynchronizerTokenServiceAsync)GWT.create(CruxSynchronizerTokenService.class);");
    }
    srcWriter.println("String locale = Screen.getLocale();");
    srcWriter.println("if (locale != null && locale.trim().length() > 0){");
    srcWriter.indent();
    srcWriter.println("if (this.__hasParameters){");
    srcWriter.indent();
    srcWriter.println("setServiceEntryPoint(getServiceEntryPoint() + \"&locale=\" + locale);");
    srcWriter.outdent();
    srcWriter.println("}else{");
    srcWriter.indent();
    srcWriter.println("setServiceEntryPoint(getServiceEntryPoint() + \"?locale=\" + locale);");
    srcWriter.println("this.__hasParameters = true;");
    srcWriter.outdent();
    srcWriter.println("}");
    srcWriter.outdent();
    srcWriter.println("}");

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

From source file:org.cruxframework.crux.plugin.bootstrap.rebind.font.FontResourceGenerator.java

License:Apache License

/**
 *  Create a custom font-resource to inject at a stylesheet
 *  @param logger/*from  w w w.  j a v  a  2  s.c  o m*/
 *  @param context
 *  @param method
 */
@Override
public String createAssignment(TreeLogger logger, ResourceContext context, JMethod method)
        throws UnableToCompleteException {
    SourceWriter sw = new StringSourceWriter();

    sw.print("new ");
    sw.print(method.getReturnType().getQualifiedSourceName());
    sw.println("() {");
    sw.indent();

    writeGetFontName(method, sw);
    writeGetName(method, sw);
    writeEnsureInjected(sw);
    writeGetText(logger, context, method, sw);

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

From source file:org.cruxframework.crux.plugin.bootstrap.rebind.font.FontResourceGenerator.java

License:Apache License

private void writeGetFontName(JMethod method, SourceWriter sw) {
    sw.println("public String getFontName() {");
    sw.indent();

    sw.print("return \"");
    sw.print(getFontName(method));//  w w  w.ja  v  a 2s.  c  om
    sw.println("\";");
    sw.outdent();
    sw.println("}");
}

From source file:org.cruxframework.crux.plugin.bootstrap.rebind.font.FontResourceGenerator.java

License:Apache License

protected void writeEnsureInjected(SourceWriter sw) {
    sw.println("private boolean injected;");
    sw.println("public boolean ensureInjected() {");
    sw.indent();
    sw.println("if (!injected) {");
    sw.indentln("injected = true;");
    sw.indentln(StyleInjector.class.getName() + ".inject(getText());");
    sw.indentln("return true;");
    sw.println("}");
    sw.println("return false;");
    sw.outdent();//from  w w w .ja  v a2  s  .  c  o m
    sw.println("}");
}

From source file:org.cruxframework.crux.plugin.bootstrap.rebind.font.FontResourceGenerator.java

License:Apache License

private void writeGetName(JMethod method, SourceWriter sw) {
    sw.println("public String getName() {");
    sw.indent();
    sw.println("return \"" + method.getName() + "\";");
    sw.outdent();/*www  . j a  v  a  2 s  .  com*/
    sw.println("}");
}

From source file:org.cruxframework.crux.plugin.bootstrap.rebind.font.FontResourceGenerator.java

License:Apache License

private void writeGetText(TreeLogger logger, ResourceContext context, JMethod method, SourceWriter sw)
        throws UnableToCompleteException {
    sw.println("public String getText() {");
    sw.indent();

    URL[] urls = ResourceGeneratorUtil.findResources(logger, context, method);

    sw.print("return \"");
    sw.print("@font-face{");

    sw.print("font-family:'");
    sw.print(getFontName(method));/*from   w  w w.  j  av a2s  .  co m*/
    sw.print("';");

    sw.print("font-style:normal;");
    sw.print("font-weight:400;");

    try {
        String agent = context.getGeneratorContext().getPropertyOracle()
                .getSelectionProperty(logger, "user.agent").getCurrentValue();
        if (agent.equals("ie6") || agent.equals("ie8"))
            writeSrcIE(logger, context, method, sw, urls);
        else
            writeSrc(logger, context, method, sw, urls);
    } catch (BadPropertyValueException e) {
        throw new UnableToCompleteException();
    }
    sw.print("}");

    sw.println("\";");

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

}

From source file:org.cruxframework.crux.plugin.gadget.rebind.gwt.DefaultPreferenceGenerator.java

License:Apache License

/**
 * Write an instantiation expression for a given Preference subtype.
 *///  w w  w  . j  a  va  2s  .co  m
public void writeInstantiation(TreeLogger logger, SourceWriter sw, JClassType extendsPreferenceType,
        JMethod prefMethod) {
    sw.println("new " + extendsPreferenceType.getParameterizedQualifiedSourceName() + "() {");
    sw.indent();

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