Tuesday, February 3, 2015

Generator annotations BaseClass

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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment