Hello,

I have a generator that runs on a class if the class is @ClassEditGeneratedand it works. All classes that have the annotations also inherit from the base class.

I would like to move to the annotations of the base class. How to do it?

public class NaviSoftEditFormGeneratedFactoryGenerator extends Generator {

    @Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException { PrintWriter pw = context.tryCreate(logger, "pl.cba.lukaszbaczek.client", "NaviSoftEditFormGeneratedFactoryImpl");
        if (pw != null) {
            pw.println("package pl.cba.lukaszbaczek.client;");
            pw.println();
pw.println("import pl.cba.lukaszbaczek.navisoft.client.generatorForm.NaviSoftEditFormGeneratedFactory;"); pw.println("import pl.cba.lukaszbaczek.navisoft.client.generatorForm.NaviSoftGridEditGenerated;");
            pw.println();
pw.println("public class NaviSoftEditFormGeneratedFactoryImpl extends NaviSoftEditFormGeneratedFactory {"); pw.println(" public NaviSoftEditFormGeneratedFactoryImpl() {");

            TypeOracle oracle = context.getTypeOracle();
            for (JClassType type : oracle.getTypes()) {
                if (type.getAnnotation(ClassEditGenerated.class) != null) {
                    String name = type.getQualifiedSourceName();
                    pw.println("register(\"" + name + "\", ");
                    pw.println("    new FactoryMethod() {");
pw.println(" public NaviSoftGridEditGenerated create() {");
                    pw.println("            return new " + name + "();");
                    pw.println("        }");
                    pw.println("    });");
                }
            }
            pw.println("    }");
            pw.println("}");
            context.commit(logger, pw);
        }
return "pl.cba.lukaszbaczek.client.NaviSoftEditFormGeneratedFactoryImpl";
    }
}

Regards,

--
You received this message because you are subscribed to the Google Groups "Google 
Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to