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

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

Introduction

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

Prototype

void outdent();

Source Link

Usage

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

License:Apache License

private void writeProxyMethodNonStaticWithHandler(SourceWriter writer) {
    writer.println();/*ww  w  . ja v  a2  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.print("public void success(" + presenterInspector.getPresenterClassName() + " p ) { p.");
    writePresenterMethodCall(writer);
    writer.println(" }");
    writer.println("public void failure(Throwable t) { event.getHandler().onSetPlaceTitle(null); }");
    writer.outdent();
    writer.println("} );");
    writer.outdent();
    writer.println("}");
}

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

License:Apache License

private void writeConstructor(SourceWriter sourceWriter, List<JClassType> presenters) {
    sourceWriter.print("@" + Inject.class.getSimpleName());
    sourceWriter.println();//from  w ww  .  ja  v a2 s.  c  om
    sourceWriter.print("public " + getClassName() + "(");
    sourceWriter.println();
    sourceWriter.indent();
    sourceWriter.indent();

    int i = 0;
    for (JClassType presenter : presenters) {
        String name = presenter.getSimpleSourceName();
        sourceWriter.print(String.format(CTOR_PARAM, name, name.toLowerCase()));
        if (i == presenters.size() - 1) {
            sourceWriter.print(") {");
        } else {
            sourceWriter.print(",");
        }
        sourceWriter.println();
        i++;
    }

    sourceWriter.outdent();
    sourceWriter.print("super(" + presenters.size() + ");");
    sourceWriter.println();
    for (JClassType presenter : presenters) {
        String name = presenter.getSimpleSourceName();
        sourceWriter.print(String.format(ARRAY_SETTER, name.toUpperCase(), name.toLowerCase()));
        sourceWriter.println();
    }
    sourceWriter.outdent();
    sourceWriter.print("}");
    sourceWriter.println();
    sourceWriter.outdent();
}

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

License:Apache License

/**
 * Writes the definition of the method responsible of handling this event.
 *
 * @param writer The {@link SourceWriter}.
 *//*from  ww w.j a va  2  s .co  m*/
public void writeHandlerMethod(SourceWriter writer) {
    writer.println("");
    writer.println("@Override");
    writer.println("public final void " + handlerMethodName + "( final " + eventTypeName + " event ) {");
    writer.indent();
    writer.println("getPresenter( new NotifyingAsyncCallback<" + presenterInspector.getPresenterClassName()
            + ">(getEventBus()) {");
    writer.indent();
    writer.println("@Override");
    writer.println("public void success(final " + presenterInspector.getPresenterClassName() + " presenter) {");
    writer.indent();
    writer.println("Scheduler.get().scheduleDeferred( new Command() {");
    writer.indent();
    writer.println("@Override");
    writer.println("public void execute() {");
    writer.indent();
    writer.println("presenter." + functionName + "( event );");
    writer.outdent();
    writer.println("}");
    writer.outdent();
    writer.println("} );");
    writer.outdent();
    writer.println("}");
    writer.outdent();
    writer.println("} );");
    writer.outdent();
    writer.println("}");
}

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

License:Apache License

@Override
public final void writeConstructor(SourceWriter writer, String className, boolean registerDelayedBind) {
    writer.println();//ww  w.ja v a  2 s  . c om
    writer.println("public " + className + "() {");
    if (registerDelayedBind) {
        writer.indent();
        writer.println("DelayedBindRegistry.register(this);");
        writer.outdent();
    }
    writer.println("}");
}

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

License:Apache License

@Override
public final void writeMethods(SourceWriter writer) throws UnableToCompleteException {
    // Write delayedBind
    writer.println();//from  www .j a  v  a 2 s.c  o m
    writer.println("@Override");
    writer.println("public void delayedBind(Ginjector baseGinjector) {");
    writer.indent();
    writeGinjectorAssignation(writer, ginjectorInspector.getGinjectorClassName());
    writer.println("bind(ginjector.getPlaceManager(),");
    writer.println("    ginjector.getEventBus());");
    writeSubclassDelayedBind(writer);
    writeAddHandlerForProxyEvents(writer);
    writer.outdent();
    writer.println("}");
    writeHandlerMethodsForProxyEvents(writer);

    writeSubclassMethods(writer);
}

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

License:Apache License

public void endWrappedProxy(SourceWriter writer) {
    writer.outdent();
    writer.println("}");
}

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

License:Apache License

private void writeGetPlaceTitleMethodConstantText(SourceWriter writer) {
    writer.println();//www. j a va  2  s .co  m
    writer.println("protected void getPlaceTitle(GetPlaceTitleEvent event) {");
    writer.indent();
    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}
 *//*from w w w  .j  a va 2s .co 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.jawspeak.gwt.verysimpletemplate.rebind.VerySimpleGwtTemplateGenerator.java

License:Apache License

private void generateMethodsForEachHtmlTemplate(TreeLogger logger, SourceWriter sourceWriter)
        throws SecurityException, ClassNotFoundException, IOException, CouldNotParseTemplateException {
    String folderPrefix = packageName.replace(".", "/");
    for (Method method : Class.forName(typeName).getMethods()) {
        String methodName = method.getName();
        if (!methodName.startsWith("get")) {
            break;
        }//from w  ww.j a v a2s  .  c om
        String path = folderPrefix + "/" + methodName.substring(3) + ".html";
        String template = Utility.getFileFromClassPath(path);
        String parameters = getParameters(method);
        sourceWriter.println("public VerySimpleGwtTemplate " + methodName + "(" + parameters + ") {");
        sourceWriter.indent();
        sourceWriter.println("VerySimpleGwtTemplate template = new VerySimpleGwtTemplate(\""
                + Generator.escape(template) + "\");");
        for (Map.Entry<String, String> entry : getTemplateReplaceables(template).entrySet()) {
            // TODO(jwolter): look for the getter method, and throw an exception if it doesn't exist
            // TODO(jwolter): look at the getter's return type, and do nice null checking then "" + or call toString()
            // TODO(jwolter): allow an arbitrary way to "pipe" subsequent options to the setter, so that you can for a date i.e. call a date formatter on it.
            // TODO(jwolter): basically look at the features of FreeMarker, and see how to integrate the best ones in here. Or adopt to FreemarkerGWT.

            // as for now, we simply turn each value into a String by prepending a "" + to the value.
            // also for the time being, remember you can have a $${token} that will not get replaced, so you can set it manually. So,
            // you should only have ${token}'s that you are comfortable getting them set literally as Strings.
            sourceWriter
                    .println("template.set(\"" + entry.getKey() + "\", " + "\"\" + " + entry.getValue() + ");");
        }
        sourceWriter.println("return template;");
        sourceWriter.outdent();
        sourceWriter.println("}");
    }
    sourceWriter.outdent();
}

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

License:Open Source License

private void generateClass(TreeLogger logger, GeneratorContext context)
        throws UnableToCompleteException, NotFoundException {
    PrintWriter printWriter = context.tryCreate(logger, packageName, className);

    if (printWriter == null) {
        return;//from   w  ww . j  a v  a 2  s. co m
    }

    ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(packageName, className);

    composer.addImport(HashMap.class.getCanonicalName());

    composer.addImplementedInterface(classType.getQualifiedSourceName());
    JClassType target = typeOracle.getType(ClassMap.class.getCanonicalName());
    for (JClassType interfaze : classType.getImplementedInterfaces()) {
        if (interfaze.getErasedType().equals(target.getErasedType())) {
            JClassType[] genericTypes = interfaze.isParameterized().getTypeArgs();
            keyType = genericTypes[0];
            valueType = genericTypes[1];
        }
    }

    //      if (!"java.lang.String".equals(keyType.getQualifiedSourceName())){
    //         logger.log(TreeLogger.ERROR, "keyType must be a String for now");
    //         throw new UnableToCompleteException();
    //      }

    composer.addImport(keyType.getQualifiedSourceName());
    composer.addImport(valueType.getQualifiedSourceName());

    SourceWriter sourceWriter = composer.createSourceWriter(context, printWriter);

    writeMethods(sourceWriter);
    writeData(sourceWriter);

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

    context.commit(logger, printWriter);
}